diff --git a/README.md b/README.md index 15e3af6..428a23e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Settings → Add-ons → Add-on store → ⋮ → Repositories, add `https://git.setti.solutions/Daniel/cantabile-ha-addons`, then install the add-on. The Supervisor pulls the prebuilt images (`git.setti.solutions/daniel/cantabile-ha--:`, -named by `image:` in each `config.yaml`); this version: `0.1.2080`, arch amd64. +named by `image:` in each `config.yaml`); this version: `0.1.2148`, arch amd64. ## Layout diff --git a/cantabile_edge/config.yaml b/cantabile_edge/config.yaml index 0aaa43a..d810bb4 100644 --- a/cantabile_edge/config.yaml +++ b/cantabile_edge/config.yaml @@ -3,7 +3,7 @@ # the Hub's, wrapped by addon-run (Dockerfile). The image is prebuilt, # per arch (README.md: building it from src/). name: Cantabile Edge Agent -version: "0.1.2080" +version: "0.1.2148" slug: cantabile_edge description: Plans your home's energy with Cantabile and, with your consent, runs the devices you choose. url: https://cantabile.cloud diff --git a/cantabile_eebus/CHANGELOG.md b/cantabile_eebus/CHANGELOG.md index 5feec4b..a2241b9 100644 --- a/cantabile_eebus/CHANGELOG.md +++ b/cantabile_eebus/CHANGELOG.md @@ -2,6 +2,17 @@ ## Unreleased +- No more crashes or hangs on reconnects: a device that connects twice, + or drops off in the middle of pairing, no longer crashes the add-on; a + lock-up under load is fixed. An unexpected error ends only that one + device's connection; the others carry on. +- A heat pump or wallbox that loses the grid operator's limit (it reports + another limit than the one passed on) gets it again. +- A device back online gets the current limit at once. +- The grid operator's control box is never disconnected over the + add-on's own errors. +- A binding a device refused is asked for again, waiting longer each time + (30 s up to 10 min), so control resumes without a restart. - Declares to the grid operator's control box only what is known: the heat pumps' and wallboxes' reported power, else the rating you enter on a device's page. Unknown: nothing is declared and the grid operator's diff --git a/cantabile_eebus/Dockerfile b/cantabile_eebus/Dockerfile index a39685a..aed147a 100644 --- a/cantabile_eebus/Dockerfile +++ b/cantabile_eebus/Dockerfile @@ -7,6 +7,7 @@ FROM docker.io/library/golang:1.26.9-bookworm AS build WORKDIR /src COPY src/eebus-bridge/go.mod src/eebus-bridge/go.sum ./ +COPY src/eebus-bridge/third_party ./third_party RUN go mod download COPY src/eebus-bridge/*.go ./ ARG VERSION=0.0.0-dev diff --git a/cantabile_eebus/config.yaml b/cantabile_eebus/config.yaml index b902e6d..979af4a 100644 --- a/cantabile_eebus/config.yaml +++ b/cantabile_eebus/config.yaml @@ -4,7 +4,7 @@ # Assistant that isn't a Cantabile Hub. Devices are paired on its page # (ingress), by their SKI. name: Cantabile EEBUS -version: "0.1.2080" +version: "0.1.2148" slug: cantabile_eebus description: Pairs with EEBUS devices (the grid operator's control box, heat pumps, wallboxes, inverters), shows them in Home Assistant under Cantabile's names and hands the grid operator's §14a limit to the Cantabile agent; every control with its protection. url: https://cantabile.cloud diff --git a/cantabile_modbus/config.yaml b/cantabile_modbus/config.yaml index b92124a..fdad937 100644 --- a/cantabile_modbus/config.yaml +++ b/cantabile_modbus/config.yaml @@ -4,7 +4,7 @@ # Home Assistant that isn't a Cantabile Hub. Devices come from the options; # the page (ingress) shows them and each control's protection. name: Cantabile Modbus bridge -version: "0.1.2080" +version: "0.1.2148" slug: cantabile_modbus description: Reads inverters, meters, relays and circuits by Cantabile's device profiles (Modbus, or Home Assistant's own entities) and shows them in Home Assistant, each control with its protection. url: https://cantabile.cloud diff --git a/src/eebus-bridge/THIRD-PARTY-NOTICES.md b/src/eebus-bridge/THIRD-PARTY-NOTICES.md index ff91a91..e12f165 100644 --- a/src/eebus-bridge/THIRD-PARTY-NOTICES.md +++ b/src/eebus-bridge/THIRD-PARTY-NOTICES.md @@ -1,15 +1,15 @@ # Third-party notices: Cantabile EEBUS bridge -Copyright © 2026 Setti Solutions S.R.L, www.setti.md. The Cantabile EEBUS bridge links the open-source Go modules below (go list -deps of the bridge; regenerate with notices.sh). Their licences permit use, modification and redistribution in binary form when these notices are included. +Copyright © 2026 Setti Solutions S.R.L, www.setti.md. The Cantabile EEBUS bridge links the open-source Go modules below (go list -deps of the bridge; regenerate with notices.sh). Their licences permit use, modification and redistribution in binary form when these notices are included. Modules marked patched are built from a modified copy in third_party/ (its PATCHES.md lists the changes, published under the module's own licence). | Module | Version | Licence | |---|---|---| | github.com/ahmetb/go-linq/v3 | v3.2.0 | Apache-2.0 | | github.com/eclipse/paho.mqtt.golang | v1.5.0 | EPL-2.0 or EDL-1.0 (BSD-3-Clause); used under EDL-1.0 | -| github.com/enbility/eebus-go | v0.7.0 | MIT | +| github.com/enbility/eebus-go | v0.7.0, patched (third_party/eebus-go) | MIT | | github.com/enbility/go-avahi | v0.0.0-20240909195612-d5de6b280d7a | MIT | -| github.com/enbility/ship-go | v0.6.0 | MIT | -| github.com/enbility/spine-go | v0.7.0 | MIT | +| github.com/enbility/ship-go | v0.6.0, patched (third_party/ship-go) | MIT | +| github.com/enbility/spine-go | v0.7.0, patched (third_party/spine-go) | MIT | | github.com/enbility/zeroconf/v2 | v2.0.0-20240920094356-be1cae74fda6 | MIT | | github.com/godbus/dbus/v5 | v5.1.0 | BSD-2-Clause | | github.com/golanguzb70/lrucache | v1.2.0 | MIT | diff --git a/src/eebus-bridge/core.go b/src/eebus-bridge/core.go index ce3421a..c6e8cd1 100644 --- a/src/eebus-bridge/core.go +++ b/src/eebus-bridge/core.go @@ -6,10 +6,12 @@ import ( "errors" "fmt" "log" + "math" "sort" "strconv" "strings" "sync" + "sync/atomic" "time" ) @@ -46,6 +48,11 @@ type Options struct { // LPC timings (the use case's: failsafe after 120 s without the control // box's heartbeat) HeartbeatGrace time.Duration + // the check of a limit passed on (checkPassedOn): the tolerance of a + // reported limit, and the longest wait between attempts to write it + // again (defaults: DefaultPassOnToleranceW, DefaultPassOnRetryMax) + PassOnToleranceW float64 + PassOnRetryMax time.Duration } // Grid is the grid operator's limit as the bridge holds it (LPC, the @@ -90,6 +97,8 @@ type Core struct { // goroutine (the grid link takes its own lock, then this core's). OnNominal func(w float64) lastNominal float64 + resends map[string]resend // by SKI: limits written again (checkPassedOn) + cbSKI atomic.Value // the control box's SKI, string (noteControlBox) } func NewCore(opts Options, store *Store, backend Backend, profiles map[string]*Profile, signer *Signer) *Core { @@ -105,8 +114,15 @@ func NewCore(opts Options, store *Store, backend Backend, profiles map[string]*P if opts.HeartbeatGrace == 0 { opts.HeartbeatGrace = 120 * time.Second } + if opts.PassOnToleranceW == 0 { + opts.PassOnToleranceW = DefaultPassOnToleranceW + } + if opts.PassOnRetryMax == 0 { + opts.PassOnRetryMax = DefaultPassOnRetryMax + } c := &Core{opts: opts, store: store, backend: backend, profiles: profiles, signer: signer, - devices: map[string]*Device{}, now: time.Now, sent: map[string]string{}, pub: func(string, string, bool) {}} + devices: map[string]*Device{}, now: time.Now, sent: map[string]string{}, pub: func(string, string, bool) {}, + resends: map[string]resend{}} for ski, d := range store.Devices { d.SKI = ski d.State = "offline" @@ -114,9 +130,27 @@ func NewCore(opts Options, store *Store, backend Backend, profiles map[string]*P } c.grid.State = "normal" c.started = c.now() + c.noteControlBox() return c } +// noteControlBox: the paired control box's SKI ("" none) for readers that +// must not wait for the core's lock (ControlBoxSKINow), under c.mu. +func (c *Core) noteControlBox() { + ski := "" + if d := c.controlBox(); d != nil { + ski = d.SKI + } + c.cbSKI.Store(ski) +} + +// ControlBoxSKINow: the paired control box's SKI, lock-free (as of the +// last change of pairings or kinds; cleared on unpairing). +func (c *Core) ControlBoxSKINow() string { + s, _ := c.cbSKI.Load().(string) + return s +} + func (c *Core) event(format string, a ...any) { msg := fmt.Sprintf(format, a...) log.Print(msg) @@ -180,12 +214,27 @@ func (c *Core) Connected(ski string, up bool) { if d == nil || !d.Paired { return } + // a report of the state it is in changes nothing (the library may report + // a connection twice): no event, no evaluation, no change to the + // back-off of a limit written again + state := "offline" if up { - d.State = "online" - } else { - d.State = "offline" - if d.Kind == KindControlBox { - d.set("heartbeat", false) + state = "online" + } + if d.State == state { + return + } + d.State = state + if !up && d.Kind == KindControlBox { + d.set("heartbeat", false) + } + if up { + // back after being away (§14a): the grid limit is due at once, on + // the next check; the attempt count stays, so a device that + // refuses it again backs off further + if r, ok := c.resends[d.SKI]; ok { + r.next = c.now() + c.resends[d.SKI] = r } } c.event("%s %s", d.Name, d.State) @@ -264,10 +313,92 @@ func (c *Core) Update(ski string, useCases []string, values map[string]any) { c.publishValues(d) if d.Kind == KindControlBox { c.evaluateGrid() + } else { + c.checkPassedOn(d) } c.nominalChanged() // a heat pump's nominal_max, a wallbox's current_max or phases came } +// checkPassedOn: a device that reports another limit than the grid limit +// passed on to it gets it again. A write can be lost without an error: it +// went to the device's connection that SHIP replaced a moment later (both +// sides connecting at once), or the device restarted. +func (c *Core) checkPassedOn(d *Device) { + if !c.opts.PassOn || !c.grid.Active() || d.State != "online" || !d.Available["limit"] || c.dry(d) != "" { + return + } + want, ok := d.Applied["limit"] + if !ok { + return + } + got, known := d.Number("limit") + active, _ := d.Values["limit_active"].(bool) + r, backingOff := c.resends[d.SKI] + if known && active && math.Abs(got-want) <= c.opts.PassOnToleranceW { + delete(c.resends, d.SKI) // holds it (again): the back-off starts over + return + } + now := c.now() + if backingOff && r.want == want && now.Before(r.next) { + return // backing off: the device refused or lost it again + } + if !backingOff || r.want != want { + r = resend{want: want} // a new target (0 W too) + } + wait := PassOnRetryFirst << r.n + if wait > c.opts.PassOnRetryMax || wait <= 0 { + wait = c.opts.PassOnRetryMax + } + r.n++ + r.next = now.Add(wait) + c.resends[d.SKI] = r + if err := c.backend.WriteLimit(d, want, true); err != nil { + c.event("%s: passing the grid limit on again failed: %v", d.Name, err) + return + } + c.event("%s reports a limit of %v (active %v): the grid limit %.0f W passed on again (attempt %d, next check after %s)", + d.Name, d.Values["limit"], active, want, r.n, wait) +} + +// resend: a device's grid limit written again (checkPassedOn), with its +// back-off: PassOnRetryFirst, doubling up to Options.PassOnRetryMax. +type resend struct { + want float64 + n int + next time.Time +} + +// The defaults of the pass-on check (docs/parameters.md E9b; the bridge has +// no Parameters source of its own: Options, set by the env of the same name +// in upper case). +const ( + // a reported limit within this of the one passed on holds it (devices + // round: 4166.67 W reported as 4167 W) + DefaultPassOnToleranceW = 50.0 + // the first wait after writing a limit again, doubling with each attempt + PassOnRetryFirst = 5 * time.Second + // the longest wait between two attempts + DefaultPassOnRetryMax = 5 * time.Minute +) + +// PassedOnSKIs: the devices holding a grid limit passed on now (the bridge +// reads them regularly, so checkPassedOn sees a lost write). +func (c *Core) PassedOnSKIs() []string { + c.mu.Lock() + defer c.mu.Unlock() + out := []string{} + if !c.grid.Active() { + return out + } + for _, d := range c.devices { + if _, ok := d.Applied["limit"]; ok && d.State == "online" { + out = append(out, d.SKI) + } + } + sort.Strings(out) + return out +} + // -- the owner's actions (the page) ------------------------------------------ var ErrRefused = errors.New("refused") @@ -284,69 +415,83 @@ func (c *Core) device(id string) *Device { // Pair: the owner trusts this SKI (after comparing it with the device's // own display or label). func (c *Core) Pair(ski, who string) error { - c.mu.Lock() - d := c.devices[strings.ToLower(ski)] - if d == nil { - c.mu.Unlock() - return fmt.Errorf("no device with SKI %s", ski) + // the core's part under its lock, unlocked deferred (a panic must not + // leave it held); the backend outside it + d, err := func() (*Device, error) { + c.mu.Lock() + defer c.mu.Unlock() + d := c.devices[strings.ToLower(ski)] + if d == nil { + return nil, fmt.Errorf("no device with SKI %s", ski) + } + if d.Paired { + return nil, nil + } + d.Paired, d.PairedAt, d.PairedBy = true, c.now().Unix(), who + if d.Kind == "" { + d.Kind = Classify(nil, d.Type) + } + if d.ID == "" { + d.ID = c.freeID(NewID(d.Brand, d.Model, d.Type, d.SKI)) + } + d.Profile = Recognise(c.profiles, d) + d.State = "connecting" + c.store.Devices[d.SKI] = d + c.save() + c.audit("paired %s (%s %s, SKI %s) by %s", d.Name, d.Brand, d.Model, d.SKI, who) + c.nominalChanged() + return d, nil + }() + if err != nil || d == nil { + return err } - if d.Paired { - c.mu.Unlock() - return nil - } - d.Paired, d.PairedAt, d.PairedBy = true, c.now().Unix(), who - if d.Kind == "" { - d.Kind = Classify(nil, d.Type) - } - if d.ID == "" { - d.ID = c.freeID(NewID(d.Brand, d.Model, d.Type, d.SKI)) - } - d.Profile = Recognise(c.profiles, d) - d.State = "connecting" - c.store.Devices[d.SKI] = d - c.save() - c.audit("paired %s (%s %s, SKI %s) by %s", d.Name, d.Brand, d.Model, d.SKI, who) - c.nominalChanged() - c.mu.Unlock() return c.backend.Pair(d.SKI, d.Kind) } // Deny: the owner refuses a pairing request. func (c *Core) Deny(ski, who string) error { - c.mu.Lock() - d := c.devices[strings.ToLower(ski)] - if d == nil || d.Paired { - c.mu.Unlock() - return fmt.Errorf("no pairing request from %s", ski) + err := func() error { + c.mu.Lock() + defer c.mu.Unlock() + d := c.devices[strings.ToLower(ski)] + if d == nil || d.Paired { + return fmt.Errorf("no pairing request from %s", ski) + } + d.State = "denied" + c.audit("denied pairing with %s (SKI %s) by %s", d.Name, d.SKI, who) + return nil + }() + if err != nil { + return err } - d.State = "denied" - c.audit("denied pairing with %s (SKI %s) by %s", d.Name, d.SKI, who) - c.mu.Unlock() return c.backend.Deny(ski) } // Unpair: a sealed device (the grid operator's control box) can't be // unpaired here: only its custodian lifts the seal (signed, from Cantabile). func (c *Core) Unpair(id, who string) error { - c.mu.Lock() - d := c.device(id) - if d == nil || !d.Paired { - c.mu.Unlock() - return fmt.Errorf("no paired device %s", id) + ski, err := func() (string, error) { + c.mu.Lock() + defer c.mu.Unlock() + d := c.device(id) + if d == nil || !d.Paired { + return "", fmt.Errorf("no paired device %s", id) + } + if level, cust := c.Level(d, "*"); level == LevelSealed { + c.audit("refused unpairing %s by %s: sealed (custodian %s)", d.Name, who, cust) + return "", fmt.Errorf("%w: %s is sealed by its custodian (%s)", ErrRefused, d.Name, cust) + } + c.forget(d) + d.Paired, d.State = false, "discovered" + delete(c.store.Devices, d.SKI) + c.save() + c.audit("unpaired %s (SKI %s) by %s", d.Name, d.SKI, who) + c.nominalChanged() + return d.SKI, nil + }() + if err != nil { + return err } - if level, cust := c.Level(d, "*"); level == LevelSealed { - c.audit("refused unpairing %s by %s: sealed (custodian %s)", d.Name, who, cust) - c.mu.Unlock() - return fmt.Errorf("%w: %s is sealed by its custodian (%s)", ErrRefused, d.Name, cust) - } - c.forget(d) - d.Paired, d.State = false, "discovered" - delete(c.store.Devices, d.SKI) - c.save() - c.audit("unpaired %s (SKI %s) by %s", d.Name, d.SKI, who) - c.nominalChanged() - ski := d.SKI - c.mu.Unlock() return c.backend.Unpair(ski) } @@ -503,6 +648,41 @@ func (c *Core) write(d *Device, key string, v float64) error { // IsControlBox: the paired control box's SKI (the only one whose LPC // writes the bridge approves). +// InternalError: a panic in the bridge's work for a device, contained +// (EEBUS.guard): an event on the page, with the device's name and the +// repeats since the last one. Called after a panic, which may have left the +// lock held: it waits at most a second for it, then the log line is all. +func (c *Core) InternalError(ski, what string, r any, repeats int) { + if !c.lockWithin(time.Second) { + log.Printf("internal error while %s for %s: %v (the core's lock is held: no event)", what, ski, r) + return + } + defer c.mu.Unlock() + name := ski + if d := c.devices[strings.ToLower(ski)]; d != nil && d.Name != "" { + name = d.Name + } + more := "" + if repeats > 0 { + more = fmt.Sprintf(", %d times more since the last report", repeats) + } + c.event("internal error while %s for %s: %v (contained%s; the bridge goes on)", what, name, r, more) +} + +// lockWithin: the core's lock, if it comes within wait. +func (c *Core) lockWithin(wait time.Duration) bool { + deadline := time.Now().Add(wait) + for { + if c.mu.TryLock() { + return true + } + if time.Now().After(deadline) { + return false + } + time.Sleep(10 * time.Millisecond) + } +} + func (c *Core) IsControlBox(ski string) bool { c.mu.Lock() defer c.mu.Unlock() @@ -714,6 +894,8 @@ func (c *Core) evaluateGrid() { func (c *Core) gridChanged(old Grid) { g := c.grid + // a new limit, or the end of one: the limits written again start over + clear(c.resends) switch g.State { case "limited": c.audit("grid operator's limit %.0f W from %s (order %s, until %s)", g.LimitW, g.Device, g.OrderID, untilText(g.Until)) @@ -1009,6 +1191,7 @@ func (c *Core) freeID(want string) string { } func (c *Core) save() { + c.noteControlBox() // every change of pairing or kind is saved if err := c.store.Save(); err != nil { log.Printf("saving devices: %v", err) } diff --git a/src/eebus-bridge/core_test.go b/src/eebus-bridge/core_test.go index a974ae1..51d1b07 100644 --- a/src/eebus-bridge/core_test.go +++ b/src/eebus-bridge/core_test.go @@ -7,6 +7,7 @@ import ( "encoding/base64" "encoding/json" "errors" + "fmt" "os" "strings" "sync" @@ -253,6 +254,310 @@ func TestGridOrderLimitedPassedOnAndSigned(t *testing.T) { } } +// A limit passed on but lost (written to a connection SHIP replaced): the +// device's next report shows another limit, and it gets the grid limit again. +func TestLostLimitPassedOnAgain(t *testing.T) { + h := newHarness(t, Options{PassOn: true}) + _, hp, _ := h.home() + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4200.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + if w := h.be.take(); !contains(w, hp.ID+" limit 4200 on") { + t.Fatalf("passed on: %v", w) + } + if got := h.core.PassedOnSKIs(); len(got) != 1 || got[0] != "hp01" { + t.Fatalf("read regularly: %v", got) + } + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + if w := h.be.take(); len(w) != 1 || w[0] != hp.ID+" limit 4200 on" { + t.Fatalf("passed on again: %v", w) + } + // still not taken (refused, or lost again): written again only after + // the back-off, doubling (5 s, 10 s, ...) + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + if w := h.be.take(); len(w) != 0 { + t.Fatalf("within the back-off: %v", w) + } + h.clock = h.clock.Add(PassOnRetryFirst) + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + if w := h.be.take(); len(w) != 1 { + t.Fatalf("after 5 s: %v", w) + } + h.clock = h.clock.Add(PassOnRetryFirst) + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + if w := h.be.take(); len(w) != 0 { + t.Fatalf("the second wait is 10 s: %v", w) + } + // a device that rounds holds it: nothing written + h.core.Update("hp01", nil, map[string]any{"limit": 4199.6, "limit_active": true}) + if w := h.be.take(); len(w) != 0 { + t.Fatalf("holds it (rounded): %v", w) + } + // and a later loss starts the back-off again from 5 s + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + if w := h.be.take(); len(w) != 1 { + t.Fatalf("lost again: %v", w) + } +} + +// A panic in our own work for the control box, on every poll: its link +// stays (never dropped or renewed: that would set it offline and move the +// §14a limit to its failsafe), the grid order stays as it is; the event is +// rate-limited. Another device's connection is renewed, with back-off. +func TestPanicKeepsTheControlBoxLink(t *testing.T) { + h := newHarness(t, Options{PassOn: true}) + _, _, _ = h.home() + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4200.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + if h.core.ControlBoxSKINow() != "cb01" { + t.Fatalf("the control box, lock-free: %q", h.core.ControlBoxSKINow()) + } + var mu sync.Mutex + dropped := []string{} + e := &EEBUS{core: h.core, drop: func(ski string) { mu.Lock(); dropped = append(dropped, ski); mu.Unlock() }} + for i := 0; i < 200; i++ { + e.guard("cb01", "reading", func() { panic(fmt.Sprintf("index %d out of range", i)) }) + } + time.Sleep(3 * time.Second) // afterPanic runs on its own goroutines + mu.Lock() + n := len(dropped) + mu.Unlock() + if n != 0 { + t.Fatalf("the control box was dropped %d times", n) + } + if o := h.order(); o["state"] != "limited" || o["limit_w"] != 4200.0 { + t.Fatalf("the grid order after 200 panics: %v", o) + } + h.core.mu.Lock() + events := strings.Join(h.core.events, "\n") + h.core.mu.Unlock() + // one site (the panic's value changes, its place doesn't): one event + if c := strings.Count(events, "internal error while reading"); c != 1 { + t.Fatalf("%d events:\n%s", c, events) + } + + // another device: the first panics only log and count; renewed once it + // panicked PanicRenewAfter times within the window + for i := 0; i < PanicRenewAfter; i++ { + e.guard("hp01", "reading", func() { panic("a bug of ours") }) + } + time.Sleep(time.Second) + mu.Lock() + n = len(dropped) + mu.Unlock() + if n != 1 { + t.Fatalf("the heat pump: dropped %d times", n) + } + + // unpaired: the lock-free record follows + if err := h.core.Unpair("cb01", "test"); err == nil || h.core.ControlBoxSKINow() != "cb01" { + // sealed: refused, stays the control box + t.Fatalf("sealed control box: %v %q", err, h.core.ControlBoxSKINow()) + } +} + +// A panic repeating on every poll: logged and shown once per +// PanicReportEvery with the repeats counted; a device's connection is +// renewed once it panicked PanicRenewAfter times within PanicRenewWindow, +// then with a doubling back-off; a device that alternates panics and normal +// runs isn't renewed more often; the back-off ends after a window without a +// panic. +func TestRepeatingPanicRateLimited(t *testing.T) { + var p panicLog + now := time.Unix(1_800_000_000, 0) + site := "core.go:1 < eebus.go:2" + reports := 0 + var renewedAt []int + for i := 0; i < 200; i++ { // 200 polls, 5 s apart: 1000 s + report, repeats, renew := p.record("hp01", "reading", site, now) + if report { + reports++ + if reports == 2 && repeats != 119 { + t.Fatalf("repeats counted: %d", repeats) + } + } + if renew { + renewedAt = append(renewedAt, i) + } + now = now.Add(5 * time.Second) + } + if reports != 2 { // at 0 s and 600 s + t.Fatalf("reports in 1000 s: %d", reports) + } + // the 5th panic (poll 4), then 1, 2, 4, 8 min later + if fmt.Sprint(renewedAt) != "[4 16 40 88 184]" { + t.Fatalf("renewed at polls %v", renewedAt) + } + + // alternating panics and normal runs (every 10 s): the same pace, the + // normal runs don't reset the back-off + var q panicLog + now = time.Unix(1_800_000_000, 0) + renewedAt = nil + for i := 0; i < 200; i++ { + if i%2 == 0 { + if _, _, renew := q.record("hp02", "reading", site, now); renew { + renewedAt = append(renewedAt, i) + } + } else { + q.ok("hp02", "reading", now) + } + now = now.Add(5 * time.Second) + } + if fmt.Sprint(renewedAt) != "[8 20 44 92 188]" { + t.Fatalf("alternating: renewed at polls %v", renewedAt) + } + + // a whole window without a panic: ended (and the first panics again + // only count) + now = now.Add(PanicRenewWindow) + q.ok("hp02", "reading", now) + if q.active.Load() != 0 { + t.Fatal("not ended after a quiet window") + } + for i := 0; i < PanicRenewAfter; i++ { + _, _, renew := q.record("hp02", "reading", site, now) + if renew != (i == PanicRenewAfter-1) { + t.Fatalf("after a quiet window, panic %d: renew %v", i, renew) + } + now = now.Add(5 * time.Second) + } + + // many sites and works: kept within their caps + for i := 0; i < 2*panicSitesMax; i++ { + p.record("hp01", "reading", fmt.Sprintf("site %d", i), now) + } + for i := 0; i < 2*panicWorksMax; i++ { + p.record(fmt.Sprintf("dev%d", i), "reading", "x", now) + } + if len(p.works) > panicWorksMax { + t.Fatalf("works: %d", len(p.works)) + } + for _, w := range p.works { + if len(w.sites) > panicSitesMax { + t.Fatalf("sites: %d", len(w.sites)) + } + } +} + +// The panic's site is its place in the code, not its value. +func TestPanicSiteWithoutTheValue(t *testing.T) { + site := func(i int) (s string) { + defer func() { _ = recover(); s = panicSiteOf(2) }() + panic(fmt.Sprintf("index %d", i)) + } + if a, b := site(1), site(2); a != b || !strings.Contains(a, "TestPanicSiteWithoutTheValue") { + t.Fatalf("sites: %q %q", a, b) + } +} + +// A 0 W target (full curtailment) backs off and starts over like any other: +// on a confirmed hold and a new grid limit or its end, not on a reconnect. +func TestPassOnBackOffWithZeroWatts(t *testing.T) { + h := newHarness(t, Options{PassOn: true}) + _, hp, _ := h.home() + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4200.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + h.be.take() + h.core.mu.Lock() + hp.Applied["limit"] = 0 + h.core.mu.Unlock() + lost := map[string]any{"limit": 9000.0, "limit_active": false} + write := func(what string, want int) { + t.Helper() + h.core.Update("hp01", nil, lost) + if w := h.be.take(); len(w) != want { + t.Fatalf("%s: %v", what, w) + } + } + write("first", 1) + write("backing off", 0) + // a confirmed hold of 0 W starts it over + h.core.Update("hp01", nil, map[string]any{"limit": 0.0, "limit_active": true}) + write("lost after a hold", 1) + write("backing off again", 0) + // a reconnect makes the next write due at once (§14a: back without + // the limit otherwise), keeping the count: the wait after it is longer + h.core.Connected("hp01", false) + h.core.Connected("hp01", true) + write("after a reconnect: written at once", 1) + write("then backing off", 0) + // a repeated report of the same state changes nothing + h.core.Connected("hp01", true) + write("a same-state report: still backing off", 0) + h.clock = h.clock.Add(PassOnRetryFirst << 1) + write("after the longer back-off", 1) + // a new grid limit starts it over (and is passed on) + h.clock = h.clock.Add(time.Second) + h.core.LimitWritten("cb01") + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4300.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + h.be.take() + h.core.mu.Lock() + hp.Applied["limit"] = 0 + h.core.mu.Unlock() + write("after a new grid limit", 1) +} + +// A connection reported twice (the library's SHIP ID and a setup after a +// twin's close): the second report changes nothing, no event. +func TestConnectedTwiceIsOnce(t *testing.T) { + h := newHarness(t, Options{PassOn: true}) + _, _, _ = h.home() + h.core.Connected("hp01", false) + h.core.mu.Lock() + n := len(h.core.events) + h.core.mu.Unlock() + h.core.Connected("hp01", true) + h.core.Connected("hp01", true) + h.core.Connected("cb01", true) + h.core.mu.Lock() + got := h.core.events[n:] + h.core.mu.Unlock() + if len(got) != 1 || !strings.Contains(got[0], "online") { + t.Fatalf("events: %v", got) + } +} + +// §14a: a device back after being away gets the grid limit on the next +// check, even with its back-off at the maximum. +func TestReconnectGetsTheLimitAtOnce(t *testing.T) { + h := newHarness(t, Options{PassOn: true}) + _, hp, _ := h.home() + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4200.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + h.be.take() + lost := map[string]any{"limit": 9000.0, "limit_active": false} + for i := 0; i < 12; i++ { // up to the 5 min maximum + h.core.Update("hp01", nil, lost) + h.be.take() + h.clock = h.clock.Add(DefaultPassOnRetryMax) + } + h.core.Update("hp01", nil, lost) + h.be.take() + h.core.Update("hp01", nil, lost) + if w := h.be.take(); len(w) != 0 { + t.Fatalf("at the maximum back-off: %v", w) + } + h.core.Connected("hp01", false) + h.core.Connected("hp01", true) + h.core.Update("hp01", nil, lost) + if w := h.be.take(); len(w) != 1 || w[0] != hp.ID+" limit 4200 on" { + t.Fatalf("after the reconnect: %v", w) + } +} + +// The back-off never grows past Options.PassOnRetryMax. +func TestPassOnBackOffCapped(t *testing.T) { + h := newHarness(t, Options{PassOn: true, PassOnRetryMax: 20 * time.Second}) + _, _, _ = h.home() + h.core.Update("cb01", nil, map[string]any{"grid_limit": 4200.0, "grid_limit_active": true, "_limit_duration": 900.0, "heartbeat": true}) + h.be.take() + writes := 0 + for i := 0; i < 40; i++ { // 40 × 5 s = 200 s: 5, 10, 20, 20, ... s apart + h.core.Update("hp01", nil, map[string]any{"limit": 9000.0, "limit_active": false}) + writes += len(h.be.take()) + h.clock = h.clock.Add(5 * time.Second) + } + if writes < 9 || writes > 12 { + t.Fatalf("writes in 200 s with a 20 s cap: %d", writes) + } +} + func TestSharesBetweenDevices(t *testing.T) { h := newHarness(t, Options{}) _, hp, wb := h.home() diff --git a/src/eebus-bridge/eebus.go b/src/eebus-bridge/eebus.go index 0b74f84..e66c9e0 100644 --- a/src/eebus-bridge/eebus.go +++ b/src/eebus-bridge/eebus.go @@ -12,11 +12,14 @@ import ( "log" "os" "path/filepath" + "slices" "strings" "sync" "time" + "unicode" eebusapi "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" "github.com/enbility/eebus-go/service" ucapi "github.com/enbility/eebus-go/usecases/api" "github.com/enbility/eebus-go/usecases/cem/evcc" @@ -56,9 +59,18 @@ type EEBUS struct { ifaces []string mdnsSel mdns.MdnsProviderSelection svc *service.Service // the energy manager toward the devices - grid *gridLink // the controllable system toward the control box, its own process (grid.go) + qmu sync.Mutex // the callback queue (async) + queue []func() + qrun bool + grid *gridLink // the controllable system toward the control box, its own process (grid.go) core *Core ski, gridSKI string + smu sync.Mutex // gridSKI (set when the grid identity's child reports it) + bmu sync.Mutex // bound + bound map[string]time.Time // binding requests sent again, by SKI and feature (bindDue) + bindFails map[string]bindFailure // binding requests not sent, by SKI and feature (bindFailed) + drop func(ski string) // drops a device's connection after a panic (nil: disconnect; tests) + panics panicLog // contained panics (panics.go) mu sync.Mutex pmu sync.Mutex pending map[string]bool @@ -90,7 +102,11 @@ func (e *EEBUS) Name() string { return "eebus" } func (e *EEBUS) LocalSKI() string { return e.ski } // GridSKI: the identity the grid operator's control box pairs with. -func (e *EEBUS) GridSKI() string { return e.gridSKI } +func (e *EEBUS) GridSKI() string { + e.smu.Lock() + defer e.smu.Unlock() + return e.gridSKI +} // LoadCertificate: the bridge's own (name: "eebus" or "eebus-grid"), made once. func LoadCertificate(dir, serial string) (tls.Certificate, string, error) { @@ -203,7 +219,7 @@ func (e *EEBUS) Start(c *Core) error { e.core.OnNominal = func(w float64) { gl.send(gridMsg{Cmd: "nominal", W: w}) } e.core.mu.Unlock() e.svc.Start() - log.Printf("EEBUS: devices SKI %s (port %d), grid SKI %s (port %d)", e.ski, e.port+1, e.gridSKI, e.port) + log.Printf("EEBUS: devices SKI %s (port %d), grid SKI %s (port %d)", e.ski, e.port+1, e.GridSKI(), e.port) go e.poll() return nil } @@ -224,18 +240,20 @@ type reader struct { } func (r reader) RemoteSKIConnected(_ eebusapi.ServiceInterface, ski string) { - r.e.core.Connected(ski, true) + r.e.async(ski, func() { r.e.core.Connected(ski, true) }) } func (r reader) RemoteSKIDisconnected(_ eebusapi.ServiceInterface, ski string) { - r.e.core.Connected(ski, false) + r.e.forgetBindings(ski) // (not the panics' back-off: a renewed connection must not restart it) + r.e.async(ski, func() { r.e.core.Connected(ski, false) }) } func (r reader) ServiceShipIDUpdate(string, string) {} func (r reader) VisibleRemoteServicesUpdated(_ eebusapi.ServiceInterface, entries []shipapi.RemoteService) { for _, s := range entries { - if strings.EqualFold(s.Ski, r.e.ski) || strings.EqualFold(s.Ski, r.e.gridSKI) { + if strings.EqualFold(s.Ski, r.e.ski) || strings.EqualFold(s.Ski, r.e.GridSKI()) { continue // the bridge's other identity } - r.e.core.Seen(s.Ski, s.Brand, s.Model, s.Type, s.Name) + s := s + r.e.async(s.Ski, func() { r.e.core.Seen(s.Ski, s.Brand, s.Model, s.Type, s.Name) }) } } func (r reader) ServicePairingDetailUpdate(ski string, detail *shipapi.ConnectionStateDetail) { @@ -246,12 +264,55 @@ func (r reader) ServicePairingDetailUpdate(ski string, detail *shipapi.Connectio r.e.onGrid[strings.ToLower(ski)] = true r.e.mu.Unlock() } - r.e.core.PairingRequest(ski) + r.e.async(ski, func() { r.e.core.PairingRequest(ski) }) case shipapi.ConnectionStateRemoteDeniedTrust: - r.e.core.Denied(ski) + r.e.async(ski, func() { r.e.core.Denied(ski) }) } } +// async: what the library reports reaches the core in order, but on the +// bridge's own goroutine. The core holds its lock while it writes to a +// device through the library (passOn); the library's callbacks run inside +// its own locks (ship-go's per-connection sync.Once on a close), so a +// callback that waited for the core's lock made a deadlock: the writer +// waited for the Once, the Once's holder for the core (the hang of CI run +// 709ea10b, 2026-11-13). Each runs guarded for its device (guard). +func (e *EEBUS) async(ski string, f func()) { + e.qmu.Lock() + e.queue = append(e.queue, func() { e.guard(ski, "a library callback", f) }) + start := !e.qrun + e.qrun = true + e.qmu.Unlock() + if !start { + return + } + go func() { + for { + e.qmu.Lock() + if len(e.queue) == 0 { + e.qrun = false + e.qmu.Unlock() + return + } + f := e.queue[0] + e.queue = e.queue[1:] + e.qmu.Unlock() + f() + } + }() +} + +// disconnect: drop a device's connection after a panic (itself guarded: a +// broken connection must not take the bridge down either). +func (e *EEBUS) disconnect(ski string) { + defer func() { + if r := recover(); r != nil { + log.Printf("EEBUS: dropping %s panicked: %v", ski, r) + } + }() + e.svc.DisconnectSKI(ski, "internal error") +} + func (e *EEBUS) Pair(ski, kind string) error { if e.onGridIdentity(ski, kind) { e.grid.send(gridMsg{Cmd: "pair", SKI: ski}) @@ -296,6 +357,14 @@ func entityOf(uc eebusapi.UseCaseInterface, ski string, live spineapi.DeviceRemo } found = r.Entity // the newest when SPINE knows none } + // only a dropped connection's entity is listed (the use case hasn't seen + // the live connection's yet): the live device's entity at the same + // address. Writes to the dropped one go nowhere, without an error. + if found != nil && live != nil && found.Device() != live && found.Address() != nil { + if e := live.Entity(found.Address().Entity); e != nil { + return e + } + } return found } @@ -308,15 +377,8 @@ func (e *EEBUS) WriteLimit(d *Device, watts float64, active bool) error { if ent == nil { return fmt.Errorf("%s offers no LPC", d.Name) } - _, err := e.eglpc.WriteConsumptionLimit(ent, ucapi.LoadLimit{Value: watts, IsActive: active}, func(r model.ResultDataType) { - if r.ErrorNumber != nil && *r.ErrorNumber != model.ErrorNumberTypeNoError { - desc := "" - if r.Description != nil { - desc = string(*r.Description) - } - log.Printf("%s refused the limit %.0f W: %s", d.Name, watts, desc) - } - }) + _, err := e.eglpc.WriteConsumptionLimit(ent, ucapi.LoadLimit{Value: watts, IsActive: active}, + e.onRefusal(d, fmt.Sprintf("the limit %.0f W", watts), ent)) return err } @@ -331,10 +393,199 @@ func (e *EEBUS) WriteCurrent(d *Device, amps float64) error { for _, p := range phases { limits = append(limits, ucapi.LoadLimitsPhase{Phase: p, IsActive: true, Value: amps}) } - _, err := e.opev.WriteLoadControlLimits(ent, limits, nil) + _, err := e.opev.WriteLoadControlLimits(ent, limits, e.onRefusal(d, fmt.Sprintf("the current %.0f A", amps), ent)) return err } +// onRefusal: the result callback of a write to a device's LoadControl +// server (an LPC limit, an OPEV current): a refusal is logged; one for a +// missing binding requests the binding again (bind), and the core's next +// check writes the value again (Core.checkPassedOn). +func (e *EEBUS) onRefusal(d *Device, what string, ent spineapi.EntityRemoteInterface) func(model.ResultDataType) { + return func(r model.ResultDataType) { + if r.ErrorNumber == nil || *r.ErrorNumber == model.ErrorNumberTypeNoError { + return + } + desc := "" + if r.Description != nil { + desc = string(*r.Description) + } + log.Printf("%s refused %s: %s", d.Name, what, desc) + if bindingMissing(r) { + go e.bind(d.SKI, ent) + } + } +} + +// bindingMissing: the refusal for a missing binding: its error number; +// spine-go's text ("write denied due to missing binding", sent as a general +// error); or another stack's general error that names the binding and is a +// refusal (any case: "Binding required", "not bound", "write refused: no +// binding"), not just any text with "binding" in it. +func bindingMissing(r model.ResultDataType) bool { + if *r.ErrorNumber == model.ErrorNumberTypeBindingIsNecessaryForThisCommand { + return true + } + if r.Description == nil { + return false + } + desc := strings.ToLower(string(*r.Description)) + if strings.Contains(desc, "denied due to missing binding") { + return true + } + if *r.ErrorNumber != model.ErrorNumberTypeGeneralError { + return false + } + // whole words only: "out of bounds" is a value's refusal, not a binding's + words := strings.FieldsFunc(desc, func(r rune) bool { return !unicode.IsLetter(r) }) + has := func(w string) bool { return slices.Contains(words, w) } + phrase := func(a, b string) bool { + for i := 0; i+1 < len(words); i++ { + if words[i] == a && words[i+1] == b { + return true + } + } + return false + } + if has("unbound") || phrase("not", "bound") || phrase("no", "binding") || phrase("without", "binding") { + return true + } + if !has("binding") && !has("bindings") { + return false + } + for _, w := range []string{"denied", "refused", "rejected", "missing", "required", "necessary", "needed"} { + if has(w) { + return true + } + } + return false +} + +// BindRetryMin: the shortest time between two binding requests to the same +// feature of a device (a device that refuses each write would otherwise get +// one per refused write). +const BindRetryMin = 30 * time.Second + +// bind: request the binding to the device's LoadControl server again, at +// most once per BindRetryMin per device and feature. The bridge's own +// record says it is bound (eebus-go binds once per entity), but the device +// lost the binding: it was made on a connection that SHIP replaced, or the +// device removed it with the dropped side of a double connection. The +// device then refuses every write ("write denied due to missing binding") +// until a new binding request. +func (e *EEBUS) bind(ski string, ent spineapi.EntityRemoteInterface) { + e.guard(ski, "binding", func() { + path := entityPath(ent) + // the slot is held while the request is made (no second at once), + // and kept only if it was sent + if !e.bindDue(ski, path, time.Now()) { + return + } + lc, err := client.NewLoadControl(e.svc.LocalDevice().EntityForType(model.EntityTypeTypeCEM), ent) + if err == nil { + _, err = lc.Bind() + } + if err != nil { + e.bindFailed(ski, path, time.Now(), err) + return + } + e.bindSent(ski, path) + log.Printf("EEBUS: %s lost its binding: requested again", ski) + }) +} + +// entityPath: the entity's address within its device ("1.2"), the same for +// the entity of a connection and of its successor (not the pointer). +func entityPath(ent spineapi.EntityRemoteInterface) string { + if ent == nil || ent.Address() == nil { + return "" + } + parts := []string{} + for _, a := range ent.Address().Entity { + parts = append(parts, fmt.Sprint(uint(a))) + } + return strings.Join(parts, ".") +} + +// forgetBindings: a device's binding requests (its connection ended: the +// next connection binds as new). +func (e *EEBUS) forgetBindings(ski string) { + e.bmu.Lock() + defer e.bmu.Unlock() + prefix := strings.ToLower(ski) + " " + for k := range e.bound { + if strings.HasPrefix(k, prefix) { + delete(e.bound, k) + } + } + for k := range e.bindFails { + if strings.HasPrefix(k, prefix) { + delete(e.bindFails, k) + } + } +} + +// BindFailMax: the longest wait after binding requests that couldn't be +// sent (BindRetryMin, doubling up to it). +const BindFailMax = 10 * time.Minute + +// bindFailure: requests to one device's feature that couldn't be sent. +type bindFailure struct { + n int + next time.Time +} + +// bindFailed: the request wasn't sent (the client couldn't be made, or the +// request not written): its slot freed, and a back-off for this device and +// feature (BindRetryMin, doubling up to BindFailMax) so a lasting failure +// isn't retried on every refused write; logged once per step. +func (e *EEBUS) bindFailed(ski, feature string, now time.Time, err error) { + e.bmu.Lock() + defer e.bmu.Unlock() + key := strings.ToLower(ski) + " " + feature + delete(e.bound, key) + if e.bindFails == nil { + e.bindFails = map[string]bindFailure{} + } + f := e.bindFails[key] + wait := BindRetryMin << f.n + if wait > BindFailMax || wait <= 0 { + wait = BindFailMax + } + f.n++ + f.next = now.Add(wait) + e.bindFails[key] = f + log.Printf("EEBUS: binding to %s (%s) not sent (%v): next try after %s", ski, feature, err, wait) +} + +// bindDue: whether a binding request to this device's feature may go out +// now (one in flight, sent less than BindRetryMin ago, or within a failure's +// back-off: not); true takes the slot (bindFailed frees it, bindSent keeps +// it and ends a failure's back-off). +func (e *EEBUS) bindDue(ski, feature string, now time.Time) bool { + e.bmu.Lock() + defer e.bmu.Unlock() + if e.bound == nil { + e.bound = map[string]time.Time{} + } + key := strings.ToLower(ski) + " " + feature + if last, ok := e.bound[key]; ok && now.Sub(last) < BindRetryMin { + return false + } + if f, ok := e.bindFails[key]; ok && now.Before(f.next) { + return false + } + e.bound[key] = now + return true +} + +// bindSent: the request went out: a failure's back-off ends. +func (e *EEBUS) bindSent(ski, feature string) { + e.bmu.Lock() + defer e.bmu.Unlock() + delete(e.bindFails, strings.ToLower(ski)+" "+feature) +} + // -- eebus-go's callbacks ---------------------------------------------------- func (e *EEBUS) onEvent(ski string, _ spineapi.DeviceRemoteInterface, _ spineapi.EntityRemoteInterface, _ eebusapi.EventType) { @@ -363,7 +614,7 @@ func (e *EEBUS) later(ski string) { e.pmu.Lock() delete(e.pending, ski) e.pmu.Unlock() - e.refresh(ski) + e.guard(ski, "reading", func() { e.refresh(ski) }) }() } @@ -372,7 +623,11 @@ func (e *EEBUS) later(ski string) { func (e *EEBUS) poll() { for range time.Tick(5 * time.Second) { if ski := e.core.ControlBoxSKI(); ski != "" { - e.refresh(ski) + e.guard(ski, "reading", func() { e.refresh(ski) }) + } + // the devices holding the grid limit: one that lost it gets it again (Core.checkPassedOn) + for _, ski := range e.core.PassedOnSKIs() { + e.guard(ski, "reading", func() { e.refresh(ski) }) } } } diff --git a/src/eebus-bridge/eebus_test.go b/src/eebus-bridge/eebus_test.go index 705fd66..e064a9e 100644 --- a/src/eebus-bridge/eebus_test.go +++ b/src/eebus-bridge/eebus_test.go @@ -5,6 +5,8 @@ package main import ( "errors" "os" + "os/exec" + "strings" "testing" "time" @@ -172,7 +174,7 @@ func TestReadUseCasesWithMocks(t *testing.T) { type remote struct { svc *service.Service connected chan string - trust string // the SKI whose pairing request it approves (its installer's confirmation) + trust map[string]bool // the SKIs whose pairing request it approves (its installer's confirmation) } func (r *remote) RemoteSKIConnected(_ eebusapi.ServiceInterface, ski string) { @@ -185,7 +187,7 @@ func (r *remote) RemoteSKIDisconnected(eebusapi.ServiceInterface, string) func (r *remote) VisibleRemoteServicesUpdated(eebusapi.ServiceInterface, []shipapi.RemoteService) {} func (r *remote) ServiceShipIDUpdate(string, string) {} func (r *remote) ServicePairingDetailUpdate(ski string, d *shipapi.ConnectionStateDetail) { - if d.State() == shipapi.ConnectionStateReceivedPairingRequest && ski == r.trust { + if d.State() == shipapi.ConnectionStateReceivedPairingRequest && r.trust[ski] { r.svc.RegisterRemoteSKI(ski) } } @@ -201,7 +203,7 @@ func newRemote(t *testing.T, dir string, port int, typ model.DeviceTypeType, ent t.Fatal(err) } conf.SetMdnsProviderSelection(mdns.MdnsProviderSelectionGoZeroConfOnly) - r := &remote{connected: make(chan string, 4)} + r := &remote{connected: make(chan string, 4), trust: map[string]bool{}} r.svc = service.NewService(conf, r) r.svc.SetLogging(ebLog{}) if err := r.svc.Setup(); err != nil { @@ -211,6 +213,26 @@ func newRemote(t *testing.T, dir string, port int, typ model.DeviceTypeType, ent return r, ski } +// tempDir: like t.TempDir, but the removal waits for a service's last +// write (a goroutine still saving made "directory not empty" fail the test +// after its last assertion, 2026-11-13). +func tempDir(t *testing.T) string { + t.Helper() + dir, err := os.MkdirTemp("", "eebus") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + for i := 0; i < 50; i++ { + if os.RemoveAll(dir) == nil { + return + } + time.Sleep(100 * time.Millisecond) + } + }) + return dir +} + func waitFor(t *testing.T, what string, d time.Duration, ok func() bool) { t.Helper() end := time.Now().Add(d) @@ -223,11 +245,134 @@ func waitFor(t *testing.T, what string, d time.Duration, ok func() bool) { t.Fatalf("timed out waiting for %s", what) } +// A panic in the work for one device is logged and contained: the callback +// queue goes on with the next device's callback. +func TestPanicInACallbackIsContained(t *testing.T) { + e := &EEBUS{} + done := make(chan struct{}) + e.async("bad", func() { panic("a bug for one device") }) + e.async("good", func() { close(done) }) + select { + case <-done: + case <-time.After(5 * time.Second): + t.Fatal("the queue stopped after a panic") + } + e.guard("bad", "reading", func() { + var m map[string]int + m["x"] = 1 + }) +} + +// A refusal for a missing binding requests the binding again, once per +// device and feature within BindRetryMin; other refusals don't. +func TestBindingRequestedAgainOnceAndOnlyForItsRefusal(t *testing.T) { + desc := func(s string) *model.DescriptionType { d := model.DescriptionType(s); return &d } + general, binding, busy := model.ErrorNumberTypeGeneralError, model.ErrorNumberTypeBindingIsNecessaryForThisCommand, model.ErrorNumberTypeTimeout + for _, c := range []struct { + r model.ResultDataType + want bool + }{ + {model.ResultDataType{ErrorNumber: &general, Description: desc("write denied due to missing binding")}, true}, + {model.ResultDataType{ErrorNumber: &binding}, true}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("binding table full")}, false}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("value out of range")}, false}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("Binding required")}, true}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("WRITE REFUSED: client not bound")}, true}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("no binding for this feature")}, true}, + {model.ResultDataType{ErrorNumber: &busy, Description: desc("binding required")}, false}, + // a value's refusal: "bounds" is not "bound" + {model.ResultDataType{ErrorNumber: &general, Description: desc("value out of bounds: a value within the bounds is required")}, false}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("upper bound exceeded, write refused")}, false}, + {model.ResultDataType{ErrorNumber: &general, Description: desc("client unbound")}, true}, + } { + if got := bindingMissing(c.r); got != c.want { + t.Fatalf("%v: %v", c.r.Description, got) + } + } + e := &EEBUS{} + now := time.Unix(1_800_000_000, 0) + if !e.bindDue("AA", "lc", now) || e.bindDue("aa", "lc", now.Add(time.Second)) { + t.Fatal("a second request within BindRetryMin") + } + if !e.bindDue("aa", "other", now) || !e.bindDue("bb", "lc", now) { + t.Fatal("other features and devices are separate") + } + if !e.bindDue("aa", "lc", now.Add(BindRetryMin)) { + t.Fatal("after BindRetryMin") + } + // a request that couldn't be sent: its slot freed, a back-off for the + // failure (BindRetryMin, doubling up to BindFailMax), ended by a sent one + at := now + for n, wait := range []time.Duration{BindRetryMin, 2 * BindRetryMin, 4 * BindRetryMin, 8 * BindRetryMin, 16 * BindRetryMin, BindFailMax, BindFailMax} { + if !e.bindDue("cc", "lc", at) { + t.Fatalf("failure %d: not due after its back-off", n) + } + e.bindFailed("cc", "lc", at, errNo) + if e.bindDue("cc", "lc", at.Add(wait-time.Second)) { + t.Fatalf("failure %d: retried within %s", n, wait) + } + at = at.Add(wait) + } + if !e.bindDue("cc", "lc", at) { + t.Fatal("cc") + } + e.bindSent("cc", "lc") + if e.bindDue("cc", "lc", at.Add(time.Second)) || !e.bindDue("cc", "lc", at.Add(BindRetryMin)) { + t.Fatal("after a sent request: the plain BindRetryMin") + } + // the device's connection ended: its next connection binds as new + e.forgetBindings("AA") + if !e.bindDue("aa", "lc", now.Add(BindRetryMin+time.Second)) || e.bindDue("bb", "lc", now.Add(time.Second)) { + t.Fatal("forgetting one device's requests") + } +} + +// TestSHIPControlBoxAndHeatPump runs the in-process SHIP test in a child +// process, once: three services share eebus-go's global event bus, which +// one process holds only once, and a hang ends at the child's 90 s timeout +// with its goroutine dump (not at the 5 min go test timeout). No retries: a +// crash or a failed assertion in the child fails this test, with the +// child's assertion lines and its panic's first stack lines, then its +// output's end. func TestSHIPControlBoxAndHeatPump(t *testing.T) { if os.Getenv("EEBUS_SHIP_TEST") != "1" { t.Skip("EEBUS_SHIP_TEST=1 runs SHIP over TCP with mDNS") } - dir := t.TempDir() + cmd := exec.Command(os.Args[0], "-test.run", "^TestSHIPInProcess$", "-test.count=1", "-test.timeout", "90s", "-test.v") + cmd.Env = append(os.Environ(), "EEBUS_SHIP_CHILD=1") + out, err := cmd.CombinedOutput() + if err == nil { + return + } + if f := os.Getenv("EEBUS_SHIP_OUT"); f != "" { + _ = os.WriteFile(f, out, 0o644) // the child's whole output (its goroutine dump on a hang) + } + // the assertion and panic lines first (a CI log keeps what matches), then the output's tail + var keep []string + stack := 0 + for _, l := range strings.Split(string(out), "\n") { + if strings.HasPrefix(l, "panic:") || strings.HasPrefix(l, "fatal error:") { + stack = 30 + } + if stack > 0 || strings.Contains(l, "_test.go:") || strings.HasPrefix(l, "--- FAIL") { + keep = append(keep, l) + } + if stack > 0 { + stack-- + } + } + tail := string(out) + if len(tail) > 6000 { + tail = tail[len(tail)-6000:] + } + t.Fatalf("the SHIP test failed (%v):\n%s\n--- its output's end:\n%s", err, strings.Join(keep, "\n"), tail) +} + +func TestSHIPInProcess(t *testing.T) { + if os.Getenv("EEBUS_SHIP_CHILD") != "1" { + t.Skip("run by TestSHIPControlBoxAndHeatPump") + } + dir := tempDir(t) store, _ := OpenStore(dir) signer, _ := LoadSigner(dir) bridge := NewEEBUS(dir, 47120, "test", nil, true) @@ -235,10 +380,9 @@ func TestSHIPControlBoxAndHeatPump(t *testing.T) { if err := bridge.Start(core); err != nil { t.Fatal(err) } - defer bridge.svc.Shutdown() - + t.Cleanup(bridge.Stop) // also the grid identity's process, which would go on writing into dir // the grid operator's control box (eg/lpc as the energy guard) - cbDir, hpDir := t.TempDir(), t.TempDir() + cbDir, hpDir := tempDir(t), tempDir(t) cb, cbSKI := newRemote(t, cbDir, 47131, model.DeviceTypeTypeElectricitySupplySystem, model.EntityTypeTypeGridGuard, "ControlBox") cbLPC := eglpc.NewLPC(cb.svc.LocalDevice().EntityForType(model.EntityTypeTypeGridGuard), nil) cb.svc.AddUseCase(cbLPC) @@ -261,12 +405,16 @@ func TestSHIPControlBoxAndHeatPump(t *testing.T) { // the bridge dials when the owner pairs; each device approves the // bridge's request (as its installer or app does), so one side connects - cb.trust, hp.trust = bridge.LocalSKI(), bridge.GridSKI() // the control box pairs with the grid identity - cb.svc.RegisterRemoteSKI(bridge.GridSKI()) - hp.svc.RegisterRemoteSKI(bridge.LocalSKI()) + // Only the bridge dials: the devices do not know its SKIs before its + // request, which each approves (registering the SKI only then). Both + // sides dialing at once is a double connection that ship-go closes in + // mid-handshake (ship-go v0.6.0's websocket then panicked: "send on + // closed channel"; fixed in third_party/ship-go). + cb.trust[bridge.LocalSKI()], cb.trust[bridge.GridSKI()] = true, true + hp.trust[bridge.LocalSKI()], hp.trust[bridge.GridSKI()] = true, true for _, r := range []*remote{cb, hp} { r.svc.Start() - defer r.svc.Shutdown() + t.Cleanup(r.svc.Shutdown) } // the owner pairs both on the page (after mDNS showed them) waitFor(t, "mDNS", 30*time.Second, func() bool { @@ -310,18 +458,29 @@ func TestSHIPControlBoxAndHeatPump(t *testing.T) { return target != nil }) // (once it has read the bridge's limit descriptions) - waitFor(t, "the control box's write", 30*time.Second, func() bool { + // The control box writes until the bridge has the order: a write sent + // before its binding went through is denied ("write denied due to + // missing binding", e.g. just after the grid identity restarted to + // offer LPC), and a real control box writes again too. + lastWrite := time.Time{} + waitFor(t, "the grid order", 60*time.Second, func() bool { + core.mu.Lock() + limited := core.grid.State == "limited" && core.grid.LimitW == 4200 + core.mu.Unlock() + if limited { + return true + } + if time.Since(lastWrite) < 3*time.Second { + return false + } target = entityOf(cbLPC, bridge.GridSKI(), cb.svc.LocalDevice().RemoteDeviceForSki(bridge.GridSKI())) if target == nil { return false } - _, err := cbLPC.WriteConsumptionLimit(target, ucapi.LoadLimit{Value: 4200, IsActive: true, Duration: 10 * time.Minute}, nil) - return err == nil - }) - waitFor(t, "the grid order", 30*time.Second, func() bool { - core.mu.Lock() - defer core.mu.Unlock() - return core.grid.State == "limited" && core.grid.LimitW == 4200 + if _, err := cbLPC.WriteConsumptionLimit(target, ucapi.LoadLimit{Value: 4200, IsActive: true, Duration: 10 * time.Minute}, nil); err == nil { + lastWrite = time.Now() + } + return false }) if !core.IsControlBox(cbSKI) || core.IsControlBox(hpSKI) { t.Fatal("the control box by its LPC") @@ -332,7 +491,7 @@ func TestSHIPControlBoxAndHeatPump(t *testing.T) { return err == nil && l.IsActive && l.Value == 4200 }) // the heat pump's limit stays protected: 0 W is refused - if _, err := core.Command(core.devices[hpSKI].ID, "limit", "0", "test"); !errors.Is(err, ErrRefused) { + if _, err := core.Command(hpID, "limit", "0", "test"); !errors.Is(err, ErrRefused) { t.Fatalf("0 W: %v", err) } } diff --git a/src/eebus-bridge/go.mod b/src/eebus-bridge/go.mod index 952f6fe..4f22a2d 100644 --- a/src/eebus-bridge/go.mod +++ b/src/eebus-bridge/go.mod @@ -33,3 +33,15 @@ require ( golang.org/x/tools v0.25.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +// enbility's modules as patched copies (their latest releases have races +// that crashed or stalled the bridge): ship-go v0.6.0 (a write to a +// connection closed in mid-handshake, mDNS shut down under a closing +// connection, a close deadlocked with SPINE's locks, a panic contained to +// its connection), spine-go v0.7.0 and eebus-go v0.7.0 (data races). +// third_party/*/PATCHES.md. Drop each when a release has its fixes. +replace ( + github.com/enbility/eebus-go => ./third_party/eebus-go + github.com/enbility/ship-go => ./third_party/ship-go + github.com/enbility/spine-go => ./third_party/spine-go +) diff --git a/src/eebus-bridge/go.sum b/src/eebus-bridge/go.sum index 31374bc..a4fddc4 100644 --- a/src/eebus-bridge/go.sum +++ b/src/eebus-bridge/go.sum @@ -4,14 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/eclipse/paho.mqtt.golang v1.5.0 h1:EH+bUVJNgttidWFkLLVKaQPGmkTUfQQqjOsyvMGvD6o= github.com/eclipse/paho.mqtt.golang v1.5.0/go.mod h1:du/2qNQVqJf/Sqs4MEL77kR8QTqANF7XU7Fk0aOTAgk= -github.com/enbility/eebus-go v0.7.0 h1:Uh3i+HMmTYecWA+BBlYYhNFuNtqzWWQarbv4z9n/aQI= -github.com/enbility/eebus-go v0.7.0/go.mod h1:ftoVhXGC00IEcfN4RZSb1PbBIglE9i3JYqwrjhXnYSA= github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a h1:foChWb8lhzqa6lWDRs6COYMdp649YlUirFP8GqoT0JQ= github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a/go.mod h1:H64mhYcAQUGUUnVqMdZQf93kPecH4M79xwH95Lddt3U= -github.com/enbility/ship-go v0.6.0 h1:1ft5NJJHqqGU3/ryYwQj8xBYJLFbf0q2cP9mjlYHlgw= -github.com/enbility/ship-go v0.6.0/go.mod h1:JJp8EQcJhUhTpZ2LSEU4rpdaM3E2n08tswWFWtmm/wU= -github.com/enbility/spine-go v0.7.0 h1:UZeghFgnM3VFU0ghc57Htt6gnxwP9jLppfU2GUMJGgY= -github.com/enbility/spine-go v0.7.0/go.mod h1:IF1sBTr7p3wXqlejeBJcJ8BYFlzzRaZcJsGw8XjgEgc= github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 h1:XOYvxKtT1oxT37w/5oEiRLuPbm9FuJPt3fiYhX0h8Po= github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6/go.mod h1:BszP9qFV14mPXgyIREbgIdQtWxbAj3OKqvK02HihMoM= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= @@ -38,8 +32,6 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a h1:DxppxFKRqJ8WD6oJ3+ZXKDY0iMONQDl5UTg2aTyHh8k= gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a/go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= diff --git a/src/eebus-bridge/grid.go b/src/eebus-bridge/grid.go index dc00f92..fd5ffe4 100644 --- a/src/eebus-bridge/grid.go +++ b/src/eebus-bridge/grid.go @@ -9,6 +9,7 @@ import ( "log" "os" "os/exec" + "runtime/debug" "strings" "sync" "time" @@ -64,6 +65,35 @@ type gridLink struct { // box reads a device's use cases when it connects: when this changes // the child starts again, so the control box sees it (docs/parameters.md U3). offered bool + cmd *exec.Cmd + stopped bool +} + +// stop: ends the child for good (no restart); the tests, and a clean exit. +func (g *gridLink) stop() { + g.mu.Lock() + g.stopped = true + cmd := g.cmd + g.mu.Unlock() + if cmd != nil && cmd.Process != nil { + _ = cmd.Process.Kill() + } +} + +func (g *gridLink) isStopped() bool { + g.mu.Lock() + defer g.mu.Unlock() + return g.stopped +} + +// Stop: the grid identity's process and the bridge's own service. +func (e *EEBUS) Stop() { + if e.grid != nil { + e.grid.stop() + } + if e.svc != nil { + e.svc.Shutdown() + } } // startGrid: the child, started again whenever it ends (its pairings sent @@ -76,7 +106,13 @@ func startGrid(e *EEBUS, paired []string) (*gridLink, error) { first := make(chan error, 1) go func() { for n := 0; ; n++ { + if g.isStopped() { + return + } err := g.run(first) + if g.isStopped() { + return + } log.Printf("EEBUS grid identity ended (%v): starting it again", err) time.Sleep(time.Duration(min(n+1, 30)) * time.Second) } @@ -114,6 +150,10 @@ func (g *gridLink) run(first chan error) error { } nominal, _ := g.e.core.NominalW() g.mu.Lock() + g.cmd = cmd + if g.stopped { + _ = cmd.Process.Kill() + } g.stdin, g.in = json.NewEncoder(in), in for ski := range g.paired { _ = g.stdin.Encode(gridMsg{Cmd: "pair", SKI: ski}) @@ -138,12 +178,19 @@ func (g *gridLink) run(first chan error) error { } func (g *gridLink) handle(m gridMsg, first chan error) { + // a panic handling one message is logged; the link and the bridge go + // on (the child resends the control box's values every 5 s) + defer func() { + if r := recover(); r != nil { + log.Printf("EEBUS grid identity: %s from %s panicked: %v\n%s", m.Ev, m.SKI, r, debug.Stack()) + } + }() c := g.e.core switch m.Ev { case "ski": - g.e.mu.Lock() + g.e.smu.Lock() g.e.gridSKI = m.SKI - g.e.mu.Unlock() + g.e.smu.Unlock() select { case first <- nil: default: diff --git a/src/eebus-bridge/main.go b/src/eebus-bridge/main.go index b6d1501..a118d07 100644 --- a/src/eebus-bridge/main.go +++ b/src/eebus-bridge/main.go @@ -43,14 +43,17 @@ type Config struct { ReadOnly bool NoControl bool // no consent to control (consent.go) PassOn bool - Interfaces []string - Node string - MQTTHost string - MQTTPort int - MQTTUser string - MQTTPass string - Serial string - HA bool + // the pass-on check (Options; 0: the defaults in core.go) + PassOnToleranceW float64 + PassOnRetryMax time.Duration + Interfaces []string + Node string + MQTTHost string + MQTTPort int + MQTTUser string + MQTTPass string + Serial string + HA bool } func env(k, d string) string { @@ -83,6 +86,10 @@ func configFromEnv() Config { if s := os.Getenv("INTERFACES"); s != "" { c.Interfaces = strings.Split(s, ",") } + c.PassOnToleranceW, _ = strconv.ParseFloat(os.Getenv("PASS_ON_TOLERANCE_W"), 64) + if s, err := strconv.Atoi(os.Getenv("PASS_ON_RETRY_MAX_S")); err == nil && s > 0 { + c.PassOnRetryMax = time.Duration(s) * time.Second + } return c } @@ -198,7 +205,8 @@ func main() { } else { backend = NewEEBUS(cfg.DataDir, cfg.Port, cfg.Serial, cfg.Interfaces, true) } - core := NewCore(Options{Node: cfg.Node, PassOn: cfg.PassOn, ReadOnly: cfg.ReadOnly, NoControl: cfg.NoControl}, store, backend, profiles, signer) + core := NewCore(Options{Node: cfg.Node, PassOn: cfg.PassOn, ReadOnly: cfg.ReadOnly, NoControl: cfg.NoControl, + PassOnToleranceW: cfg.PassOnToleranceW, PassOnRetryMax: cfg.PassOnRetryMax}, store, backend, profiles, signer) opts := paho.NewClientOptions().AddBroker(fmt.Sprintf("tcp://%s:%d", cfg.MQTTHost, cfg.MQTTPort)). SetClientID("cantabile-eebus-bridge").SetUsername(cfg.MQTTUser).SetPassword(cfg.MQTTPass). diff --git a/src/eebus-bridge/notices.sh b/src/eebus-bridge/notices.sh index 8794399..fb9206b 100755 --- a/src/eebus-bridge/notices.sh +++ b/src/eebus-bridge/notices.sh @@ -4,14 +4,17 @@ # and their licence files. Run where Go and the module cache are, in this # directory (e.g. in golang:1.26), after a dependency change. set -eu -mods=$(go list -deps -f '{{with .Module}}{{.Path}}@{{.Version}}{{end}}' . | sort -u | grep -v '^git.setti') +# a module replaced by a patched copy (go.mod: third_party/) is +# path@version@patched; its licence is read from that copy +mods=$(go list -deps -f '{{with .Module}}{{.Path}}@{{.Version}}{{if .Replace}}@patched{{end}}{{end}}' . | sort -u | grep -v '^git.setti') cache=$(go env GOMODCACHE) { echo "# Third-party notices: Cantabile EEBUS bridge"; echo -echo "Copyright © 2026 Setti Solutions S.R.L, www.setti.md. The Cantabile EEBUS bridge links the open-source Go modules below (go list -deps of the bridge; regenerate with notices.sh). Their licences permit use, modification and redistribution in binary form when these notices are included."; echo +echo "Copyright © 2026 Setti Solutions S.R.L, www.setti.md. The Cantabile EEBUS bridge links the open-source Go modules below (go list -deps of the bridge; regenerate with notices.sh). Their licences permit use, modification and redistribution in binary form when these notices are included. Modules marked patched are built from a modified copy in third_party/ (its PATCHES.md lists the changes, published under the module's own licence)."; echo echo "| Module | Version | Licence |"; echo "|---|---|---|" for m in $mods; do - p=${m%@*}; v=${m#*@} + p=${m%%@*}; v=${m#*@} + case $v in *@patched) v="${v%@patched}, patched (third_party/${p##*/})" ;; esac case $p in github.com/ahmetb/go-linq/v3) l="Apache-2.0" ;; github.com/eclipse/paho.mqtt.golang) l="EPL-2.0 or EDL-1.0 (BSD-3-Clause); used under EDL-1.0" ;; @@ -23,7 +26,9 @@ for m in $mods; do echo "| $p | $v | $l |" done; echo for m in $mods; do - d=$cache/$m; echo "## ${m%@*} ${m#*@}"; echo; echo '```'; cat "$d/LICENSE" + p=${m%%@*}; v=${m#*@}; d=$cache/$p@$v + case $v in *@patched) v=${v%@patched}; d=third_party/${p##*/} ;; esac + echo "## $p $v"; echo; echo '```'; cat "$d/LICENSE" [ -f "$d/edl-v10" ] && { echo; echo "--- EDL-1.0 (edl-v10) ---"; cat "$d/edl-v10"; } echo '```'; echo done diff --git a/src/eebus-bridge/panics.go b/src/eebus-bridge/panics.go new file mode 100644 index 0000000..0c8127e --- /dev/null +++ b/src/eebus-bridge/panics.go @@ -0,0 +1,250 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. All rights reserved. + +package main + +import ( + "fmt" + "log" + "runtime" + "runtime/debug" + "strings" + "sync" + "sync/atomic" + "time" +) + +// Contained panics in the bridge's work for a device (EEBUS.guard). A panic +// that repeats (the same site on every 5 s poll) is logged with its stack +// and shown as an event once per PanicReportEvery, with the count of +// repeats meanwhile. A device other than the grid operator's control box +// has its connection renewed (dropped; it connects again) once it panicked +// PanicRenewAfter times within PanicRenewWindow (the first panics only log +// and count), then again after PanicReconnectFirst, doubling up to +// PanicReconnectMax while it goes on; the back-off ends only after a whole +// PanicRenewWindow without a panic (a run that ends normally in between +// doesn't end it: a device alternating panics and normal runs isn't dropped +// every few seconds). The control box never: dropping it would set it +// offline and move the §14a limit to its failsafe (for up to 2 h) over a +// bug of ours; it gets the log, the event and the count only. The defaults +// are the bridge's own engineering values (docs/parameters.md E9c). +const ( + PanicReportEvery = 10 * time.Minute + PanicRenewAfter = 5 + PanicRenewWindow = 10 * time.Minute + PanicReconnectFirst = time.Minute + PanicReconnectMax = 30 * time.Minute + // the most panic sites and works kept (the oldest dropped beyond) + panicSitesMax = 64 + panicWorksMax = 256 +) + +// panicSite: one place in the code (the top frames of the stack, without +// the panic's value), for the rate limit. +type panicSite struct { + reported time.Time // last logged with its stack and shown as an event + repeats int // since then + total int +} + +// panicWork: the panics of one work for one device (ski, what). +type panicWork struct { + recent []time.Time // the panics within PanicRenewWindow (at most PanicRenewAfter) + reconnect time.Time // the next renewal allowed + renewals int + last time.Time // the last panic + active bool // counted in panicLog.active + sites map[string]*panicSite +} + +type panicLog struct { + mu sync.Mutex + active atomic.Int32 // works with a panic within PanicRenewWindow: ok's fast path when 0 + works map[string]*panicWork + reported int // panics reported in all (a counter for the page's log) +} + +func workKey(ski, what string) string { return strings.ToLower(ski) + "|" + what } + +// panicSiteOf: the panicking code's place: the first frames below the panic +// that aren't the runtime's or this file's, as function and line (no values, +// so a panic whose value changes (an index, a time) is one site). +func panicSiteOf(skip int) string { + pcs := make([]uintptr, 32) + n := runtime.Callers(skip, pcs) + frames := runtime.CallersFrames(pcs[:n]) + parts := []string{} + for { + f, more := frames.Next() + if !strings.HasPrefix(f.Function, "runtime.") && !strings.Contains(f.File, "/panics.go") { + parts = append(parts, fmt.Sprintf("%s:%d", f.Function, f.Line)) + if len(parts) == 3 { + break + } + } + if !more { + break + } + } + return strings.Join(parts, " < ") +} + +// record: the panic counted; report: log its stack and raise the event now +// (repeats: how many of this site were not reported since its last report); +// renew: renew the device's connection now (never done for the control +// box: afterPanic). +func (p *panicLog) record(ski, what, site string, now time.Time) (report bool, repeats int, renew bool) { + p.mu.Lock() + defer p.mu.Unlock() + if p.works == nil { + p.works = map[string]*panicWork{} + } + key := workKey(ski, what) + w := p.works[key] + if w == nil { + if len(p.works) >= panicWorksMax { + p.dropOldestWork() + } + w = &panicWork{sites: map[string]*panicSite{}} + p.works[key] = w + } + if !w.last.IsZero() && now.Sub(w.last) >= PanicRenewWindow { + // a whole window without a panic: a new start + w.recent, w.renewals, w.reconnect = nil, 0, time.Time{} + } + w.last = now + if !w.active { + w.active = true + p.active.Add(1) + } + kept := w.recent[:0] + for _, at := range w.recent { + if now.Sub(at) < PanicRenewWindow { + kept = append(kept, at) + } + } + w.recent = append(kept, now) + if len(w.recent) > PanicRenewAfter { + w.recent = w.recent[len(w.recent)-PanicRenewAfter:] + } + s := w.sites[site] + if s == nil { + if len(w.sites) >= panicSitesMax { + dropOldestSite(w.sites) + } + s = &panicSite{} + w.sites[site] = s + } + s.total++ + if s.reported.IsZero() || now.Sub(s.reported) >= PanicReportEvery { + report, repeats = true, s.repeats + s.reported, s.repeats = now, 0 + p.reported++ + } else { + s.repeats++ + } + if len(w.recent) >= PanicRenewAfter && !now.Before(w.reconnect) { + renew = true + wait := PanicReconnectFirst << w.renewals + if wait > PanicReconnectMax || wait <= 0 { + wait = PanicReconnectMax + } + w.renewals++ + w.reconnect = now.Add(wait) + } + return report, repeats, renew +} + +// ok: the work for this device ended normally. Its renewal back-off ends +// only after a whole PanicRenewWindow without a panic. O(1), and without +// the lock when no work had a panic within the window. +func (p *panicLog) ok(ski, what string, now time.Time) { + if p.active.Load() == 0 { + return + } + p.mu.Lock() + defer p.mu.Unlock() + if w := p.works[workKey(ski, what)]; w != nil && w.active && now.Sub(w.last) >= PanicRenewWindow { + w.recent, w.renewals, w.reconnect, w.active = nil, 0, time.Time{}, false + p.active.Add(-1) + } +} + +func (p *panicLog) dropOldestWork() { + oldest := "" + for k, w := range p.works { + if oldest == "" || w.last.Before(p.works[oldest].last) { + oldest = k + } + } + if w := p.works[oldest]; w != nil && w.active { + p.active.Add(-1) + } + delete(p.works, oldest) +} + +func dropOldestSite(sites map[string]*panicSite) { + oldest := "" + for k, s := range sites { + if oldest == "" || s.reported.Before(sites[oldest].reported) { + oldest = k + } + } + delete(sites, oldest) +} + +// guard: a panic in the work for one device (the bridge's or the library's +// under it) is contained (panicLog, afterPanic). (Panics on a connection's +// own goroutines end that connection in ship-go's websocket, +// third_party/ship-go.) +func (e *EEBUS) guard(ski, what string, f func()) { + defer func() { + r := recover() + if r == nil { + e.panics.ok(ski, what, time.Now()) + return + } + // skip runtime.Callers, panicSiteOf and this deferred function + site := panicSiteOf(3) + report, repeats, renew := e.panics.record(ski, what, site, time.Now()) + if report { + log.Printf("EEBUS: %s for %s panicked at %s (%d more since the last report): %v\n%s", + what, ski, site, repeats, r, debug.Stack()) + } + go e.afterPanic(ski, what, r, report, repeats, renew) + }() + f() +} + +// afterPanic: on its own goroutine, and never waiting for the core's lock +// for long (the panic may have left it held): the event when reported; the +// device's connection dropped, or renewed after repeats; the control box's +// never (it keeps its link: only the log, the event and the count). +func (e *EEBUS) afterPanic(ski, what string, r any, report bool, repeats int, renew bool) { + defer func() { + if r := recover(); r != nil { + log.Printf("EEBUS: after a panic for %s: %v", ski, r) + } + }() + if report && e.core != nil { + e.core.InternalError(ski, what, r, repeats) + } + if ski == "" || !renew || e.isControlBox(ski) { + return + } + log.Printf("EEBUS: %s for %s panicked: renewing its connection", what, ski) + if e.drop != nil { + e.drop(ski) + } else if e.svc != nil { + e.disconnect(ski) + } +} + +// isControlBox: whether ski is the paired control box, lock-free (the +// core's record of it, kept where pairings and kinds change). +func (e *EEBUS) isControlBox(ski string) bool { + if e.core == nil { + return false + } + cb := e.core.ControlBoxSKINow() + return cb != "" && strings.EqualFold(cb, ski) +} diff --git a/src/eebus-bridge/third_party/eebus-go/LICENSE b/src/eebus-bridge/third_party/eebus-go/LICENSE new file mode 100644 index 0000000..34e447e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/LICENSE @@ -0,0 +1,22 @@ +MIT license + +Copyright (c) 2022 Andreas Linde & Timo Vogel +Copyright (c) 2023-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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/eebus-bridge/third_party/eebus-go/PATCHES.md b/src/eebus-bridge/third_party/eebus-go/PATCHES.md new file mode 100644 index 0000000..8e227b7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/PATCHES.md @@ -0,0 +1,17 @@ +# eebus-go v0.7.0, patched + +This directory is [enbility/eebus-go](https://github.com/enbility/eebus-go) at +v0.7.0 (the module as published, without its tests, examples, example keys +and CI files), with the fixes below. The original is MIT-licensed (LICENSE, +unchanged). The modifications are Copyright © 2026 Setti Solutions S.R.L, +www.setti.md, and are published under the same MIT licence. The EEBUS bridge +uses this copy through a `replace` in its go.mod; drop it when an eebus-go +release has these fixes (v0.7.0 is the latest release as of 2026-11-13). + +| File | Change | +|---|---| +| `usecases/cs/lpc/{usecase,events,public}.go`, `usecases/cs/lpp/…` (the same code) | `heartbeatDiag` and `heartbeatKeoWorkaround` under a lock. SPINE delivers events to the use cases on their own goroutines (`go HandleEvent`), so two devices connecting at once wrote them concurrently (`deviceConnected`), and `IsHeartbeatWithinDuration` read them meanwhile: data races (go test -race). | + +Tests: `usecases/cs/lpc/heartbeat_race_test.go`, `usecases/cs/lpp/heartbeat_race_test.go` +(`go test -race ./usecases/cs/lpc ./usecases/cs/lpp`; `../go.work` builds them +against the patched ship-go and spine-go). diff --git a/src/eebus-bridge/third_party/eebus-go/api/api.go b/src/eebus-bridge/third_party/eebus-go/api/api.go new file mode 100644 index 0000000..c4ba94c --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/api.go @@ -0,0 +1,108 @@ +package api + +import ( + "github.com/enbility/ship-go/logging" + + shipapi "github.com/enbility/ship-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +//go:generate mockery + +/* Service */ + +// central service interface +// +// implemented by service, used by the eebus service implementation +type ServiceInterface interface { + // setup the service + Setup() error + + // start the service + Start() + + // shutdown the service + Shutdown() + + // add a use case to the service + AddUseCase(useCase UseCaseInterface) + + // set logging interface + SetLogging(logger logging.LoggingInterface) + + // return the configuration + Configuration() *Configuration + + // return the local service details + LocalService() *shipapi.ServiceDetails + + // return the local device + LocalDevice() spineapi.DeviceLocalInterface + + // Passthough functions to HubInterface + + // Provide the current pairing state for a SKI + PairingDetailForSki(ski string) *shipapi.ConnectionStateDetail + + // Defines wether incoming pairing requests should be automatically accepted or not + // + // Default: false + SetAutoAccept(value bool) + + // Returns if the service has auto accept enabled or not + IsAutoAcceptEnabled() bool + + // Returns the Service detail of a remote SKI + RemoteServiceForSKI(ski string) *shipapi.ServiceDetails + + // Sets the SKI as being paired + RegisterRemoteSKI(ski string) + + // Sets the SKI as not being paired + UnregisterRemoteSKI(ski string) + + // Disconnect from a connected remote SKI + DisconnectSKI(ski string, reason string) + + // Cancels the pairing process for a SKI + // + // This should be called while the service is running and the end + // user wants to cancel/disallow an incoming pairing request + CancelPairingWithSKI(ski string) + + // Define wether the user is able to react to an incoming pairing request + // + // Call this with `true` e.g. if the user is currently using a web interface + // where an incoming request can be accepted or denied + // + // Default is set to false, meaning every incoming pairing request will be + // automatically denied + UserIsAbleToApproveOrCancelPairingRequests(allow bool) +} + +// interface for receiving data for specific events from Service +// +// some are passthrough readers, because service needs to coordinate +// everything with SPINE +// +// implemented by the eebus service implementation, used by service +type ServiceReaderInterface interface { + // report a connection to a SKI + RemoteSKIConnected(service ServiceInterface, ski string) + + // report a disconnection to a SKI + RemoteSKIDisconnected(service ServiceInterface, ski string) + + // report all currently visible EEBUS services + VisibleRemoteServicesUpdated(service ServiceInterface, entries []shipapi.RemoteService) + + // Provides the SHIP ID the remote service reported during the handshake process + // This needs to be persisted and passed on for future remote service connections + // when using `PairRemoteService` + ServiceShipIDUpdate(ski string, shipdID string) + + // Provides the current pairing state for the remote service + // This is called whenever the state changes and can be used to + // provide user information for the pairing/connection process + ServicePairingDetailUpdate(ski string, detail *shipapi.ConnectionStateDetail) +} diff --git a/src/eebus-bridge/third_party/eebus-go/api/configuration.go b/src/eebus-bridge/third_party/eebus-go/api/configuration.go new file mode 100644 index 0000000..b3b5bc4 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/configuration.go @@ -0,0 +1,241 @@ +package api + +import ( + "crypto/tls" + "fmt" + "time" + + "github.com/enbility/ship-go/mdns" + "github.com/enbility/spine-go/model" +) + +const defaultPort int = 4711 + +// defines requires meta information about this service +type Configuration struct { + // The vendors IANA PEN, optional but highly recommended. + // If not set, brand will be used instead + // Used for the Device Address: SPINE - Protocol Specification 7.1.1.2 + vendorCode string + + // The deviceBrand of the device, required + // Used for the Device Address: SPINE - Protocol Specification 7.1.1.2 + // Used for mDNS txt record: SHIP - Specification 7.3.2 + deviceBrand string + + // The device model, required + // Used for the Device Address: SPINE - Protocol Specification 7.1.1.2 + // Used for mDNS txt record: SHIP - Specification 7.3.2 + deviceModel string + + // Serial number of the device, required + // Used for the Device Address: SPINE - Protocol Specification 7.1.1.2 + deviceSerialNumber string + + // An alternate mDNS service identifier + // Optional, if not set will be generated using "Brand-Model-SerialNumber" + // Used for mDNS service and SHIP identifier: SHIP - Specification 7.2 + alternateIdentifier string + + // An alternate mDNS service name + // Optional, if not set will be identical to alternateIdentifier or generated using "Brand-Model-SerialNumber" + alternateMdnsServiceName string + + // SPINE device type of the device model, required + // Used for SPINE device type + // Used for mDNS txt record: SHIP - Specification 7.3.2 + deviceType model.DeviceTypeType + + // SPINE device network feature set type, optional + // SPINE Protocol Specification 6 + featureSet model.NetworkManagementFeatureSetType + + // SPINE entity types for each entity that should be created + // Each entity has to have a different type! + entityTypes []model.EntityTypeType + + // Network interface to use for the service + // Optional, if not set all detected interfaces will be used + interfaces []string + + // The port address of the websocket server, required + port int + + // The certificate used for the service and its connections, required + certificate tls.Certificate + + // The timeout to be used for sending heartbeats and applied to all + // local entities created on setup the service + heartbeatTimeout time.Duration + + // Optional set which mDNS providers should be used + mdnsProviderSelection mdns.MdnsProviderSelection +} + +// Setup a Configuration with the required parameters +func NewConfiguration( + vendorCode, + deviceBrand, + deviceModel, + serialNumber string, + deviceType model.DeviceTypeType, + entityTypes []model.EntityTypeType, + port int, + certificate tls.Certificate, + heartbeatTimeout time.Duration, +) (*Configuration, error) { + configuration := &Configuration{ + certificate: certificate, + port: port, + heartbeatTimeout: heartbeatTimeout, + mdnsProviderSelection: mdns.MdnsProviderSelectionAll, + } + + if port == 0 { + configuration.port = defaultPort + } + + isRequired := "is required" + + if len(vendorCode) == 0 { + return nil, fmt.Errorf("vendorCode %s", isRequired) + } + configuration.vendorCode = vendorCode + + if len(deviceBrand) == 0 { + return nil, fmt.Errorf("brand %s", isRequired) + } + configuration.deviceBrand = deviceBrand + + if len(deviceModel) == 0 { + return nil, fmt.Errorf("model %s", isRequired) + } + configuration.deviceModel = deviceModel + + if len(serialNumber) == 0 { + return nil, fmt.Errorf("serialNumber %s", isRequired) + } + configuration.deviceSerialNumber = serialNumber + + if len(deviceType) == 0 { + return nil, fmt.Errorf("deviceType %s", isRequired) + } + configuration.deviceType = deviceType + + if len(entityTypes) == 0 { + return nil, fmt.Errorf("entityTypes %s", isRequired) + } + configuration.entityTypes = entityTypes + + // set default + configuration.featureSet = model.NetworkManagementFeatureSetTypeSmart + + return configuration, nil +} + +func (s *Configuration) VendorCode() string { + return s.vendorCode +} + +func (s *Configuration) DeviceBrand() string { + return s.deviceBrand +} + +func (s *Configuration) DeviceModel() string { + return s.deviceModel +} + +func (s *Configuration) DeviceSerialNumber() string { + return s.deviceSerialNumber +} + +// define an alternative mDNS and SHIP identifier +// usually this is only used when no deviceCode is available or identical to the brand +// if this is not set, generated identifier is used +func (s *Configuration) SetAlternateIdentifier(identifier string) { + s.alternateIdentifier = identifier +} + +// define an alternative mDNS service name +// this is normally not needed or used +func (s *Configuration) SetAlternateMdnsServiceName(name string) { + s.alternateMdnsServiceName = name +} + +func (s *Configuration) SetMdnsProviderSelection(providerSelection mdns.MdnsProviderSelection) { + s.mdnsProviderSelection = providerSelection +} + +func (s *Configuration) MdnsProviderSelection() mdns.MdnsProviderSelection { + return s.mdnsProviderSelection +} + +func (s *Configuration) DeviceType() model.DeviceTypeType { + return s.deviceType +} + +func (s *Configuration) FeatureSet() model.NetworkManagementFeatureSetType { + return s.featureSet +} + +func (s *Configuration) EntityTypes() []model.EntityTypeType { + return s.entityTypes +} + +func (s *Configuration) Interfaces() []string { + return s.interfaces +} + +// define which network interfaces should be considered instead of all existing +// expects a list of network interface names +func (s *Configuration) SetInterfaces(ifaces []string) { + s.interfaces = ifaces +} + +// generates a standard identifier used for mDNS ID and SHIP ID +// Brand-Model-SerialNumber +func (s *Configuration) generateIdentifier() string { + return fmt.Sprintf("%s-%s-%s", s.deviceBrand, s.deviceModel, s.deviceSerialNumber) +} + +// return the identifier to be used for mDNS and SHIP ID +// returns in this order: +// - alternateIdentifier +// - generateIdentifier +func (s *Configuration) Identifier() string { + // SHIP identifier is identical to the mDNS ID + if len(s.alternateIdentifier) > 0 { + return s.alternateIdentifier + } + + return s.generateIdentifier() +} + +// return the name to be used as the mDNS service name +// returns in this order: +// - alternateMdnsServiceName +// - generateIdentifier +func (s *Configuration) MdnsServiceName() string { + // SHIP identifier is identical to the mDNS ID + if len(s.alternateMdnsServiceName) > 0 { + return s.alternateMdnsServiceName + } + + return s.generateIdentifier() +} + +func (s *Configuration) Certificate() tls.Certificate { + return s.certificate +} + +func (s *Configuration) Port() int { + return s.port +} + +func (s *Configuration) SetCertificate(cert tls.Certificate) { + s.certificate = cert +} + +func (s *Configuration) HeartbeatTimeout() time.Duration { + return s.heartbeatTimeout +} diff --git a/src/eebus-bridge/third_party/eebus-go/api/errors.go b/src/eebus-bridge/third_party/eebus-go/api/errors.go new file mode 100644 index 0000000..96eeffb --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/errors.go @@ -0,0 +1,29 @@ +package api + +import "errors" + +// ErrMetadataNotAvailable indicates that the meta data information is not available +// e.g. decsriptions, constraints, ... +var ErrMetadataNotAvailable = errors.New("meta data not available") + +// ErrDataNotAvailable indicates that no data set is yet available +var ErrDataNotAvailable = errors.New("data not available") + +// ErrDataForMetadataKeyNotFound indicates that no data item is found for the given key +var ErrDataForMetadataKeyNotFound = errors.New("data for key not found") + +var ErrNotSupported = errors.New("not supported") + +var ErrEntityNotFound = errors.New("entity not found") + +var ErrUsecCaseNotSupported = errors.New("usecase is not supported") + +var ErrFunctionNotSupported = errors.New("function is not supported") + +var ErrOperationOnFunctionNotSupported = errors.New("operation is not supported on function") + +var ErrMissingData = errors.New("missing data") + +var ErrDeviceDisconnected = errors.New("device is disconnected") + +var ErrNoCompatibleEntity = errors.New("no compatible entity") diff --git a/src/eebus-bridge/third_party/eebus-go/api/features.go b/src/eebus-bridge/third_party/eebus-go/api/features.go new file mode 100644 index 0000000..506fdd5 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/features.go @@ -0,0 +1,244 @@ +package api + +import ( + "time" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Feature client interface were the local feature role is client and the remote feature role is server +type FeatureClientInterface interface { + // check if there is a subscription to the remote feature + HasSubscription() bool + + // subscribe to the feature of the entity + Subscribe() (*model.MsgCounterType, error) + + // check if there is a binding to the remote feature + HasBinding() bool + + // bind to the feature of the entity + Bind() (*model.MsgCounterType, error) + + // add a callback function to be invoked once a result or reply message for a msgCounter came in + AddResponseCallback(msgCounterReference model.MsgCounterType, function func(msg api.ResponseMessage)) error + + // add a callback function to be invoked once a result came in + AddResultCallback(function func(msg api.ResponseMessage)) +} + +// Feature server interface were the local feature role is a server +type FeatureServerInterface interface { +} + +// Common interface for DeviceClassificationClientInterface and DeviceClassificationServerInterface +type DeviceClassificationCommonInterface interface { + // get the current manufacturer details for a remote device entity + GetManufacturerDetails() (*model.DeviceClassificationManufacturerDataType, error) +} + +// Common interface for DeviceConfigurationClientInterface and DeviceConfigurationServerInterface +type DeviceConfigurationCommonInterface interface { + // check if spine.EventPayload Data contains data for a given filter + // + // data type will be checked for model.DeviceConfigurationKeyValueListDataType, + // filter type will be checked for model.DeviceConfigurationKeyValueDescriptionDataType + CheckEventPayloadDataForFilter(payloadData any, filter any) bool + + // Get the description for a given keyId + // + // Will return nil if no matching description was found + GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error) + + // Get the description for a given value combination + // + // Returns an error if no matching description was found + GetKeyValueDescriptionsForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error) + + // Get the key value data for a given keyId + // + // Will return nil if no matching data was found + GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error) + + // Get key value data for a given filter + // + // Will return nil if no matching data was found + GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error) +} + +// Common interface for DeviceDiagnosisClientInterface and DeviceDiagnosisServerInterface +type DeviceDiagnosisCommonInterface interface { + // get the current diagnosis state for an device entity + GetState() (*model.DeviceDiagnosisStateDataType, error) + + // check if the currently available heartbeat data is within a time duration + IsHeartbeatWithinDuration(duration time.Duration) bool +} + +// Common interface for ElectricalConnectionClientInterface and ElectricalConnectionServerInterface +type ElectricalConnectionCommonInterface interface { + // check if spine.EventPayload Data contains data for a given filter + // + // data type will be checked for model.ElectricalConnectionPermittedValueSetListDataType, + // filter type will be checked for model.ElectricalConnectionParameterDescriptionDataType + CheckEventPayloadDataForFilter(payloadData any, filter any) bool + + // Get the description for a given filter + // + // Returns an error if no matching description is found + GetDescriptionsForFilter( + filter model.ElectricalConnectionDescriptionDataType, + ) ([]model.ElectricalConnectionDescriptionDataType, error) + + // Get the description for a given parameter description + // + // Returns an error if no matching description is found + GetDescriptionForParameterDescriptionFilter( + filter model.ElectricalConnectionParameterDescriptionDataType) ( + *model.ElectricalConnectionDescriptionDataType, error) + + // Get the description for a given filter + // + // Returns an error if no matching description is found + GetParameterDescriptionsForFilter( + filter model.ElectricalConnectionParameterDescriptionDataType, + ) ([]model.ElectricalConnectionParameterDescriptionDataType, error) + + // return permitted values for all Electrical Connections + GetPermittedValueSetForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) ( + []model.ElectricalConnectionPermittedValueSetDataType, error) + + // returns minimum, maximum, default/pause limit values + GetPermittedValueDataForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) ( + float64, float64, float64, error) + + // Get the min, max, default current limits for each phase + GetPhaseCurrentLimits(measDesc []model.MeasurementDescriptionDataType) ( + resultMin []float64, resultMax []float64, resultDefault []float64, resultErr error) + + // Adjust a value to be within the permitted value range + AdjustValueToBeWithinPermittedValuesForParameterId( + value float64, parameterId model.ElectricalConnectionParameterIdType) float64 + + // Get the characteristics for a given filter + // + // Returns an error if no matching description is found + GetCharacteristicsForFilter( + filter model.ElectricalConnectionCharacteristicDataType, + ) ([]model.ElectricalConnectionCharacteristicDataType, error) +} + +// Common interface for LoadControlClientInterface and LoadControlServerInterface +type LoadControlCommonInterface interface { + // check if spine.EventPayload Data contains data for a given filter + // + // data type will be checked for model.LoadControlLimitListDataType, + // filter type will be checked for model.LoadControlLimitDescriptionDataType + CheckEventPayloadDataForFilter(payloadData any, filter any) bool + + // Get the description for a given limitId + // + // Will return nil if no matching description is found + GetLimitDescriptionForId(limitId model.LoadControlLimitIdType) ( + *model.LoadControlLimitDescriptionDataType, error) + + // Get the description for a given filter + // + // Returns an error if no matching description is found + GetLimitDescriptionsForFilter( + filter model.LoadControlLimitDescriptionDataType, + ) ([]model.LoadControlLimitDescriptionDataType, error) + + // Get the description for a given limitId + // + // Will return nil if no data is available + GetLimitDataForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error) + + // Get limit data for a given filter + // + // Will return nil if no data is available + GetLimitDataForFilter(filter model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error) +} + +// Common interface for MeasurementClientInterface and MeasurementServerInterface +type MeasurementCommonInterface interface { + // check if spine.EventPayload Data contains data for a given filter + // + // data type will be checked for model.MeasurementListDataType, + // filter type will be checked for model.MeasurementDescriptionDataType + CheckEventPayloadDataForFilter(payloadData any, filter any) bool + + // Get the description for a given id + // + // Returns an error if no matching description is found + GetDescriptionForId( + measurementId model.MeasurementIdType, + ) (*model.MeasurementDescriptionDataType, error) + + // Get the description for a given filter + // + // Returns an error if no matching description is found + GetDescriptionsForFilter( + filter model.MeasurementDescriptionDataType, + ) ([]model.MeasurementDescriptionDataType, error) + + // Get the constraints for a given filter + // + // Returns an error if no matching constraint is found + GetConstraintsForFilter( + filter model.MeasurementConstraintsDataType, + ) ([]model.MeasurementConstraintsDataType, error) + + // Get the measuement data for a given measurementId + // + // Will return nil if no data is available + GetDataForId(measurementId model.MeasurementIdType) (*model.MeasurementDataType, error) + + // Get measuement data for a given filter + // + // Will return nil if no data is available + GetDataForFilter(filter model.MeasurementDescriptionDataType) ( + []model.MeasurementDataType, error) +} + +// Common interface for IdentificationClientInterface and IdentificationServerInterface +type IdentificationCommonInterface interface { + // check if spine.EventPayload Data contains identification data + // + // data type will be checked for model.IdentificationListDataType + CheckEventPayloadDataForFilter(payloadData any) bool + + // return current values for Identification + GetDataForFilter(filter model.IdentificationDataType) ([]model.IdentificationDataType, error) +} + +// Common interface for IncentiveTableClientInterface and IncentiveTableServerInterface +type IncentiveTableCommonInterface interface { + // return list of descriptions for a given filter + GetDescriptionsForFilter(filter model.TariffDescriptionDataType) ([]model.IncentiveTableDescriptionType, error) + + // return list of constraints + GetConstraints() ([]model.IncentiveTableConstraintsType, error) + + // return current data for Time Series + GetData() ([]model.IncentiveTableType, error) +} + +// Common interface for SmartEnergyManagementPsClientInterface and SmartEnergyManagementPsServerInterface +type SmartEnergyManagementPsCommonInterface interface { + // return current data for FunctionTypeSmartEnergyManagementPsData + GetData() (*model.SmartEnergyManagementPsDataType, error) +} + +// Common interface for TimeSeriesClientInterface and TimeSeriesServerInterface +type TimeSeriesCommonInterface interface { + // return list of descriptions for a given filter + GetDescriptionsForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDescriptionDataType, error) + + // return current constraints for Time Series + GetConstraints() ([]model.TimeSeriesConstraintsDataType, error) + + // return current data for Time Series for a given filter + GetDataForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/api/featuresclient.go b/src/eebus-bridge/third_party/eebus-go/api/featuresclient.go new file mode 100644 index 0000000..ed0895e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/featuresclient.go @@ -0,0 +1,167 @@ +package api + +import "github.com/enbility/spine-go/model" + +type DeviceClassificationClientInterface interface { + // request DeviceClassificationManufacturerData from a remote device entity + RequestManufacturerDetails() (*model.MsgCounterType, error) +} + +type DeviceConfigurationClientInterface interface { + DeviceConfigurationCommonInterface + + // request DeviceConfigurationKeyValueDescriptionDataType from a remote entity + RequestKeyValueDescriptions( + selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, + elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request DeviceConfigurationKeyValueListData from a remote entity + RequestKeyValues( + selector *model.DeviceConfigurationKeyValueListDataSelectorsType, + elements *model.DeviceConfigurationKeyValueDataElementsType, + ) (*model.MsgCounterType, error) + + // write key values + // returns an error if this failed + WriteKeyValues(data []model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error) +} + +type DeviceDiagnosisClientInterface interface { + // request DeviceDiagnosisStateData from a remote entity + RequestState() (*model.MsgCounterType, error) + + // request FunctionTypeDeviceDiagnosisHeartbeatData from a remote device + RequestHeartbeat() (*model.MsgCounterType, error) +} + +type ElectricalConnectionClientInterface interface { + // request ElectricalConnectionDescriptionListDataType from a remote entity + RequestDescriptions( + selector *model.ElectricalConnectionDescriptionListDataSelectorsType, + elements *model.ElectricalConnectionDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity + RequestParameterDescriptions( + selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType, + elements *model.ElectricalConnectionParameterDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeElectricalConnectionPermittedValueSetListData from a remote entity + RequestPermittedValueSets( + selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType, + elements *model.ElectricalConnectionPermittedValueSetDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeElectricalConnectionCharacteristicListData from a remote entity + RequestCharacteristics( + selector *model.ElectricalConnectionCharacteristicListDataSelectorsType, + elements *model.ElectricalConnectionCharacteristicDataElementsType, + ) (*model.MsgCounterType, error) +} + +type IdentificationClientInterface interface { + // request FunctionTypeIdentificationListData from a remote entity + RequestValues() (*model.MsgCounterType, error) +} + +type IncentiveTableClientInterface interface { + // request FunctionTypeIncentiveTableDescriptionData from a remote entity + RequestDescriptions() (*model.MsgCounterType, error) + + // request FunctionTypeIncentiveTableConstraintsData from a remote entity + RequestConstraints() (*model.MsgCounterType, error) + + // request FunctionTypeIncentiveTableData from a remote entity + RequestValues() (*model.MsgCounterType, error) + + // write incentivetable descriptions + // returns an error if this failed + WriteDescriptions(data []model.IncentiveTableDescriptionType) (*model.MsgCounterType, error) + + // write incentivetable descriptions + // returns an error if this failed + WriteValues(data []model.IncentiveTableType) (*model.MsgCounterType, error) +} + +type LoadControlClientInterface interface { + // request FunctionTypeLoadControlLimitDescriptionListData from a remote device + RequestLimitDescriptions( + selector *model.LoadControlLimitDescriptionListDataSelectorsType, + elements *model.LoadControlLimitDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeLoadControlLimitConstraintsListData from a remote device + RequestLimitConstraints( + selector *model.LoadControlLimitConstraintsListDataSelectorsType, + elements *model.LoadControlLimitConstraintsDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeLoadControlLimitListData from a remote device + RequestLimitData( + selector *model.LoadControlLimitListDataSelectorsType, + elements *model.LoadControlLimitDataElementsType, + ) (*model.MsgCounterType, error) + + // write load control limits + // returns an error if this failed + WriteLimitData( + data []model.LoadControlLimitDataType, + deleteSelectors *model.LoadControlLimitListDataSelectorsType, + deleteElements *model.LoadControlLimitDataElementsType, + ) (*model.MsgCounterType, error) +} + +type MeasurementClientInterface interface { + // request FunctionTypeMeasurementDescriptionListData from a remote device + RequestDescriptions( + selector *model.MeasurementDescriptionListDataSelectorsType, + elements *model.MeasurementDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeMeasurementConstraintsListData from a remote entity + RequestConstraints( + selector *model.MeasurementConstraintsListDataSelectorsType, + elements *model.MeasurementConstraintsDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeMeasurementListData from a remote entity + RequestData( + selector *model.MeasurementListDataSelectorsType, + elements *model.MeasurementDataElementsType, + ) (*model.MsgCounterType, error) +} + +type SmartEnergyManagementPsClientInterface interface { + // request FunctionTypeSmartEnergyManagementPsData from a remote entity + RequestData() (*model.MsgCounterType, error) + + // write SmartEnergyManagementPsData + // returns an error if this failed + WriteData(data *model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error) +} + +type TimeSeriesClientInterface interface { + // request FunctionTypeTimeSeriesDescriptionListData from a remote entity + RequestDescriptions( + selector *model.TimeSeriesDescriptionListDataSelectorsType, + elements *model.TimeSeriesDescriptionDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeTimeSeriesConstraintsListData from a remote entity + RequestConstraints( + selector *model.TimeSeriesConstraintsListDataSelectorsType, + elements *model.TimeSeriesConstraintsDataElementsType, + ) (*model.MsgCounterType, error) + + // request FunctionTypeTimeSeriesListData from a remote device + RequestData( + selector *model.TimeSeriesListDataSelectorsType, + elements *model.TimeSeriesDataElementsType, + ) (*model.MsgCounterType, error) + + // write Time Series values + // returns an error if this failed + WriteData(data []model.TimeSeriesDataType) (*model.MsgCounterType, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/api/featuresserver.go b/src/eebus-bridge/third_party/eebus-go/api/featuresserver.go new file mode 100644 index 0000000..be02d89 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/featuresserver.go @@ -0,0 +1,154 @@ +package api + +import "github.com/enbility/spine-go/model" + +type DeviceClassificationServerInterface interface { +} + +type DeviceConfigurationServerInterface interface { + DeviceConfigurationCommonInterface + + // Add a new description data set and return the keyId + // + // will return nil if the data set could not be added + AddKeyValueDescription(description model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyIdType + + // Set or update data set for a keyId + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateKeyValueDataForKeyId( + data model.DeviceConfigurationKeyValueDataType, + deleteElements *model.DeviceConfigurationKeyValueDataElementsType, + keyId model.DeviceConfigurationKeyIdType, + ) error + + // Set or update data set for a filter + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateKeyValueDataForFilter( + data model.DeviceConfigurationKeyValueDataType, + deleteElements *model.DeviceConfigurationKeyValueDataElementsType, + filter model.DeviceConfigurationKeyValueDescriptionDataType, + ) error +} + +type DeviceDiagnosisServerInterface interface { + // set the local diagnosis state of the device + SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) +} + +type ElectricalConnectionServerInterface interface { + ElectricalConnectionCommonInterface + + // Add a new description data set + // + // NOTE: the electricalConnectionId has to be provided + // + // will return nil if the data set could not be added + AddDescription( + description model.ElectricalConnectionDescriptionDataType, + ) error + + // Add a new parameter description data sett and return the parameterId + // + // NOTE: the electricalConnectionId has to be provided, parameterId may not be provided + // + // will return nil if the data set could not be added + AddParameterDescription( + description model.ElectricalConnectionParameterDescriptionDataType, + ) *model.ElectricalConnectionParameterIdType + + // Add a new characteristic data set + // + // Note: ElectricalConnectionId and ParameterId must be set, CharacteristicId will be set automatically + // + // Will return an error if the data set could not be added + AddCharacteristic(data model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error) + + // Update data set for a filter + // Elements provided in deleteElements will be removed from the data set before the update + // + // // ElectricalConnectionId, ParameterId and CharacteristicId must be set + // + // Will return an error if the data set could not be updated + UpdateCharacteristic( + data model.ElectricalConnectionCharacteristicDataType, + deleteElements *model.ElectricalConnectionCharacteristicDataElementsType, + ) error +} + +type LoadControlServerInterface interface { + // Add a new description data set and return the limitId + // + // NOTE: the limitId may not be provided + // + // will return nil if the data set could not be added + AddLimitDescription( + description model.LoadControlLimitDescriptionDataType, + ) *model.LoadControlLimitIdType + + // Set or update data set for a limitId + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateLimitDataForId( + data model.LoadControlLimitDataType, + deleteElements *model.LoadControlLimitDataElementsType, + limitId model.LoadControlLimitIdType, + ) error + + // Set or update data set for a filter + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateLimitDataForFilter( + data model.LoadControlLimitDataType, + deleteElements *model.LoadControlLimitDataElementsType, + filter model.LoadControlLimitDescriptionDataType, + ) error +} + +type MeasurementServerInterface interface { + // Add a new parameter description data sett and return the measurementId + // + // NOTE: the measurementId may not be provided + // + // will return nil if the data set could not be added + AddDescription( + description model.MeasurementDescriptionDataType, + ) *model.MeasurementIdType + + // Set or update data set for a measurementId + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateDataForId( + data model.MeasurementDataType, + deleteElements *model.MeasurementDataElementsType, + measurementId model.MeasurementIdType, + ) error + + // Set or update data set for a filter + // Elements provided in deleteElements will be removed from the data set before the update + // + // Will return an error if the data set could not be updated + UpdateDataForFilter( + data model.MeasurementDataType, + deleteElements *model.MeasurementDataElementsType, + filter model.MeasurementDescriptionDataType, + ) error +} + +type IdentificationServerInterface interface { +} + +type IncentiveTableServerInterface interface { +} + +type SmartEnergyManagementPsServerInterface interface { +} + +type TimeSeriesServerInterface interface { +} diff --git a/src/eebus-bridge/third_party/eebus-go/api/types.go b/src/eebus-bridge/third_party/eebus-go/api/types.go new file mode 100644 index 0000000..5c4a212 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/types.go @@ -0,0 +1,4 @@ +package api + +// type for cem and usecase specfic event names +type EventType string diff --git a/src/eebus-bridge/third_party/eebus-go/api/usecases.go b/src/eebus-bridge/third_party/eebus-go/api/usecases.go new file mode 100644 index 0000000..c3af436 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/api/usecases.go @@ -0,0 +1,76 @@ +package api + +import ( + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// details about each use case scenario +type UseCaseScenario struct { + Scenario model.UseCaseScenarioSupportType // the scenario number + Mandatory bool // if this scenario is mandatory to be supported by the remote entity + ServerFeatures []model.FeatureTypeType // the server features required for this scenario on the remote entity +} + +// contains the available scenarios of a remote entity +type RemoteEntityScenarios struct { + Entity spineapi.EntityRemoteInterface + Scenarios []uint +} + +// Entity event callback +// +// Used by Use Case implementations +type EntityEventCallback func(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event EventType) + +type UseCaseBaseInterface interface { + // add the use case + AddUseCase() + + // remove the use case + RemoveUseCase() + + // update availability of the use case + // + // NOTE: only allowed to be used for client side implementations + // of a use case! Otherwise use `RemoveUseCase` and `AddUseCase`. + UpdateUseCaseAvailability(available bool) + + // check if the entity is compatible with the use case + IsCompatibleEntityType(entity spineapi.EntityRemoteInterface) bool + + // return the current list of compatible remote entities and their available scenarios of this use case + RemoteEntitiesScenarios() []RemoteEntityScenarios + + // return the current list of available scenarios of this use case for the remote entity + AvailableScenariosForEntity(entity spineapi.EntityRemoteInterface) []uint + + // check if the provided scenario are available at the remote entity + IsScenarioAvailableAtEntity( + entity spineapi.EntityRemoteInterface, + scenario uint, + ) bool +} + +// Implemented by each Use Case +type UseCaseInterface interface { + UseCaseBaseInterface + + // add the features + AddFeatures() +} + +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"` +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/deviceclassification.go b/src/eebus-bridge/third_party/eebus-go/features/client/deviceclassification.go new file mode 100644 index 0000000..9a4f0a4 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/deviceclassification.go @@ -0,0 +1,41 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceClassification struct { + *Feature + + *internal.DeviceClassificationCommon +} + +// Get a new DeviceClassification features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewDeviceClassification( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*DeviceClassification, error) { + feature, err := NewFeature(model.FeatureTypeTypeDeviceClassification, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + dc := &DeviceClassification{ + Feature: feature, + DeviceClassificationCommon: internal.NewRemoteDeviceClassification(feature.featureRemote), + } + + return dc, nil +} + +var _ api.DeviceClassificationClientInterface = (*DeviceClassification)(nil) + +// request DeviceClassificationManufacturerData from a remote device entity +func (d *DeviceClassification) RequestManufacturerDetails() (*model.MsgCounterType, error) { + return d.requestData(model.FunctionTypeDeviceClassificationManufacturerData, nil, nil) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/deviceconfiguration.go b/src/eebus-bridge/third_party/eebus-go/features/client/deviceconfiguration.go new file mode 100644 index 0000000..6749dcd --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/deviceconfiguration.go @@ -0,0 +1,90 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + internal "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type DeviceConfiguration struct { + *Feature + + *internal.DeviceConfigurationCommon +} + +// Get a new DeviceConfiguration features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewDeviceConfiguration( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*DeviceConfiguration, error) { + feature, err := NewFeature(model.FeatureTypeTypeDeviceConfiguration, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + dc := &DeviceConfiguration{ + Feature: feature, + DeviceConfigurationCommon: internal.NewRemoteDeviceConfiguration(feature.featureRemote), + } + + return dc, nil +} + +var _ api.DeviceConfigurationClientInterface = (*DeviceConfiguration)(nil) + +// request DeviceConfigurationKeyValueDescriptionDataType from a remote entity +func (d *DeviceConfiguration) RequestKeyValueDescriptions( + selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, + elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, selector, elements) +} + +// request DeviceConfigurationKeyValueListData from a remote entity +func (d *DeviceConfiguration) RequestKeyValues( + selector *model.DeviceConfigurationKeyValueListDataSelectorsType, + elements *model.DeviceConfigurationKeyValueDataElementsType, +) (*model.MsgCounterType, error) { + return d.requestData(model.FunctionTypeDeviceConfigurationKeyValueListData, selector, elements) +} + +// write key values +// returns an error if this failed +func (d *DeviceConfiguration) WriteKeyValues(data []model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error) { + if len(data) == 0 { + return nil, api.ErrMissingData + } + + filters := []model.FilterType{*model.NewFilterTypePartial()} + + // does the remote server feature not support partials? + operation := d.featureRemote.Operations()[model.FunctionTypeDeviceConfigurationKeyValueListData] + if operation == nil || !operation.WritePartial() { + filters = nil + // we need to send all data + updateData := &model.DeviceConfigurationKeyValueListDataType{ + DeviceConfigurationKeyValueData: data, + } + + if mergedData, err := d.featureRemote.UpdateData(false, model.FunctionTypeDeviceConfigurationKeyValueListData, updateData, nil, nil); err == nil { + data = mergedData.([]model.DeviceConfigurationKeyValueDataType) + } + } + + cmd := model.CmdType{ + DeviceConfigurationKeyValueListData: &model.DeviceConfigurationKeyValueListDataType{ + DeviceConfigurationKeyValueData: data, + }, + } + + if filters != nil { + cmd.Filter = filters + cmd.Function = util.Ptr(model.FunctionTypeDeviceConfigurationKeyValueListData) + } + + return d.remoteDevice.Sender().Write(d.featureLocal.Address(), d.featureRemote.Address(), cmd) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/devicediagnosis.go b/src/eebus-bridge/third_party/eebus-go/features/client/devicediagnosis.go new file mode 100644 index 0000000..f1b5008 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/devicediagnosis.go @@ -0,0 +1,46 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceDiagnosis struct { + *Feature + + *internal.DeviceDiagnosisCommon +} + +// Get a new DeviceDiagnosis features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewDeviceDiagnosis( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*DeviceDiagnosis, error) { + feature, err := NewFeature(model.FeatureTypeTypeDeviceDiagnosis, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + dd := &DeviceDiagnosis{ + Feature: feature, + DeviceDiagnosisCommon: internal.NewRemoteDeviceDiagnosis(feature.featureRemote), + } + + return dd, nil +} + +var _ api.DeviceDiagnosisClientInterface = (*DeviceDiagnosis)(nil) + +// request DeviceDiagnosisStateData from a remote entity +func (d *DeviceDiagnosis) RequestState() (*model.MsgCounterType, error) { + return d.requestData(model.FunctionTypeDeviceDiagnosisStateData, nil, nil) +} + +// request FunctionTypeDeviceDiagnosisHeartbeatData from a remote device +func (d *DeviceDiagnosis) RequestHeartbeat() (*model.MsgCounterType, error) { + return d.requestData(model.FunctionTypeDeviceDiagnosisHeartbeatData, nil, nil) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/electricalconnection.go b/src/eebus-bridge/third_party/eebus-go/features/client/electricalconnection.go new file mode 100644 index 0000000..b22a855 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/electricalconnection.go @@ -0,0 +1,68 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type ElectricalConnection struct { + *Feature + + *internal.ElectricalConnectionCommon +} + +// Get a new ElectricalConnection features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewElectricalConnection( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*ElectricalConnection, error) { + feature, err := NewFeature(model.FeatureTypeTypeElectricalConnection, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + e := &ElectricalConnection{ + Feature: feature, + ElectricalConnectionCommon: internal.NewRemoteElectricalConnection(feature.featureRemote), + } + + return e, nil +} + +var _ api.ElectricalConnectionClientInterface = (*ElectricalConnection)(nil) + +// request ElectricalConnectionDescriptionListDataType from a remote entity +func (e *ElectricalConnection) RequestDescriptions( + selector *model.ElectricalConnectionDescriptionListDataSelectorsType, + elements *model.ElectricalConnectionDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return e.requestData(model.FunctionTypeElectricalConnectionDescriptionListData, selector, elements) +} + +// request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity +func (e *ElectricalConnection) RequestParameterDescriptions( + selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType, + elements *model.ElectricalConnectionParameterDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return e.requestData(model.FunctionTypeElectricalConnectionParameterDescriptionListData, selector, elements) +} + +// request FunctionTypeElectricalConnectionPermittedValueSetListData from a remote entity +func (e *ElectricalConnection) RequestPermittedValueSets( + selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType, + elements *model.ElectricalConnectionPermittedValueSetDataElementsType, +) (*model.MsgCounterType, error) { + return e.requestData(model.FunctionTypeElectricalConnectionPermittedValueSetListData, selector, elements) +} + +// request FunctionTypeElectricalConnectionCharacteristicListData from a remote entity +func (e *ElectricalConnection) RequestCharacteristics( + selector *model.ElectricalConnectionCharacteristicListDataSelectorsType, + elements *model.ElectricalConnectionCharacteristicDataElementsType, +) (*model.MsgCounterType, error) { + return e.requestData(model.FunctionTypeElectricalConnectionCharacteristicListData, selector, elements) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/feature.go b/src/eebus-bridge/third_party/eebus-go/features/client/feature.go new file mode 100644 index 0000000..ea80246 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/feature.go @@ -0,0 +1,177 @@ +package client + +import ( + "errors" + "fmt" + + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type Feature struct { + featureType model.FeatureTypeType + + localRole model.RoleType + remoteRole model.RoleType + + spineLocalDevice spineapi.DeviceLocalInterface + localEntity spineapi.EntityLocalInterface + + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface + + remoteDevice spineapi.DeviceRemoteInterface + remoteEntity spineapi.EntityRemoteInterface +} + +var _ api.FeatureClientInterface = (*Feature)(nil) + +func NewFeature( + featureType model.FeatureTypeType, + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*Feature, error) { + if localEntity == nil { + return nil, errors.New("local entity is nil") + } + + if remoteEntity == nil { + return nil, errors.New("remote entity is nil") + } + + f := &Feature{ + featureType: featureType, + localRole: model.RoleTypeClient, + remoteRole: model.RoleTypeServer, + spineLocalDevice: localEntity.Device(), + localEntity: localEntity, + remoteDevice: remoteEntity.Device(), + remoteEntity: remoteEntity, + } + + var err error + f.featureLocal, f.featureRemote, err = f.getLocalAndRemoteFeatures() + + return f, err +} + +// check if there is a subscription to the remote feature +func (f *Feature) HasSubscription() bool { + subscription := f.featureLocal.HasSubscriptionToRemote(f.featureRemote.Address()) + return subscription +} + +// subscribe to the feature of the entity +func (f *Feature) Subscribe() (*model.MsgCounterType, error) { + msgCounter, fErr := f.featureLocal.SubscribeToRemote(f.featureRemote.Address()) + + if fErr != nil { + return nil, errors.New(fErr.String()) + } + + return msgCounter, nil +} + +// unssubscribe to the feature of the entity +func (f *Feature) Unsubscribe() (*model.MsgCounterType, error) { + msgCounter, fErr := f.featureLocal.RemoveRemoteSubscription(f.featureRemote.Address()) + + if fErr != nil { + return nil, errors.New(fErr.String()) + } + + return msgCounter, nil +} + +// check if there is a binding to the remote feature +func (f *Feature) HasBinding() bool { + binding := f.featureLocal.HasBindingToRemote(f.featureRemote.Address()) + return binding +} + +// bind to the feature of the entity +func (f *Feature) Bind() (*model.MsgCounterType, error) { + msgCounter, fErr := f.featureLocal.BindToRemote(f.featureRemote.Address()) + if fErr != nil { + return nil, errors.New(fErr.String()) + } + + return msgCounter, nil +} + +// remove a binding to the feature of the entity +func (f *Feature) Unbind() (*model.MsgCounterType, error) { + msgCounter, fErr := f.featureLocal.RemoveRemoteBinding(f.featureRemote.Address()) + + if fErr != nil { + return nil, errors.New(fErr.String()) + } + + return msgCounter, nil +} + +// add a callback function to be invoked once a result or reply message for a msgCounter came in +func (f *Feature) AddResponseCallback( + msgCounterReference model.MsgCounterType, + function func(msg spineapi.ResponseMessage)) error { + return f.featureLocal.AddResponseCallback(msgCounterReference, function) +} + +// add a callback function to be invoked once a result came in +func (f *Feature) AddResultCallback(function func(msg spineapi.ResponseMessage)) { + f.featureLocal.AddResultCallback(function) +} + +// helper method which adds checking if the feature is available and the operation is allowed +// selectors and elements are used if specific data should be requested by using +// model.FilterType DataSelectors (selectors) and/or DataElements (elements) +// both should use the proper data types for the used function +// +// Note: selectors and elements have to be pointers! +func (f *Feature) requestData(function model.FunctionType, selectors any, elements any) (*model.MsgCounterType, error) { + if f.featureRemote == nil { + return nil, api.ErrDataNotAvailable + } + + fTypes := f.featureRemote.Operations() + op, exists := fTypes[function] + if !exists || !op.Read() { + errWithFunction := fmt.Sprintf("%s %s", api.ErrOperationOnFunctionNotSupported.Error(), function) + return nil, errors.New(errWithFunction) + } + + // remove the selectors if the remote does not allow partial reads + // or partial writes, because in that case we need to have all data + if selectors != nil && (!op.ReadPartial() || !op.WritePartial()) { + selectors = nil + elements = nil + } + + msgCounter, fErr := f.featureLocal.RequestRemoteData(function, selectors, elements, f.featureRemote) + if fErr != nil { + return nil, errors.New(fErr.String()) + } + + return msgCounter, nil +} + +// internal helper method for getting local and remote feature for a given featureType and a given remoteDevice +func (f *Feature) getLocalAndRemoteFeatures() ( + spineapi.FeatureLocalInterface, + spineapi.FeatureRemoteInterface, + error) { + featureLocal := f.localEntity.FeatureOfTypeAndRole(f.featureType, f.localRole) + if featureLocal == nil { + featureLocal = f.localEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeGeneric, f.localRole) + } + if featureLocal == nil { + return nil, nil, errors.New("local feature not found") + } + + featureRemote := f.remoteEntity.Device().FeatureByEntityTypeAndRole(f.remoteEntity, f.featureType, f.remoteRole) + if featureRemote == nil { + return nil, nil, errors.New("remote feature not found") + } + + return featureLocal, featureRemote, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/identification.go b/src/eebus-bridge/third_party/eebus-go/features/client/identification.go new file mode 100644 index 0000000..ea93486 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/identification.go @@ -0,0 +1,38 @@ +package client + +import ( + internal "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type Identification struct { + *Feature + + *internal.IdentificationCommon +} + +// Get a new Identification features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewIdentification( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*Identification, error) { + feature, err := NewFeature(model.FeatureTypeTypeIdentification, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + i := &Identification{ + Feature: feature, + IdentificationCommon: internal.NewRemoteIdentification(feature.featureRemote), + } + + return i, nil +} + +// request FunctionTypeIdentificationListData from a remote entity +func (i *Identification) RequestValues() (*model.MsgCounterType, error) { + return i.requestData(model.FunctionTypeIdentificationListData, nil, nil) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/incentivetable.go b/src/eebus-bridge/third_party/eebus-go/features/client/incentivetable.go new file mode 100644 index 0000000..1300fab --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/incentivetable.go @@ -0,0 +1,83 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type IncentiveTable struct { + *Feature + + *internal.IncentiveTableCommon +} + +// Get a new IncentiveTable features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewIncentiveTable( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*IncentiveTable, error) { + feature, err := NewFeature(model.FeatureTypeTypeIncentiveTable, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + i := &IncentiveTable{ + Feature: feature, + IncentiveTableCommon: internal.NewRemoteIncentiveTable(feature.featureRemote), + } + + return i, nil +} + +var _ api.IncentiveTableClientInterface = (*IncentiveTable)(nil) + +// request FunctionTypeIncentiveTableDescriptionData from a remote entity +func (i *IncentiveTable) RequestDescriptions() (*model.MsgCounterType, error) { + return i.requestData(model.FunctionTypeIncentiveTableDescriptionData, nil, nil) +} + +// request FunctionTypeIncentiveTableConstraintsData from a remote entity +func (i *IncentiveTable) RequestConstraints() (*model.MsgCounterType, error) { + return i.requestData(model.FunctionTypeIncentiveTableConstraintsData, nil, nil) +} + +// request FunctionTypeIncentiveTableData from a remote entity +func (i *IncentiveTable) RequestValues() (*model.MsgCounterType, error) { + return i.requestData(model.FunctionTypeIncentiveTableData, nil, nil) +} + +// write incentivetable descriptions +// returns an error if this failed +func (i *IncentiveTable) WriteDescriptions(data []model.IncentiveTableDescriptionType) (*model.MsgCounterType, error) { + if len(data) == 0 { + return nil, api.ErrMissingData + } + + cmd := model.CmdType{ + IncentiveTableDescriptionData: &model.IncentiveTableDescriptionDataType{ + IncentiveTableDescription: data, + }, + } + + return i.remoteDevice.Sender().Write(i.featureLocal.Address(), i.featureRemote.Address(), cmd) +} + +// write incentivetable descriptions +// returns an error if this failed +func (i *IncentiveTable) WriteValues(data []model.IncentiveTableType) (*model.MsgCounterType, error) { + if len(data) == 0 { + return nil, api.ErrMissingData + } + + cmd := model.CmdType{ + IncentiveTableData: &model.IncentiveTableDataType{ + IncentiveTable: data, + }, + } + + return i.remoteDevice.Sender().Write(i.featureLocal.Address(), i.featureRemote.Address(), cmd) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/loadcontrol.go b/src/eebus-bridge/third_party/eebus-go/features/client/loadcontrol.go new file mode 100644 index 0000000..b8c7c42 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/loadcontrol.go @@ -0,0 +1,115 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type LoadControl struct { + *Feature + + *internal.LoadControlCommon +} + +// Get a new LoadControl features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewLoadControl( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*LoadControl, error) { + feature, err := NewFeature(model.FeatureTypeTypeLoadControl, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + lc := &LoadControl{ + Feature: feature, + LoadControlCommon: internal.NewRemoteLoadControl(feature.featureRemote), + } + + return lc, nil +} + +var _ api.LoadControlClientInterface = (*LoadControl)(nil) + +// request FunctionTypeLoadControlLimitDescriptionListData from a remote device +func (l *LoadControl) RequestLimitDescriptions( + selector *model.LoadControlLimitDescriptionListDataSelectorsType, + elements *model.LoadControlLimitDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return l.requestData(model.FunctionTypeLoadControlLimitDescriptionListData, selector, elements) +} + +// request FunctionTypeLoadControlLimitConstraintsListData from a remote device +func (l *LoadControl) RequestLimitConstraints( + selector *model.LoadControlLimitConstraintsListDataSelectorsType, + elements *model.LoadControlLimitConstraintsDataElementsType, +) (*model.MsgCounterType, error) { + return l.requestData(model.FunctionTypeLoadControlLimitConstraintsListData, selector, elements) +} + +// request FunctionTypeLoadControlLimitListData from a remote device +func (l *LoadControl) RequestLimitData( + selector *model.LoadControlLimitListDataSelectorsType, + elements *model.LoadControlLimitDataElementsType, +) (*model.MsgCounterType, error) { + return l.requestData(model.FunctionTypeLoadControlLimitListData, selector, elements) +} + +// write load control limits +// returns an error if this failed +func (l *LoadControl) WriteLimitData( + data []model.LoadControlLimitDataType, + deleteSelectors *model.LoadControlLimitListDataSelectorsType, + deleteElements *model.LoadControlLimitDataElementsType, +) (*model.MsgCounterType, error) { + if len(data) == 0 { + return nil, api.ErrMissingData + } + + var filters []model.FilterType + var delFilter *model.FilterType + partialFilter := model.NewFilterTypePartial() + if deleteElements != nil && deleteSelectors != nil { + delFilter = &model.FilterType{ + CmdControl: &model.CmdControlType{ + Delete: &model.ElementTagType{}, + }, + LoadControlLimitListDataSelectors: deleteSelectors, + LoadControlLimitDataElements: deleteElements, + } + filters = append(filters, *delFilter) + } + filters = append(filters, *partialFilter) + + // does the remote server feature not support partials? + operation := l.featureRemote.Operations()[model.FunctionTypeLoadControlLimitListData] + if operation == nil || !operation.WritePartial() { + filters = nil + // we need to send all data + updateData := &model.LoadControlLimitListDataType{ + LoadControlLimitData: data, + } + + if mergedData, err := l.featureRemote.UpdateData(false, model.FunctionTypeLoadControlLimitListData, updateData, partialFilter, delFilter); err == nil { + data = mergedData.([]model.LoadControlLimitDataType) + } + } + + cmd := model.CmdType{ + LoadControlLimitListData: &model.LoadControlLimitListDataType{ + LoadControlLimitData: data, + }, + } + + if filters != nil { + cmd.Filter = filters + cmd.Function = util.Ptr(model.FunctionTypeLoadControlLimitListData) + } + + return l.remoteDevice.Sender().Write(l.featureLocal.Address(), l.featureRemote.Address(), cmd) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/measurement.go b/src/eebus-bridge/third_party/eebus-go/features/client/measurement.go new file mode 100644 index 0000000..c566190 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/measurement.go @@ -0,0 +1,60 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type Measurement struct { + *Feature + + *internal.MeasurementCommon +} + +var _ api.MeasurementClientInterface = (*Measurement)(nil) + +// Get a new Measurement features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewMeasurement( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*Measurement, error) { + feature, err := NewFeature(model.FeatureTypeTypeMeasurement, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + m := &Measurement{ + Feature: feature, + MeasurementCommon: internal.NewRemoteMeasurement(feature.featureRemote), + } + + return m, nil +} + +// request FunctionTypeMeasurementDescriptionListData from a remote device +func (m *Measurement) RequestDescriptions( + selector *model.MeasurementDescriptionListDataSelectorsType, + elements *model.MeasurementDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return m.requestData(model.FunctionTypeMeasurementDescriptionListData, selector, elements) +} + +// request FunctionTypeMeasurementConstraintsListData from a remote entity +func (m *Measurement) RequestConstraints( + selector *model.MeasurementConstraintsListDataSelectorsType, + elements *model.MeasurementConstraintsDataElementsType, +) (*model.MsgCounterType, error) { + return m.requestData(model.FunctionTypeMeasurementConstraintsListData, selector, elements) +} + +// request FunctionTypeMeasurementListData from a remote entity +func (m *Measurement) RequestData( + selector *model.MeasurementListDataSelectorsType, + elements *model.MeasurementDataElementsType, +) (*model.MsgCounterType, error) { + return m.requestData(model.FunctionTypeMeasurementListData, selector, elements) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/smartenergymanagementps.go b/src/eebus-bridge/third_party/eebus-go/features/client/smartenergymanagementps.go new file mode 100644 index 0000000..ed39d4f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/smartenergymanagementps.go @@ -0,0 +1,56 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type SmartEnergyManagementPs struct { + *Feature + + *internal.SmartEnergyManagementPsCommon +} + +// Get a new Identification features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewSmartEnergyManagementPs( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*SmartEnergyManagementPs, error) { + feature, err := NewFeature(model.FeatureTypeTypeSmartEnergyManagementPs, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + i := &SmartEnergyManagementPs{ + Feature: feature, + SmartEnergyManagementPsCommon: internal.NewRemoteSmartEnergyManagementPs(feature.featureRemote), + } + + return i, nil +} + +// request FunctionTypeSmartEnergyManagementPsData from a remote entity +func (i *SmartEnergyManagementPs) RequestData() (*model.MsgCounterType, error) { + return i.requestData(model.FunctionTypeSmartEnergyManagementPsData, nil, nil) +} + +// write SmartEnergyManagementPsData +// returns an error if this failed +func (l *SmartEnergyManagementPs) WriteData(data *model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error) { + if data == nil { + return nil, api.ErrMissingData + } + + cmd := model.CmdType{ + Function: util.Ptr(model.FunctionTypeSmartEnergyManagementPsData), + Filter: []model.FilterType{*model.NewFilterTypePartial()}, + SmartEnergyManagementPsData: data, + } + + return l.remoteDevice.Sender().Write(l.featureLocal.Address(), l.featureRemote.Address(), cmd) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/client/timeseries.go b/src/eebus-bridge/third_party/eebus-go/features/client/timeseries.go new file mode 100644 index 0000000..4703ed7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/client/timeseries.go @@ -0,0 +1,76 @@ +package client + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type TimeSeries struct { + *Feature + + *internal.TimeSeriesCommon +} + +// Get a new TimeSeries features helper +// +// - The feature on the local entity has to be of role client +// - The feature on the remote entity has to be of role server +func NewTimeSeries( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface) (*TimeSeries, error) { + feature, err := NewFeature(model.FeatureTypeTypeTimeSeries, localEntity, remoteEntity) + if err != nil { + return nil, err + } + + t := &TimeSeries{ + Feature: feature, + TimeSeriesCommon: internal.NewRemoteTimeSeries(feature.featureRemote), + } + + return t, nil +} + +var _ api.TimeSeriesClientInterface = (*TimeSeries)(nil) + +// request FunctionTypeTimeSeriesDescriptionListData from a remote entity +func (t *TimeSeries) RequestDescriptions( + selector *model.TimeSeriesDescriptionListDataSelectorsType, + elements *model.TimeSeriesDescriptionDataElementsType, +) (*model.MsgCounterType, error) { + return t.requestData(model.FunctionTypeTimeSeriesDescriptionListData, selector, elements) +} + +// request FunctionTypeTimeSeriesConstraintsListData from a remote entity +func (t *TimeSeries) RequestConstraints( + selector *model.TimeSeriesConstraintsListDataSelectorsType, + elements *model.TimeSeriesConstraintsDataElementsType, +) (*model.MsgCounterType, error) { + return t.requestData(model.FunctionTypeTimeSeriesConstraintsListData, selector, elements) +} + +// request FunctionTypeTimeSeriesListData from a remote device +func (t *TimeSeries) RequestData( + selector *model.TimeSeriesListDataSelectorsType, + elements *model.TimeSeriesDataElementsType, +) (*model.MsgCounterType, error) { + return t.requestData(model.FunctionTypeTimeSeriesListData, selector, elements) +} + +// write Time Series values +// returns an error if this failed +func (t *TimeSeries) WriteData(data []model.TimeSeriesDataType) (*model.MsgCounterType, error) { + if len(data) == 0 { + return nil, api.ErrMissingData + } + + cmd := model.CmdType{ + TimeSeriesListData: &model.TimeSeriesListDataType{ + TimeSeriesData: data, + }, + } + + return t.remoteDevice.Sender().Write(t.featureLocal.Address(), t.featureRemote.Address(), cmd) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/deviceclassification.go b/src/eebus-bridge/third_party/eebus-go/features/internal/deviceclassification.go new file mode 100644 index 0000000..b37d8bc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/deviceclassification.go @@ -0,0 +1,37 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceClassificationCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalDeviceClassification(featureLocal spineapi.FeatureLocalInterface) *DeviceClassificationCommon { + return &DeviceClassificationCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteDeviceClassification(featureRemote spineapi.FeatureRemoteInterface) *DeviceClassificationCommon { + return &DeviceClassificationCommon{ + featureRemote: featureRemote, + } +} + +var _ api.DeviceClassificationCommonInterface = (*DeviceClassificationCommon)(nil) + +// get the current manufacturer details for a remote device entity +func (d *DeviceClassificationCommon) GetManufacturerDetails() (*model.DeviceClassificationManufacturerDataType, error) { + function := model.FunctionTypeDeviceClassificationManufacturerData + data, err := featureDataCopyOfType[model.DeviceClassificationManufacturerDataType](d.featureLocal, d.featureRemote, function) + if err != nil || data == nil { + return nil, api.ErrDataNotAvailable + } + + return data, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/deviceconfiguration.go b/src/eebus-bridge/third_party/eebus-go/features/internal/deviceconfiguration.go new file mode 100644 index 0000000..a8ea257 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/deviceconfiguration.go @@ -0,0 +1,130 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceConfigurationCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalDeviceConfiguration(featureLocal spineapi.FeatureLocalInterface) *DeviceConfigurationCommon { + return &DeviceConfigurationCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteDeviceConfiguration(featureRemote spineapi.FeatureRemoteInterface) *DeviceConfigurationCommon { + return &DeviceConfigurationCommon{ + featureRemote: featureRemote, + } +} + +var _ api.DeviceConfigurationCommonInterface = (*DeviceConfigurationCommon)(nil) + +// check if spine.EventPayload Data contains data for a given filter +// +// data type will be checked for model.DeviceConfigurationKeyValueListDataType, +// filter type will be checked for model.DeviceConfigurationKeyValueDescriptionDataType +func (d *DeviceConfigurationCommon) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { + if payloadData == nil { + return false + } + + data, ok := payloadData.(*model.DeviceConfigurationKeyValueListDataType) + filterData, ok2 := filter.(model.DeviceConfigurationKeyValueDescriptionDataType) + if !ok || !ok2 { + return false + } + + descs, err := d.GetKeyValueDescriptionsForFilter(filterData) + if err != nil { + return false + } + for _, desc := range descs { + if desc.KeyId == nil { + continue + } + + for _, item := range data.DeviceConfigurationKeyValueData { + if item.KeyId != nil && + *item.KeyId == *desc.KeyId || + item.Value != nil { + return true + } + } + } + + return false +} + +// Get the description for a given keyId +// +// Will return nil if no matching description is found +func (d *DeviceConfigurationCommon) GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) ( + *model.DeviceConfigurationKeyValueDescriptionDataType, error) { + data, err := d.GetKeyValueDescriptionsForFilter(model.DeviceConfigurationKeyValueDescriptionDataType{KeyId: &keyId}) + + if err != nil || len(data) != 1 { + return nil, api.ErrDataNotAvailable + } + + return &data[0], nil +} + +// Get the description for a given value combination +// +// Returns an error if no matching description is found +func (d *DeviceConfigurationCommon) GetKeyValueDescriptionsForFilter( + filter model.DeviceConfigurationKeyValueDescriptionDataType, +) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error) { + function := model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData + + data, err := featureDataCopyOfType[model.DeviceConfigurationKeyValueDescriptionListDataType](d.featureLocal, d.featureRemote, function) + if err != nil || data == nil || data.DeviceConfigurationKeyValueDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.DeviceConfigurationKeyValueDescriptionDataType]( + data.DeviceConfigurationKeyValueDescriptionData, filter) + return result, nil +} + +// Get the key value data for a given keyId +// +// Will return nil if no data is available +func (d *DeviceConfigurationCommon) GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) ( + *model.DeviceConfigurationKeyValueDataType, error) { + return d.GetKeyValueDataForFilter(model.DeviceConfigurationKeyValueDescriptionDataType{KeyId: &keyId}) +} + +// Get key value data for a given filter +// +// Will return nil if no data is available +func (d *DeviceConfigurationCommon) GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ( + *model.DeviceConfigurationKeyValueDataType, error) { + function := model.FunctionTypeDeviceConfigurationKeyValueListData + + descriptions, err := d.GetKeyValueDescriptionsForFilter(filter) + if err != nil || descriptions == nil || len(descriptions) == 0 { + return nil, api.ErrDataNotAvailable + } + + description := descriptions[0] + + data, err := featureDataCopyOfType[model.DeviceConfigurationKeyValueListDataType](d.featureLocal, d.featureRemote, function) + if err != nil || data == nil || data.DeviceConfigurationKeyValueData == nil { + return nil, api.ErrDataNotAvailable + } + + for _, item := range data.DeviceConfigurationKeyValueData { + if item.KeyId != nil && *item.KeyId == *description.KeyId { + return &item, nil + } + } + + return nil, api.ErrDataNotAvailable +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/devicediagnosis.go b/src/eebus-bridge/third_party/eebus-go/features/internal/devicediagnosis.go new file mode 100644 index 0000000..533e430 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/devicediagnosis.go @@ -0,0 +1,59 @@ +package internal + +import ( + "time" + + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceDiagnosisCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalDeviceDiagnosis(featureLocal spineapi.FeatureLocalInterface) *DeviceDiagnosisCommon { + return &DeviceDiagnosisCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteDeviceDiagnosis(featureRemote spineapi.FeatureRemoteInterface) *DeviceDiagnosisCommon { + return &DeviceDiagnosisCommon{ + featureRemote: featureRemote, + } +} + +var _ api.DeviceDiagnosisCommonInterface = (*DeviceDiagnosisCommon)(nil) + +// get the current diagnosis state for an device entity +func (d *DeviceDiagnosisCommon) GetState() (*model.DeviceDiagnosisStateDataType, error) { + function := model.FunctionTypeDeviceDiagnosisStateData + + data, err := featureDataCopyOfType[model.DeviceDiagnosisStateDataType](d.featureLocal, d.featureRemote, function) + if err != nil { + return nil, api.ErrDataNotAvailable + } + + return data, nil +} + +// check if the currently available heartbeat data is within a time duration +func (d *DeviceDiagnosisCommon) IsHeartbeatWithinDuration(duration time.Duration) bool { + function := model.FunctionTypeDeviceDiagnosisHeartbeatData + + data, err := featureDataCopyOfType[model.DeviceDiagnosisHeartbeatDataType](d.featureLocal, d.featureRemote, function) + if err != nil || data == nil || data.Timestamp == nil { + return false + } + + timeValue, err := data.Timestamp.GetTime() + if err != nil { + return false + } + + diff := time.Now().UTC().Add(-1 * duration) + + return diff.Compare(timeValue.Local()) <= 0 +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/electricalconnection.go b/src/eebus-bridge/third_party/eebus-go/features/internal/electricalconnection.go new file mode 100644 index 0000000..a6c3d5d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/electricalconnection.go @@ -0,0 +1,293 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type ElectricalConnectionCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalElectricalConnection(featureLocal spineapi.FeatureLocalInterface) *ElectricalConnectionCommon { + return &ElectricalConnectionCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteElectricalConnection(featureRemote spineapi.FeatureRemoteInterface) *ElectricalConnectionCommon { + return &ElectricalConnectionCommon{ + featureRemote: featureRemote, + } +} + +var _ api.ElectricalConnectionCommonInterface = (*ElectricalConnectionCommon)(nil) + +// check if spine.EventPayload Data contains data for a given filter +// +// data type will be checked for model.ElectricalConnectionPermittedValueSetListDataType, +// filter type will be checked for model.ElectricalConnectionParameterDescriptionDataType +func (e *ElectricalConnectionCommon) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { + if payloadData == nil { + return false + } + + data, ok := payloadData.(*model.ElectricalConnectionPermittedValueSetListDataType) + filterData, ok2 := filter.(model.ElectricalConnectionParameterDescriptionDataType) + if !ok || !ok2 { + return false + } + + descs, err := e.GetParameterDescriptionsForFilter(filterData) + if err != nil { + return false + } + + for _, desc := range descs { + for _, item := range data.ElectricalConnectionPermittedValueSetData { + if item.ParameterId != nil && + desc.ParameterId != nil && + *item.ParameterId == *desc.ParameterId && + len(item.PermittedValueSet) != 0 { + return true + } + } + } + + return false +} + +// Get the description for a given filter +// +// Returns an error if no matching description is found +func (e *ElectricalConnectionCommon) GetDescriptionsForFilter( + filter model.ElectricalConnectionDescriptionDataType, +) ([]model.ElectricalConnectionDescriptionDataType, error) { + function := model.FunctionTypeElectricalConnectionDescriptionListData + + data, err := featureDataCopyOfType[model.ElectricalConnectionDescriptionListDataType](e.featureLocal, e.featureRemote, function) + if err != nil || data == nil || data.ElectricalConnectionDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.ElectricalConnectionDescriptionDataType]( + data.ElectricalConnectionDescriptionData, filter) + return result, nil +} + +// return current electrical description for a given parameter description +func (e *ElectricalConnectionCommon) GetDescriptionForParameterDescriptionFilter( + filter model.ElectricalConnectionParameterDescriptionDataType) ( + *model.ElectricalConnectionDescriptionDataType, error) { + param, err := e.GetParameterDescriptionsForFilter(filter) + if err != nil || len(param) == 0 { + return nil, err + } + + descriptions, err := e.GetDescriptionsForFilter(model.ElectricalConnectionDescriptionDataType{}) + if err != nil { + return nil, err + } + + for _, item := range descriptions { + if item.ElectricalConnectionId == nil || + param[0].ElectricalConnectionId == nil || + *item.ElectricalConnectionId != *param[0].ElectricalConnectionId { + continue + } + + return &item, nil + } + + return nil, api.ErrMetadataNotAvailable +} + +// Get the description for a given filter +// +// Returns an error if no matching description is found +func (e *ElectricalConnectionCommon) GetParameterDescriptionsForFilter( + filter model.ElectricalConnectionParameterDescriptionDataType, +) ([]model.ElectricalConnectionParameterDescriptionDataType, error) { + function := model.FunctionTypeElectricalConnectionParameterDescriptionListData + + data, err := featureDataCopyOfType[model.ElectricalConnectionParameterDescriptionListDataType](e.featureLocal, e.featureRemote, function) + if err != nil || data == nil || data.ElectricalConnectionParameterDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.ElectricalConnectionParameterDescriptionDataType]( + data.ElectricalConnectionParameterDescriptionData, filter) + return result, nil +} + +// return permitted values for all Electrical Connections +func (e *ElectricalConnectionCommon) GetPermittedValueSetForFilter( + filter model.ElectricalConnectionPermittedValueSetDataType) ( + []model.ElectricalConnectionPermittedValueSetDataType, error) { + function := model.FunctionTypeElectricalConnectionPermittedValueSetListData + + data, err := featureDataCopyOfType[model.ElectricalConnectionPermittedValueSetListDataType](e.featureLocal, e.featureRemote, function) + if err != nil || data == nil || data.ElectricalConnectionPermittedValueSetData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.ElectricalConnectionPermittedValueSetDataType](data.ElectricalConnectionPermittedValueSetData, filter) + return result, nil +} + +// returns minimum, maximum, default/pause limit values +func (e *ElectricalConnectionCommon) GetPermittedValueDataForFilter( + filter model.ElectricalConnectionPermittedValueSetDataType) ( + float64, float64, float64, error) { + data, err := e.GetPermittedValueSetForFilter(filter) + if err != nil || len(data) != 1 || + data[0].ElectricalConnectionId == nil || + data[0].PermittedValueSet == nil { + return 0, 0, 0, api.ErrDataNotAvailable + } + + var resultMin, resultMax, resultDefault float64 + + for _, set := range data[0].PermittedValueSet { + if len(set.Value) > 0 { + resultDefault = set.Value[0].GetValue() + } + if set.Range != nil { + for _, rangeItem := range set.Range { + if rangeItem.Min != nil { + resultMin = rangeItem.Min.GetValue() + } + if rangeItem.Max != nil { + resultMax = rangeItem.Max.GetValue() + } + } + } + } + + return resultMin, resultMax, resultDefault, nil +} + +var PhaseNameMapping = []model.ElectricalConnectionPhaseNameType{ + model.ElectricalConnectionPhaseNameTypeA, + model.ElectricalConnectionPhaseNameTypeB, + model.ElectricalConnectionPhaseNameTypeC} + +// Get the min, max, default current limits for each phase +func (e *ElectricalConnectionCommon) GetPhaseCurrentLimits(measurementDescs []model.MeasurementDescriptionDataType) ( + resultMin []float64, resultMax []float64, resultDefault []float64, resultErr error) { + for _, phaseName := range PhaseNameMapping { + // electricalParameterDescription contains the measured phase for each measurementId + filter := model.ElectricalConnectionParameterDescriptionDataType{ + AcMeasuredPhases: util.Ptr(phaseName), + } + elParamDesc, err := e.GetParameterDescriptionsForFilter(filter) + if err != nil || len(elParamDesc) == 0 { + continue + } + + // check all params and assume there are no phase specific power limits + for _, paramEl := range elParamDesc { + if paramEl.ParameterId == nil || paramEl.MeasurementId == nil { + continue + } + + // check if the measurementId is in measurementDescs + found := false + for _, mDesc := range measurementDescs { + if mDesc.MeasurementId != nil && *mDesc.MeasurementId == *paramEl.MeasurementId { + found = true + break + } + } + if !found { + continue + } + + filter1 := model.ElectricalConnectionPermittedValueSetDataType{ + ParameterId: paramEl.ParameterId, + } + dataMin, dataMax, dataDefault, err := e.GetPermittedValueDataForFilter(filter1) + if err != nil { + continue + } + + // Min current data should be derived from min power data + // but as this value is only properly provided via VAS the + // currrent min values can not be trusted. + + resultMin = append(resultMin, dataMin) + resultMax = append(resultMax, dataMax) + resultDefault = append(resultDefault, dataDefault) + } + } + + if len(resultMin) == 0 { + return nil, nil, nil, api.ErrDataNotAvailable + } + + return resultMin, resultMax, resultDefault, nil +} + +// Adjust a value to be within the permitted value range +func (e *ElectricalConnectionCommon) AdjustValueToBeWithinPermittedValuesForParameterId( + value float64, parameterId model.ElectricalConnectionParameterIdType) float64 { + filter := model.ElectricalConnectionPermittedValueSetDataType{ + ParameterId: ¶meterId, + } + data, err := e.GetPermittedValueSetForFilter(filter) + if err != nil || len(data) != 1 { + return value + } + + var defaultValue, minValue, maxValue float64 + var hasDefaultValue, hasRange bool + + for _, element := range data[0].PermittedValueSet { + // is a value set + if len(element.Value) > 0 { + defaultValue = element.Value[0].GetValue() + hasDefaultValue = true + } + // is a range set + if len(element.Range) > 0 { + if element.Range[0].Min != nil { + minValue = element.Range[0].Min.GetValue() + } + if element.Range[0].Max != nil { + maxValue = element.Range[0].Max.GetValue() + } + hasRange = true + } + } + + if hasRange { + if hasDefaultValue && value < minValue { + value = defaultValue + } + if value > maxValue { + value = maxValue + } + } + + return value +} + +// Get the characteristics for a given filter +// +// Returns an error if no matching description is found +func (e *ElectricalConnectionCommon) GetCharacteristicsForFilter( + filter model.ElectricalConnectionCharacteristicDataType, +) ([]model.ElectricalConnectionCharacteristicDataType, error) { + function := model.FunctionTypeElectricalConnectionCharacteristicListData + + data, err := featureDataCopyOfType[model.ElectricalConnectionCharacteristicListDataType](e.featureLocal, e.featureRemote, function) + if err != nil || data == nil || data.ElectricalConnectionCharacteristicData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.ElectricalConnectionCharacteristicDataType](data.ElectricalConnectionCharacteristicData, filter) + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/helper.go b/src/eebus-bridge/third_party/eebus-go/features/internal/helper.go new file mode 100644 index 0000000..9853967 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/helper.go @@ -0,0 +1,61 @@ +package internal + +import ( + "reflect" + + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +func featureDataCopyOfType[T any]( + featureLocal spineapi.FeatureLocalInterface, + featureRemote spineapi.FeatureRemoteInterface, + function model.FunctionType) (*T, error) { + var data *T + var err error + + if featureLocal != nil { + data, err = spine.LocalFeatureDataCopyOfType[*T](featureLocal, function) + } else { + data, err = spine.RemoteFeatureDataCopyOfType[*T](featureRemote, function) + } + + return data, err +} + +func searchFilterInItem[T any](item T, filter T) bool { + v := reflect.ValueOf(item) + + match := true + for i := 0; i < v.NumField(); i++ { + filterField := reflect.ValueOf(filter).Field(i) + itemField := v.Field(i) + + if filterField.Kind() != reflect.Ptr || itemField.Kind() != reflect.Ptr { + continue + } + + if (!filterField.IsNil() && !itemField.IsNil() && filterField.Elem().Interface() != itemField.Elem().Interface()) || + (!filterField.IsNil() && itemField.IsNil()) { + match = false + break + } + } + + return match +} + +func searchFilterInList[T any](list []T, filter T) []T { + var result []T + + for _, item := range list { + match := searchFilterInItem[T](item, filter) + + if match { + result = append(result, item) + } + } + + return result +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/identification.go b/src/eebus-bridge/third_party/eebus-go/features/internal/identification.go new file mode 100644 index 0000000..2657551 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/identification.go @@ -0,0 +1,63 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type IdentificationCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalIdentification(featureLocal spineapi.FeatureLocalInterface) *IdentificationCommon { + return &IdentificationCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteIdentification(featureRemote spineapi.FeatureRemoteInterface) *IdentificationCommon { + return &IdentificationCommon{ + featureRemote: featureRemote, + } +} + +var _ api.IdentificationCommonInterface = (*IdentificationCommon)(nil) + +// check if spine.EventPayload Data contains identification data +// +// data type will be checked for model.IdentificationListDataType +func (i *IdentificationCommon) CheckEventPayloadDataForFilter(payloadData any) bool { + if payloadData == nil { + return false + } + + data, ok := payloadData.(*model.IdentificationListDataType) + if !ok { + return false + } + + for _, item := range data.IdentificationData { + if item.IdentificationId == nil || item.IdentificationValue == nil { + continue + } + + return true + } + + return false +} + +// return current values for Identification +func (i *IdentificationCommon) GetDataForFilter(filter model.IdentificationDataType) ([]model.IdentificationDataType, error) { + function := model.FunctionTypeIdentificationListData + + data, err := featureDataCopyOfType[model.IdentificationListDataType](i.featureLocal, i.featureRemote, function) + if err != nil || data == nil || data.IdentificationData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.IdentificationDataType](data.IdentificationData, filter) + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/incentivetable.go b/src/eebus-bridge/third_party/eebus-go/features/internal/incentivetable.go new file mode 100644 index 0000000..a5588fd --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/incentivetable.go @@ -0,0 +1,71 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type IncentiveTableCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalIncentiveTable(featureLocal spineapi.FeatureLocalInterface) *IncentiveTableCommon { + return &IncentiveTableCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteIncentiveTable(featureRemote spineapi.FeatureRemoteInterface) *IncentiveTableCommon { + return &IncentiveTableCommon{ + featureRemote: featureRemote, + } +} + +var _ api.IncentiveTableCommonInterface = (*IncentiveTableCommon)(nil) + +// return list of descriptions for a given filter +func (i *IncentiveTableCommon) GetDescriptionsForFilter( + filter model.TariffDescriptionDataType, +) ([]model.IncentiveTableDescriptionType, error) { + function := model.FunctionTypeIncentiveTableDescriptionData + data, err := featureDataCopyOfType[model.IncentiveTableDescriptionDataType](i.featureLocal, i.featureRemote, function) + if err != nil || data == nil || data.IncentiveTableDescription == nil { + return nil, api.ErrDataNotAvailable + } + + var result []model.IncentiveTableDescriptionType + for _, item := range data.IncentiveTableDescription { + match := searchFilterInItem[model.TariffDescriptionDataType](*item.TariffDescription, filter) + + if match { + result = append(result, item) + } + } + + return result, nil +} + +// return list of constraints +func (i *IncentiveTableCommon) GetConstraints() ([]model.IncentiveTableConstraintsType, error) { + function := model.FunctionTypeIncentiveTableConstraintsData + data, err := featureDataCopyOfType[model.IncentiveTableConstraintsDataType](i.featureLocal, i.featureRemote, function) + if err != nil { + return nil, api.ErrDataNotAvailable + } + + return data.IncentiveTableConstraints, nil +} + +// return current data for Time Series +func (i *IncentiveTableCommon) GetData() ([]model.IncentiveTableType, error) { + function := model.FunctionTypeIncentiveTableData + + data, err := featureDataCopyOfType[model.IncentiveTableDataType](i.featureLocal, i.featureRemote, function) + if err != nil || data == nil || data.IncentiveTable == nil { + return nil, api.ErrDataNotAvailable + } + + return data.IncentiveTable, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/loadcontrol.go b/src/eebus-bridge/third_party/eebus-go/features/internal/loadcontrol.go new file mode 100644 index 0000000..9b9a9ea --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/loadcontrol.go @@ -0,0 +1,128 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type LoadControlCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalLoadControl(featureLocal spineapi.FeatureLocalInterface) *LoadControlCommon { + return &LoadControlCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteLoadControl(featureRemote spineapi.FeatureRemoteInterface) *LoadControlCommon { + return &LoadControlCommon{ + featureRemote: featureRemote, + } +} + +var _ api.FeatureServerInterface = (*LoadControlCommon)(nil) + +// check if spine.EventPayload Data contains data for a given filter +// +// data type will be checked for model.LoadControlLimitListDataType, +// filter type will be checked for model.LoadControlLimitDescriptionDataType +func (l *LoadControlCommon) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { + if payloadData == nil { + return false + } + + data, ok := payloadData.(*model.LoadControlLimitListDataType) + filterData, ok2 := filter.(model.LoadControlLimitDescriptionDataType) + if !ok || !ok2 { + return false + } + + descs, _ := l.GetLimitDescriptionsForFilter(filterData) + for _, desc := range descs { + for _, item := range data.LoadControlLimitData { + if item.LimitId != nil && + desc.LimitId != nil && + *item.LimitId == *desc.LimitId && + item.Value != nil { + return true + } + } + } + + return false +} + +var _ api.LoadControlCommonInterface = (*LoadControlCommon)(nil) + +// Get the description for a given limitId +// +// Will return nil if no matching description is found +func (l *LoadControlCommon) GetLimitDescriptionForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDescriptionDataType, error) { + data, err := l.GetLimitDescriptionsForFilter(model.LoadControlLimitDescriptionDataType{LimitId: &limitId}) + + if err != nil || len(data) != 1 { + return nil, api.ErrDataNotAvailable + } + + return &data[0], nil +} + +// Get the description for a given filter +// +// Returns an error if no matching description is found +func (l *LoadControlCommon) GetLimitDescriptionsForFilter( + filter model.LoadControlLimitDescriptionDataType, +) ([]model.LoadControlLimitDescriptionDataType, error) { + function := model.FunctionTypeLoadControlLimitDescriptionListData + + data, err := featureDataCopyOfType[model.LoadControlLimitDescriptionListDataType](l.featureLocal, l.featureRemote, function) + if err != nil || data == nil || data.LoadControlLimitDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.LoadControlLimitDescriptionDataType](data.LoadControlLimitDescriptionData, filter) + return result, nil +} + +// Get the description for a given limitId +// +// Will return nil if no data is available +func (l *LoadControlCommon) GetLimitDataForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error) { + result, err := l.GetLimitDataForFilter(model.LoadControlLimitDescriptionDataType{LimitId: &limitId}) + if err != nil || len(result) == 0 { + return nil, api.ErrDataNotAvailable + } + return &result[0], nil +} + +// Get limit data for a given filter +// +// Will return nil if no data is available +func (l *LoadControlCommon) GetLimitDataForFilter(filter model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error) { + function := model.FunctionTypeLoadControlLimitListData + + descriptions, err := l.GetLimitDescriptionsForFilter(filter) + if err != nil || len(descriptions) == 0 { + return nil, api.ErrDataNotAvailable + } + + data, err := featureDataCopyOfType[model.LoadControlLimitListDataType](l.featureLocal, l.featureRemote, function) + if err != nil || data == nil || data.LoadControlLimitData == nil { + return nil, api.ErrDataNotAvailable + } + + var result []model.LoadControlLimitDataType + + for _, desc := range descriptions { + filter2 := model.LoadControlLimitDataType{ + LimitId: desc.LimitId, + } + + elements := searchFilterInList[model.LoadControlLimitDataType](data.LoadControlLimitData, filter2) + result = append(result, elements...) + } + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/measurement.go b/src/eebus-bridge/third_party/eebus-go/features/internal/measurement.go new file mode 100644 index 0000000..2a48cab --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/measurement.go @@ -0,0 +1,154 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type MeasurementCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalMeasurement(featureLocal spineapi.FeatureLocalInterface) *MeasurementCommon { + return &MeasurementCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteMeasurement(featureRemote spineapi.FeatureRemoteInterface) *MeasurementCommon { + return &MeasurementCommon{ + featureRemote: featureRemote, + } +} + +var _ api.MeasurementCommonInterface = (*MeasurementCommon)(nil) + +// check if spine.EventPayload Data contains data for a given filter +// +// data type will be checked for model.MeasurementListDataType, +// filter type will be checked for model.MeasurementDescriptionDataType +func (m *MeasurementCommon) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { + if payloadData == nil { + return false + } + + data, ok := payloadData.(*model.MeasurementListDataType) + filterData, ok2 := filter.(model.MeasurementDescriptionDataType) + if !ok || !ok2 { + return false + } + + descs, err := m.GetDescriptionsForFilter(filterData) + if err != nil { + return false + } + for _, desc := range descs { + if desc.MeasurementId == nil { + continue + } + + for _, item := range data.MeasurementData { + if item.MeasurementId != nil && + *item.MeasurementId == *desc.MeasurementId && + item.Value != nil { + return true + } + } + } + + return false +} + +// Get the description for a given id +// +// Returns an error if no matching description is found +func (m *MeasurementCommon) GetDescriptionForId( + measurementId model.MeasurementIdType, +) (*model.MeasurementDescriptionDataType, error) { + data, err := m.GetDescriptionsForFilter(model.MeasurementDescriptionDataType{MeasurementId: &measurementId}) + + if err != nil || len(data) != 1 { + return nil, api.ErrDataNotAvailable + } + + return &data[0], nil +} + +// Get the description for a given filter +// +// Returns an error if no matching description is found +func (m *MeasurementCommon) GetDescriptionsForFilter( + filter model.MeasurementDescriptionDataType, +) ([]model.MeasurementDescriptionDataType, error) { + function := model.FunctionTypeMeasurementDescriptionListData + + data, err := featureDataCopyOfType[model.MeasurementDescriptionListDataType](m.featureLocal, m.featureRemote, function) + if err != nil || data == nil || data.MeasurementDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.MeasurementDescriptionDataType](data.MeasurementDescriptionData, filter) + return result, nil +} + +// Get the constraints for a given filter +// +// Returns an error if no matching constraint is found +func (m *MeasurementCommon) GetConstraintsForFilter( + filter model.MeasurementConstraintsDataType, +) ([]model.MeasurementConstraintsDataType, error) { + function := model.FunctionTypeMeasurementConstraintsListData + + data, err := featureDataCopyOfType[model.MeasurementConstraintsListDataType](m.featureLocal, m.featureRemote, function) + if err != nil || data == nil || data.MeasurementConstraintsData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.MeasurementConstraintsDataType](data.MeasurementConstraintsData, filter) + return result, nil +} + +// Get the measuement data for a given measurementId +// +// Will return nil if no data is available +func (m *MeasurementCommon) GetDataForId(measurementId model.MeasurementIdType) ( + *model.MeasurementDataType, error) { + result, err := m.GetDataForFilter(model.MeasurementDescriptionDataType{MeasurementId: &measurementId}) + if err != nil || len(result) == 0 { + return nil, api.ErrDataNotAvailable + } + + return &result[0], nil +} + +// Get measuement data for a given filter +// +// Will return nil if no data is available +func (m *MeasurementCommon) GetDataForFilter(filter model.MeasurementDescriptionDataType) ( + []model.MeasurementDataType, error) { + function := model.FunctionTypeMeasurementListData + + descriptions, err := m.GetDescriptionsForFilter(filter) + if err != nil || len(descriptions) == 0 { + return nil, api.ErrDataNotAvailable + } + + data, err := featureDataCopyOfType[model.MeasurementListDataType](m.featureLocal, m.featureRemote, function) + if err != nil || data == nil || data.MeasurementData == nil { + return nil, api.ErrDataNotAvailable + } + + var result []model.MeasurementDataType + + for _, desc := range descriptions { + filter2 := model.MeasurementDataType{ + MeasurementId: desc.MeasurementId, + } + + elements := searchFilterInList[model.MeasurementDataType](data.MeasurementData, filter2) + result = append(result, elements...) + } + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/smartenergymanagementps.go b/src/eebus-bridge/third_party/eebus-go/features/internal/smartenergymanagementps.go new file mode 100644 index 0000000..0974563 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/smartenergymanagementps.go @@ -0,0 +1,38 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type SmartEnergyManagementPsCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalSmartEnergyManagementPs(featureLocal spineapi.FeatureLocalInterface) *SmartEnergyManagementPsCommon { + return &SmartEnergyManagementPsCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteSmartEnergyManagementPs(featureRemote spineapi.FeatureRemoteInterface) *SmartEnergyManagementPsCommon { + return &SmartEnergyManagementPsCommon{ + featureRemote: featureRemote, + } +} + +var _ api.FeatureServerInterface = (*SmartEnergyManagementPsCommon)(nil) + +// return current data for FunctionTypeSmartEnergyManagementPsData +func (i *SmartEnergyManagementPsCommon) GetData() (*model.SmartEnergyManagementPsDataType, error) { + function := model.FunctionTypeSmartEnergyManagementPsData + + data, err := featureDataCopyOfType[model.SmartEnergyManagementPsDataType](i.featureLocal, i.featureRemote, function) + if err != nil || data == nil { + return nil, api.ErrDataNotAvailable + } + + return data, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/internal/timeseries.go b/src/eebus-bridge/third_party/eebus-go/features/internal/timeseries.go new file mode 100644 index 0000000..8317bd8 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/internal/timeseries.go @@ -0,0 +1,80 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type TimeSeriesCommon struct { + featureLocal spineapi.FeatureLocalInterface + featureRemote spineapi.FeatureRemoteInterface +} + +func NewLocalTimeSeries(featureLocal spineapi.FeatureLocalInterface) *TimeSeriesCommon { + return &TimeSeriesCommon{ + featureLocal: featureLocal, + } +} + +func NewRemoteTimeSeries(featureRemote spineapi.FeatureRemoteInterface) *TimeSeriesCommon { + return &TimeSeriesCommon{ + featureRemote: featureRemote, + } +} + +var _ api.TimeSeriesCommonInterface = (*TimeSeriesCommon)(nil) + +// return list of descriptions for a given filter +func (t *TimeSeriesCommon) GetDescriptionsForFilter( + filter model.TimeSeriesDescriptionDataType, +) ([]model.TimeSeriesDescriptionDataType, error) { + function := model.FunctionTypeTimeSeriesDescriptionListData + + data, err := featureDataCopyOfType[model.TimeSeriesDescriptionListDataType](t.featureLocal, t.featureRemote, function) + if err != nil || data == nil || data.TimeSeriesDescriptionData == nil { + return nil, api.ErrDataNotAvailable + } + + result := searchFilterInList[model.TimeSeriesDescriptionDataType](data.TimeSeriesDescriptionData, filter) + return result, nil +} + +// return current constraints for Time Series +func (t *TimeSeriesCommon) GetConstraints() ([]model.TimeSeriesConstraintsDataType, error) { + function := model.FunctionTypeTimeSeriesConstraintsListData + + data, err := featureDataCopyOfType[model.TimeSeriesConstraintsListDataType](t.featureLocal, t.featureRemote, function) + if err != nil { + return nil, api.ErrDataNotAvailable + } + + return data.TimeSeriesConstraintsData, nil +} + +// return current data for Time Series for a given filter +func (t *TimeSeriesCommon) GetDataForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error) { + function := model.FunctionTypeTimeSeriesListData + + descriptions, err := t.GetDescriptionsForFilter(filter) + if err != nil || len(descriptions) == 0 { + return nil, api.ErrDataNotAvailable + } + + data, err := featureDataCopyOfType[model.TimeSeriesListDataType](t.featureLocal, t.featureRemote, function) + if err != nil || data == nil || data.TimeSeriesData == nil { + return nil, api.ErrDataNotAvailable + } + + var result []model.TimeSeriesDataType + + for _, desc := range descriptions { + filter2 := model.TimeSeriesDataType{ + TimeSeriesId: desc.TimeSeriesId, + } + + elements := searchFilterInList[model.TimeSeriesDataType](data.TimeSeriesData, filter2) + result = append(result, elements...) + } + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/deviceconfiguration.go b/src/eebus-bridge/third_party/eebus-go/features/server/deviceconfiguration.go new file mode 100644 index 0000000..42c8a5e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/deviceconfiguration.go @@ -0,0 +1,126 @@ +package server + +import ( + "errors" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" + "github.com/enbility/spine-go/util" +) + +type DeviceConfiguration struct { + *Feature + + *internal.DeviceConfigurationCommon +} + +func NewDeviceConfiguration(localEntity spineapi.EntityLocalInterface) (*DeviceConfiguration, error) { + feature, err := NewFeature(model.FeatureTypeTypeDeviceConfiguration, localEntity) + if err != nil { + return nil, err + } + + dc := &DeviceConfiguration{ + Feature: feature, + DeviceConfigurationCommon: internal.NewLocalDeviceConfiguration(feature.featureLocal), + } + + return dc, nil +} + +var _ api.DeviceConfigurationServerInterface = (*DeviceConfiguration)(nil) + +// Add a new description data set and return the keyId +// +// will return nil if the data set could not be added +func (d *DeviceConfiguration) AddKeyValueDescription( + description model.DeviceConfigurationKeyValueDescriptionDataType, +) *model.DeviceConfigurationKeyIdType { + data, err := spine.LocalFeatureDataCopyOfType[*model.DeviceConfigurationKeyValueDescriptionListDataType](d.featureLocal, model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData) + if err != nil { + data = &model.DeviceConfigurationKeyValueDescriptionListDataType{} + } + + var keyId *model.DeviceConfigurationKeyIdType + + maxId := model.DeviceConfigurationKeyIdType(0) + + for _, item := range data.DeviceConfigurationKeyValueDescriptionData { + if item.KeyId != nil && *item.KeyId >= maxId { + maxId = *item.KeyId + 1 + } + } + + keyId = util.Ptr(maxId) + description.KeyId = keyId + + partial := model.NewFilterTypePartial() + datalist := &model.DeviceConfigurationKeyValueDescriptionListDataType{ + DeviceConfigurationKeyValueDescriptionData: []model.DeviceConfigurationKeyValueDescriptionDataType{description}, + } + + if err := d.featureLocal.UpdateData(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, datalist, partial, nil); err != nil { + return nil + } + + return keyId +} + +// Set or update data set for a keyId +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (d *DeviceConfiguration) UpdateKeyValueDataForKeyId( + data model.DeviceConfigurationKeyValueDataType, + deleteElements *model.DeviceConfigurationKeyValueDataElementsType, + keyId model.DeviceConfigurationKeyIdType, +) (resultErr error) { + return d.UpdateKeyValueDataForFilter(data, deleteElements, model.DeviceConfigurationKeyValueDescriptionDataType{KeyId: &keyId}) +} + +// Set or update data set for a filter +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (d *DeviceConfiguration) UpdateKeyValueDataForFilter( + data model.DeviceConfigurationKeyValueDataType, + deleteElements *model.DeviceConfigurationKeyValueDataElementsType, + filter model.DeviceConfigurationKeyValueDescriptionDataType, +) (resultErr error) { + resultErr = api.ErrDataNotAvailable + + descriptions, err := d.GetKeyValueDescriptionsForFilter(filter) + if err != nil { + return err + } + if descriptions == nil || len(descriptions) != 1 { + return + } + + description := descriptions[0] + data.KeyId = description.KeyId + + datalist := &model.DeviceConfigurationKeyValueListDataType{ + DeviceConfigurationKeyValueData: []model.DeviceConfigurationKeyValueDataType{data}, + } + + partial := model.NewFilterTypePartial() + var deleteFilter *model.FilterType + if deleteElements != nil { + deleteFilter = &model.FilterType{ + DeviceConfigurationKeyValueListDataSelectors: &model.DeviceConfigurationKeyValueListDataSelectorsType{ + KeyId: description.KeyId, + }, + DeviceConfigurationKeyValueDataElements: deleteElements, + } + } + + if err := d.featureLocal.UpdateData(model.FunctionTypeDeviceConfigurationKeyValueListData, datalist, partial, deleteFilter); err != nil { + return errors.New(err.String()) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/devicediagnosis.go b/src/eebus-bridge/third_party/eebus-go/features/server/devicediagnosis.go new file mode 100644 index 0000000..70768c2 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/devicediagnosis.go @@ -0,0 +1,35 @@ +package server + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceDiagnosis struct { + *Feature + + *internal.DeviceDiagnosisCommon +} + +func NewDeviceDiagnosis(localEntity spineapi.EntityLocalInterface) (*DeviceDiagnosis, error) { + feature, err := NewFeature(model.FeatureTypeTypeDeviceConfiguration, localEntity) + if err != nil { + return nil, err + } + + dc := &DeviceDiagnosis{ + Feature: feature, + DeviceDiagnosisCommon: internal.NewLocalDeviceDiagnosis(feature.featureLocal), + } + + return dc, nil +} + +var _ api.DeviceDiagnosisServerInterface = (*DeviceDiagnosis)(nil) + +// set the local diagnosis state of the device +func (d *DeviceDiagnosis) SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) { + d.featureLocal.SetData(model.FunctionTypeDeviceDiagnosisStateData, operatingState) +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/electricalconnection.go b/src/eebus-bridge/third_party/eebus-go/features/server/electricalconnection.go new file mode 100644 index 0000000..0665d67 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/electricalconnection.go @@ -0,0 +1,185 @@ +package server + +import ( + "errors" + + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" + "github.com/enbility/spine-go/util" +) + +type ElectricalConnection struct { + *Feature + + *internal.ElectricalConnectionCommon +} + +func NewElectricalConnection(localEntity spineapi.EntityLocalInterface) (*ElectricalConnection, error) { + feature, err := NewFeature(model.FeatureTypeTypeElectricalConnection, localEntity) + if err != nil { + return nil, err + } + + ec := &ElectricalConnection{ + Feature: feature, + ElectricalConnectionCommon: internal.NewLocalElectricalConnection(feature.featureLocal), + } + + return ec, nil +} + +// Add a new description data set +// +// NOTE: the electricalConnectionId has to be provided +// +// will return nil if the data set could not be added +func (e *ElectricalConnection) AddDescription( + description model.ElectricalConnectionDescriptionDataType, +) error { + if description.ElectricalConnectionId == nil { + return errors.New("missing id data") + } + + partial := model.NewFilterTypePartial() + datalist := &model.ElectricalConnectionDescriptionListDataType{ + ElectricalConnectionDescriptionData: []model.ElectricalConnectionDescriptionDataType{description}, + } + + if err := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionDescriptionListData, datalist, partial, nil); err != nil { + return errors.New(err.String()) + } + + return nil +} + +// Add a new parameter description data sett and return the parameterId +// +// NOTE: the electricalConnectionId has to be provided, parameterId may not be provided +// +// will return nil if the data set could not be added +func (e *ElectricalConnection) AddParameterDescription( + description model.ElectricalConnectionParameterDescriptionDataType, +) *model.ElectricalConnectionParameterIdType { + if description.ElectricalConnectionId == nil || description.ParameterId != nil { + return nil + } + + filter := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: description.ElectricalConnectionId, + } + data, _ := e.GetParameterDescriptionsForFilter(filter) + + maxId := model.ElectricalConnectionParameterIdType(0) + + for _, item := range data { + if item.ParameterId != nil && *item.ParameterId >= maxId { + maxId = *item.ParameterId + 1 + } + } + + parameterId := util.Ptr(maxId) + description.ParameterId = parameterId + + partial := model.NewFilterTypePartial() + datalist := &model.ElectricalConnectionParameterDescriptionListDataType{ + ElectricalConnectionParameterDescriptionData: []model.ElectricalConnectionParameterDescriptionDataType{description}, + } + + if err := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionParameterDescriptionListData, datalist, partial, nil); err != nil { + return nil + } + + return parameterId +} + +// Add a new characteristic data set +// +// Note: ElectricalConnectionId and ParameterId must be set, CharacteristicId will be set automatically +// +// Will return an error if the data set could not be added +func (e *ElectricalConnection) AddCharacteristic(data model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error) { + if data.ElectricalConnectionId == nil || + data.ParameterId == nil { + return nil, errors.New("missing id data") + } + if data.CharacteristicId != nil { + return nil, errors.New("characteristic id must not be set") + } + + maxId := model.ElectricalConnectionCharacteristicIdType(0) + + listData, err := spine.LocalFeatureDataCopyOfType[*model.ElectricalConnectionCharacteristicListDataType](e.featureLocal, model.FunctionTypeElectricalConnectionCharacteristicListData) + if err != nil { + listData = &model.ElectricalConnectionCharacteristicListDataType{} + } + + for _, item := range listData.ElectricalConnectionCharacteristicData { + if item.CharacteristicId != nil && *item.CharacteristicId >= maxId { + maxId = *item.CharacteristicId + 1 + } + } + + charId := util.Ptr(maxId) + data.CharacteristicId = charId + + datalist := &model.ElectricalConnectionCharacteristicListDataType{ + ElectricalConnectionCharacteristicData: []model.ElectricalConnectionCharacteristicDataType{data}, + } + + partial := model.NewFilterTypePartial() + if err := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionCharacteristicListData, datalist, partial, nil); err != nil { + return nil, errors.New(err.String()) + } + + return charId, nil +} + +// Update data set for a filter +// Elements provided in deleteElements will be removed from the data set before the update +// +// // ElectricalConnectionId, ParameterId and CharacteristicId must be set +// +// Will return an error if the data set could not be updated +func (e *ElectricalConnection) UpdateCharacteristic( + data model.ElectricalConnectionCharacteristicDataType, + deleteElements *model.ElectricalConnectionCharacteristicDataElementsType, +) error { + if data.CharacteristicId == nil || + data.ElectricalConnectionId == nil || + data.ParameterId == nil { + return errors.New("missing id data") + } + + filter := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: data.ElectricalConnectionId, + ParameterId: data.ParameterId, + CharacteristicId: data.CharacteristicId, + } + chars, err := e.GetCharacteristicsForFilter(filter) + if err != nil || chars == nil || len(chars) != 1 { + return errors.New("no matching element found") + } + + partial := model.NewFilterTypePartial() + var deleteFilter *model.FilterType + if deleteElements != nil { + deleteFilter = &model.FilterType{ + ElectricalConnectionCharacteristicListDataSelectors: &model.ElectricalConnectionCharacteristicListDataSelectorsType{ + CharacteristicId: data.CharacteristicId, + }, + ElectricalConnectionCharacteristicDataElements: deleteElements, + } + } + + datalist := &model.ElectricalConnectionCharacteristicListDataType{ + ElectricalConnectionCharacteristicData: []model.ElectricalConnectionCharacteristicDataType{data}, + } + + if err := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionCharacteristicListData, datalist, partial, deleteFilter); err != nil { + return errors.New(err.String()) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/feature.go b/src/eebus-bridge/third_party/eebus-go/features/server/feature.go new file mode 100644 index 0000000..f50ffff --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/feature.go @@ -0,0 +1,43 @@ +package server + +import ( + "errors" + + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type Feature struct { + featureType model.FeatureTypeType + + localRole model.RoleType + + spineLocalDevice spineapi.DeviceLocalInterface + localEntity spineapi.EntityLocalInterface + + featureLocal spineapi.FeatureLocalInterface +} + +// var _ api.FeatureServerInterface = (*Feature)(nil) + +func NewFeature( + featureType model.FeatureTypeType, + localEntity spineapi.EntityLocalInterface) (*Feature, error) { + if localEntity == nil { + return nil, errors.New("local entity is nil") + } + + f := &Feature{ + featureType: featureType, + localRole: model.RoleTypeServer, + spineLocalDevice: localEntity.Device(), + localEntity: localEntity, + } + + f.featureLocal = f.localEntity.FeatureOfTypeAndRole(f.featureType, f.localRole) + if f.featureLocal == nil { + return nil, errors.New("local feature not found") + } + + return f, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/loadcontrol.go b/src/eebus-bridge/third_party/eebus-go/features/server/loadcontrol.go new file mode 100644 index 0000000..9cc41f7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/loadcontrol.go @@ -0,0 +1,124 @@ +package server + +import ( + "errors" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type LoadControl struct { + *Feature + + *internal.LoadControlCommon +} + +func NewLoadControl(localEntity spineapi.EntityLocalInterface) (*LoadControl, error) { + feature, err := NewFeature(model.FeatureTypeTypeLoadControl, localEntity) + if err != nil { + return nil, err + } + + lc := &LoadControl{ + Feature: feature, + LoadControlCommon: internal.NewLocalLoadControl(feature.featureLocal), + } + + return lc, nil +} + +// Add a new description data set and return the limitId +// +// NOTE: the limitId may not be provided +// +// will return nil if the data set could not be added +func (l *LoadControl) AddLimitDescription( + description model.LoadControlLimitDescriptionDataType, +) *model.LoadControlLimitIdType { + if description.LimitId != nil { + return nil + } + + data, err := l.GetLimitDescriptionsForFilter(model.LoadControlLimitDescriptionDataType{}) + if err != nil { + data = []model.LoadControlLimitDescriptionDataType{} + } + + maxId := model.LoadControlLimitIdType(0) + + for _, item := range data { + if item.LimitId != nil && *item.LimitId >= maxId { + maxId = *item.LimitId + 1 + } + } + + limitId := util.Ptr(maxId) + description.LimitId = limitId + + partial := model.NewFilterTypePartial() + datalist := &model.LoadControlLimitDescriptionListDataType{ + LoadControlLimitDescriptionData: []model.LoadControlLimitDescriptionDataType{description}, + } + + if err := l.featureLocal.UpdateData(model.FunctionTypeLoadControlLimitDescriptionListData, datalist, partial, nil); err != nil { + return nil + } + + return limitId +} + +// Set or update data set for a limitId +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (l *LoadControl) UpdateLimitDataForId( + data model.LoadControlLimitDataType, + deleteElements *model.LoadControlLimitDataElementsType, + limitId model.LoadControlLimitIdType, +) (resultErr error) { + return l.UpdateLimitDataForFilter(data, deleteElements, model.LoadControlLimitDescriptionDataType{LimitId: &limitId}) +} + +// Set or update data set for a filter +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (l *LoadControl) UpdateLimitDataForFilter( + data model.LoadControlLimitDataType, + deleteElements *model.LoadControlLimitDataElementsType, + filter model.LoadControlLimitDescriptionDataType, +) (resultErr error) { + resultErr = api.ErrDataNotAvailable + + descriptions, err := l.GetLimitDescriptionsForFilter(filter) + if err != nil || descriptions == nil || len(descriptions) != 1 { + return + } + + description := descriptions[0] + data.LimitId = description.LimitId + + datalist := &model.LoadControlLimitListDataType{ + LoadControlLimitData: []model.LoadControlLimitDataType{data}, + } + + partial := model.NewFilterTypePartial() + var deleteFilter *model.FilterType + if deleteElements != nil { + deleteFilter = &model.FilterType{ + LoadControlLimitListDataSelectors: &model.LoadControlLimitListDataSelectorsType{ + LimitId: description.LimitId, + }, + LoadControlLimitDataElements: deleteElements, + } + } + + if err := l.featureLocal.UpdateData(model.FunctionTypeLoadControlLimitListData, datalist, partial, deleteFilter); err != nil { + return errors.New(err.String()) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/features/server/measurement.go b/src/eebus-bridge/third_party/eebus-go/features/server/measurement.go new file mode 100644 index 0000000..5a8a7cc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/features/server/measurement.go @@ -0,0 +1,126 @@ +package server + +import ( + "errors" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type Measurement struct { + *Feature + + *internal.MeasurementCommon +} + +func NewMeasurement(localEntity spineapi.EntityLocalInterface) (*Measurement, error) { + feature, err := NewFeature(model.FeatureTypeTypeMeasurement, localEntity) + if err != nil { + return nil, err + } + + m := &Measurement{ + Feature: feature, + MeasurementCommon: internal.NewLocalMeasurement(feature.featureLocal), + } + + return m, nil +} + +var _ api.MeasurementServerInterface = (*Measurement)(nil) + +// Add a new parameter description data sett and return the measurementId +// +// NOTE: the measurementId may not be provided +// +// will return nil if the data set could not be added +func (m *Measurement) AddDescription( + description model.MeasurementDescriptionDataType, +) *model.MeasurementIdType { + if description.MeasurementId != nil { + return nil + } + + data, err := m.GetDescriptionsForFilter(model.MeasurementDescriptionDataType{}) + if err != nil { + data = []model.MeasurementDescriptionDataType{} + } + + maxId := model.MeasurementIdType(0) + + for _, item := range data { + if item.MeasurementId != nil && *item.MeasurementId >= maxId { + maxId = *item.MeasurementId + 1 + } + } + + measurementId := util.Ptr(maxId) + description.MeasurementId = measurementId + + partial := model.NewFilterTypePartial() + datalist := &model.MeasurementDescriptionListDataType{ + MeasurementDescriptionData: []model.MeasurementDescriptionDataType{description}, + } + + if err := m.featureLocal.UpdateData(model.FunctionTypeMeasurementDescriptionListData, datalist, partial, nil); err != nil { + return nil + } + + return measurementId +} + +// Set or update data set for a measurementId +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (m *Measurement) UpdateDataForId( + data model.MeasurementDataType, + deleteElements *model.MeasurementDataElementsType, + measurementId model.MeasurementIdType, +) (resultErr error) { + return m.UpdateDataForFilter(data, deleteElements, model.MeasurementDescriptionDataType{MeasurementId: &measurementId}) +} + +// Set or update data set for a filter +// Elements provided in deleteElements will be removed from the data set before the update +// +// Will return an error if the data set could not be updated +func (m *Measurement) UpdateDataForFilter( + data model.MeasurementDataType, + deleteElements *model.MeasurementDataElementsType, + filter model.MeasurementDescriptionDataType, +) (resultErr error) { + resultErr = api.ErrDataNotAvailable + + descriptions, err := m.GetDescriptionsForFilter(filter) + if err != nil || descriptions == nil || len(descriptions) != 1 { + return + } + + description := descriptions[0] + data.MeasurementId = description.MeasurementId + + datalist := &model.MeasurementListDataType{ + MeasurementData: []model.MeasurementDataType{data}, + } + + partial := model.NewFilterTypePartial() + var deleteFilter *model.FilterType + if deleteElements != nil { + deleteFilter = &model.FilterType{ + MeasurementListDataSelectors: &model.MeasurementListDataSelectorsType{ + MeasurementId: description.MeasurementId, + }, + MeasurementDataElements: deleteElements, + } + } + + if err := m.featureLocal.UpdateData(model.FunctionTypeMeasurementListData, datalist, partial, deleteFilter); err != nil { + return errors.New(err.String()) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/go.mod b/src/eebus-bridge/third_party/eebus-go/go.mod new file mode 100644 index 0000000..cd6b651 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/go.mod @@ -0,0 +1,37 @@ +module github.com/enbility/eebus-go + +go 1.22.0 + +require ( + github.com/enbility/ship-go v0.6.0 + github.com/enbility/spine-go v0.7.0 + github.com/stretchr/testify v1.9.0 +) + +require ( + github.com/ahmetb/go-linq/v3 v3.2.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a // indirect + github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/golanguzb70/lrucache v1.2.0 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/miekg/dns v1.1.62 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rickb777/date v1.21.1 // indirect + github.com/rickb777/plural v1.4.2 // indirect + github.com/stretchr/objx v0.5.2 // indirect + gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect + go.uber.org/mock v0.4.0 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/tools v0.25.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +retract ( + v0.2.2 // Contains retractions only. + v0.2.1 // Published accidentally. +) diff --git a/src/eebus-bridge/third_party/eebus-go/go.sum b/src/eebus-bridge/third_party/eebus-go/go.sum new file mode 100644 index 0000000..84205cb --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/go.sum @@ -0,0 +1,54 @@ +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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a h1:foChWb8lhzqa6lWDRs6COYMdp649YlUirFP8GqoT0JQ= +github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a/go.mod h1:H64mhYcAQUGUUnVqMdZQf93kPecH4M79xwH95Lddt3U= +github.com/enbility/ship-go v0.6.0 h1:1ft5NJJHqqGU3/ryYwQj8xBYJLFbf0q2cP9mjlYHlgw= +github.com/enbility/ship-go v0.6.0/go.mod h1:JJp8EQcJhUhTpZ2LSEU4rpdaM3E2n08tswWFWtmm/wU= +github.com/enbility/spine-go v0.7.0 h1:UZeghFgnM3VFU0ghc57Htt6gnxwP9jLppfU2GUMJGgY= +github.com/enbility/spine-go v0.7.0/go.mod h1:IF1sBTr7p3wXqlejeBJcJ8BYFlzzRaZcJsGw8XjgEgc= +github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 h1:XOYvxKtT1oxT37w/5oEiRLuPbm9FuJPt3fiYhX0h8Po= +github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6/go.mod h1:BszP9qFV14mPXgyIREbgIdQtWxbAj3OKqvK02HihMoM= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/golanguzb70/lrucache v1.2.0 h1:VjpjmB4VTf9VXBtZTJGcgcN0CNFM5egDrrSjkGyQOlg= +github.com/golanguzb70/lrucache v1.2.0/go.mod h1:zc2GD26KwGEDdTHsCCTcJorv/11HyKwQVS9gqg2bizc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= +github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rickb777/date v1.21.1 h1:tUcQS8riIRoYK5kUAv5aevllFEYUEk2x8OYDyoldOn4= +github.com/rickb777/date v1.21.1/go.mod h1:gnDexsbXViZr2fCKMrY3m6IfAF5U2vSkEaiGJcNFaLQ= +github.com/rickb777/plural v1.4.2 h1:Kl/syFGLFZ5EbuV8c9SVud8s5HI2HpCCtOMw2U1kS+A= +github.com/rickb777/plural v1.4.2/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a h1:DxppxFKRqJ8WD6oJ3+ZXKDY0iMONQDl5UTg2aTyHh8k= +gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a/go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= +golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationClientInterface.go new file mode 100644 index 0000000..567c8b6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationClientInterface.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceClassificationClientInterface is an autogenerated mock type for the DeviceClassificationClientInterface type +type DeviceClassificationClientInterface struct { + mock.Mock +} + +type DeviceClassificationClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceClassificationClientInterface) EXPECT() *DeviceClassificationClientInterface_Expecter { + return &DeviceClassificationClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestManufacturerDetails provides a mock function with given fields: +func (_m *DeviceClassificationClientInterface) RequestManufacturerDetails() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestManufacturerDetails") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceClassificationClientInterface_RequestManufacturerDetails_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestManufacturerDetails' +type DeviceClassificationClientInterface_RequestManufacturerDetails_Call struct { + *mock.Call +} + +// RequestManufacturerDetails is a helper method to define mock.On call +func (_e *DeviceClassificationClientInterface_Expecter) RequestManufacturerDetails() *DeviceClassificationClientInterface_RequestManufacturerDetails_Call { + return &DeviceClassificationClientInterface_RequestManufacturerDetails_Call{Call: _e.mock.On("RequestManufacturerDetails")} +} + +func (_c *DeviceClassificationClientInterface_RequestManufacturerDetails_Call) Run(run func()) *DeviceClassificationClientInterface_RequestManufacturerDetails_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceClassificationClientInterface_RequestManufacturerDetails_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceClassificationClientInterface_RequestManufacturerDetails_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceClassificationClientInterface_RequestManufacturerDetails_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *DeviceClassificationClientInterface_RequestManufacturerDetails_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceClassificationClientInterface creates a new instance of DeviceClassificationClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceClassificationClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceClassificationClientInterface { + mock := &DeviceClassificationClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationCommonInterface.go new file mode 100644 index 0000000..19b8b33 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationCommonInterface.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceClassificationCommonInterface is an autogenerated mock type for the DeviceClassificationCommonInterface type +type DeviceClassificationCommonInterface struct { + mock.Mock +} + +type DeviceClassificationCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceClassificationCommonInterface) EXPECT() *DeviceClassificationCommonInterface_Expecter { + return &DeviceClassificationCommonInterface_Expecter{mock: &_m.Mock} +} + +// GetManufacturerDetails provides a mock function with given fields: +func (_m *DeviceClassificationCommonInterface) GetManufacturerDetails() (*model.DeviceClassificationManufacturerDataType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetManufacturerDetails") + } + + var r0 *model.DeviceClassificationManufacturerDataType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.DeviceClassificationManufacturerDataType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.DeviceClassificationManufacturerDataType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceClassificationManufacturerDataType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceClassificationCommonInterface_GetManufacturerDetails_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetManufacturerDetails' +type DeviceClassificationCommonInterface_GetManufacturerDetails_Call struct { + *mock.Call +} + +// GetManufacturerDetails is a helper method to define mock.On call +func (_e *DeviceClassificationCommonInterface_Expecter) GetManufacturerDetails() *DeviceClassificationCommonInterface_GetManufacturerDetails_Call { + return &DeviceClassificationCommonInterface_GetManufacturerDetails_Call{Call: _e.mock.On("GetManufacturerDetails")} +} + +func (_c *DeviceClassificationCommonInterface_GetManufacturerDetails_Call) Run(run func()) *DeviceClassificationCommonInterface_GetManufacturerDetails_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceClassificationCommonInterface_GetManufacturerDetails_Call) Return(_a0 *model.DeviceClassificationManufacturerDataType, _a1 error) *DeviceClassificationCommonInterface_GetManufacturerDetails_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceClassificationCommonInterface_GetManufacturerDetails_Call) RunAndReturn(run func() (*model.DeviceClassificationManufacturerDataType, error)) *DeviceClassificationCommonInterface_GetManufacturerDetails_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceClassificationCommonInterface creates a new instance of DeviceClassificationCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceClassificationCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceClassificationCommonInterface { + mock := &DeviceClassificationCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationServerInterface.go new file mode 100644 index 0000000..a072e4b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceClassificationServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// DeviceClassificationServerInterface is an autogenerated mock type for the DeviceClassificationServerInterface type +type DeviceClassificationServerInterface struct { + mock.Mock +} + +type DeviceClassificationServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceClassificationServerInterface) EXPECT() *DeviceClassificationServerInterface_Expecter { + return &DeviceClassificationServerInterface_Expecter{mock: &_m.Mock} +} + +// NewDeviceClassificationServerInterface creates a new instance of DeviceClassificationServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceClassificationServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceClassificationServerInterface { + mock := &DeviceClassificationServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationClientInterface.go new file mode 100644 index 0000000..a55ed0f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationClientInterface.go @@ -0,0 +1,490 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceConfigurationClientInterface is an autogenerated mock type for the DeviceConfigurationClientInterface type +type DeviceConfigurationClientInterface struct { + mock.Mock +} + +type DeviceConfigurationClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceConfigurationClientInterface) EXPECT() *DeviceConfigurationClientInterface_Expecter { + return &DeviceConfigurationClientInterface_Expecter{mock: &_m.Mock} +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *DeviceConfigurationClientInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *DeviceConfigurationClientInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { + return &DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationClientInterface) GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForFilter") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForFilter' +type DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDataForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationClientInterface_Expecter) GetKeyValueDataForFilter(filter interface{}) *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call { + return &DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call{Call: _e.mock.On("GetKeyValueDataForFilter", filter)} +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationClientInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationClientInterface) GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForKeyId' +type DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDataForKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationClientInterface_Expecter) GetKeyValueDataForKeyId(keyId interface{}) *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call { + return &DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call{Call: _e.mock.On("GetKeyValueDataForKeyId", keyId)} +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationClientInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionFoKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationClientInterface) GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionFoKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionFoKeyId' +type DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionFoKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationClientInterface_Expecter) GetKeyValueDescriptionFoKeyId(keyId interface{}) *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call { + return &DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call{Call: _e.mock.On("GetKeyValueDescriptionFoKeyId", keyId)} +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationClientInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionsForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationClientInterface) GetKeyValueDescriptionsForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionsForFilter") + } + + var r0 []model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) []model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionsForFilter' +type DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionsForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationClientInterface_Expecter) GetKeyValueDescriptionsForFilter(filter interface{}) *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call { + return &DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call{Call: _e.mock.On("GetKeyValueDescriptionsForFilter", filter)} +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call) Return(_a0 []model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationClientInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// RequestKeyValueDescriptions provides a mock function with given fields: selector, elements +func (_m *DeviceConfigurationClientInterface) RequestKeyValueDescriptions(selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestKeyValueDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, *model.DeviceConfigurationKeyValueDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, *model.DeviceConfigurationKeyValueDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, *model.DeviceConfigurationKeyValueDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestKeyValueDescriptions' +type DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call struct { + *mock.Call +} + +// RequestKeyValueDescriptions is a helper method to define mock.On call +// - selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType +// - elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType +func (_e *DeviceConfigurationClientInterface_Expecter) RequestKeyValueDescriptions(selector interface{}, elements interface{}) *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call { + return &DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call{Call: _e.mock.On("RequestKeyValueDescriptions", selector, elements)} +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call) Run(run func(selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType)) *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType), args[1].(*model.DeviceConfigurationKeyValueDescriptionDataElementsType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call) RunAndReturn(run func(*model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType, *model.DeviceConfigurationKeyValueDescriptionDataElementsType) (*model.MsgCounterType, error)) *DeviceConfigurationClientInterface_RequestKeyValueDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// RequestKeyValues provides a mock function with given fields: selector, elements +func (_m *DeviceConfigurationClientInterface) RequestKeyValues(selector *model.DeviceConfigurationKeyValueListDataSelectorsType, elements *model.DeviceConfigurationKeyValueDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestKeyValues") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.DeviceConfigurationKeyValueListDataSelectorsType, *model.DeviceConfigurationKeyValueDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.DeviceConfigurationKeyValueListDataSelectorsType, *model.DeviceConfigurationKeyValueDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.DeviceConfigurationKeyValueListDataSelectorsType, *model.DeviceConfigurationKeyValueDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_RequestKeyValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestKeyValues' +type DeviceConfigurationClientInterface_RequestKeyValues_Call struct { + *mock.Call +} + +// RequestKeyValues is a helper method to define mock.On call +// - selector *model.DeviceConfigurationKeyValueListDataSelectorsType +// - elements *model.DeviceConfigurationKeyValueDataElementsType +func (_e *DeviceConfigurationClientInterface_Expecter) RequestKeyValues(selector interface{}, elements interface{}) *DeviceConfigurationClientInterface_RequestKeyValues_Call { + return &DeviceConfigurationClientInterface_RequestKeyValues_Call{Call: _e.mock.On("RequestKeyValues", selector, elements)} +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValues_Call) Run(run func(selector *model.DeviceConfigurationKeyValueListDataSelectorsType, elements *model.DeviceConfigurationKeyValueDataElementsType)) *DeviceConfigurationClientInterface_RequestKeyValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DeviceConfigurationKeyValueListDataSelectorsType), args[1].(*model.DeviceConfigurationKeyValueDataElementsType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValues_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceConfigurationClientInterface_RequestKeyValues_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_RequestKeyValues_Call) RunAndReturn(run func(*model.DeviceConfigurationKeyValueListDataSelectorsType, *model.DeviceConfigurationKeyValueDataElementsType) (*model.MsgCounterType, error)) *DeviceConfigurationClientInterface_RequestKeyValues_Call { + _c.Call.Return(run) + return _c +} + +// WriteKeyValues provides a mock function with given fields: data +func (_m *DeviceConfigurationClientInterface) WriteKeyValues(data []model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for WriteKeyValues") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func([]model.DeviceConfigurationKeyValueDataType) *model.MsgCounterType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]model.DeviceConfigurationKeyValueDataType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationClientInterface_WriteKeyValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteKeyValues' +type DeviceConfigurationClientInterface_WriteKeyValues_Call struct { + *mock.Call +} + +// WriteKeyValues is a helper method to define mock.On call +// - data []model.DeviceConfigurationKeyValueDataType +func (_e *DeviceConfigurationClientInterface_Expecter) WriteKeyValues(data interface{}) *DeviceConfigurationClientInterface_WriteKeyValues_Call { + return &DeviceConfigurationClientInterface_WriteKeyValues_Call{Call: _e.mock.On("WriteKeyValues", data)} +} + +func (_c *DeviceConfigurationClientInterface_WriteKeyValues_Call) Run(run func(data []model.DeviceConfigurationKeyValueDataType)) *DeviceConfigurationClientInterface_WriteKeyValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.DeviceConfigurationKeyValueDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationClientInterface_WriteKeyValues_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceConfigurationClientInterface_WriteKeyValues_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationClientInterface_WriteKeyValues_Call) RunAndReturn(run func([]model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error)) *DeviceConfigurationClientInterface_WriteKeyValues_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceConfigurationClientInterface creates a new instance of DeviceConfigurationClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceConfigurationClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceConfigurationClientInterface { + mock := &DeviceConfigurationClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationCommonInterface.go new file mode 100644 index 0000000..e10b3e7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationCommonInterface.go @@ -0,0 +1,314 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceConfigurationCommonInterface is an autogenerated mock type for the DeviceConfigurationCommonInterface type +type DeviceConfigurationCommonInterface struct { + mock.Mock +} + +type DeviceConfigurationCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceConfigurationCommonInterface) EXPECT() *DeviceConfigurationCommonInterface_Expecter { + return &DeviceConfigurationCommonInterface_Expecter{mock: &_m.Mock} +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *DeviceConfigurationCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *DeviceConfigurationCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { + return &DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationCommonInterface) GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForFilter") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForFilter' +type DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDataForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationCommonInterface_Expecter) GetKeyValueDataForFilter(filter interface{}) *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call { + return &DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call{Call: _e.mock.On("GetKeyValueDataForFilter", filter)} +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationCommonInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationCommonInterface) GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForKeyId' +type DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDataForKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationCommonInterface_Expecter) GetKeyValueDataForKeyId(keyId interface{}) *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call { + return &DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call{Call: _e.mock.On("GetKeyValueDataForKeyId", keyId)} +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationCommonInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionFoKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationCommonInterface) GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionFoKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionFoKeyId' +type DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionFoKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationCommonInterface_Expecter) GetKeyValueDescriptionFoKeyId(keyId interface{}) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call { + return &DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call{Call: _e.mock.On("GetKeyValueDescriptionFoKeyId", keyId)} +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionsForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationCommonInterface) GetKeyValueDescriptionsForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionsForFilter") + } + + var r0 []model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) []model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionsForFilter' +type DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionsForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationCommonInterface_Expecter) GetKeyValueDescriptionsForFilter(filter interface{}) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call { + return &DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call{Call: _e.mock.On("GetKeyValueDescriptionsForFilter", filter)} +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call) Return(_a0 []model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationCommonInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceConfigurationCommonInterface creates a new instance of DeviceConfigurationCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceConfigurationCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceConfigurationCommonInterface { + mock := &DeviceConfigurationCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationServerInterface.go new file mode 100644 index 0000000..ad7a097 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceConfigurationServerInterface.go @@ -0,0 +1,458 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceConfigurationServerInterface is an autogenerated mock type for the DeviceConfigurationServerInterface type +type DeviceConfigurationServerInterface struct { + mock.Mock +} + +type DeviceConfigurationServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceConfigurationServerInterface) EXPECT() *DeviceConfigurationServerInterface_Expecter { + return &DeviceConfigurationServerInterface_Expecter{mock: &_m.Mock} +} + +// AddKeyValueDescription provides a mock function with given fields: description +func (_m *DeviceConfigurationServerInterface) AddKeyValueDescription(description model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyIdType { + ret := _m.Called(description) + + if len(ret) == 0 { + panic("no return value specified for AddKeyValueDescription") + } + + var r0 *model.DeviceConfigurationKeyIdType + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyIdType); ok { + r0 = rf(description) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyIdType) + } + } + + return r0 +} + +// DeviceConfigurationServerInterface_AddKeyValueDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddKeyValueDescription' +type DeviceConfigurationServerInterface_AddKeyValueDescription_Call struct { + *mock.Call +} + +// AddKeyValueDescription is a helper method to define mock.On call +// - description model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationServerInterface_Expecter) AddKeyValueDescription(description interface{}) *DeviceConfigurationServerInterface_AddKeyValueDescription_Call { + return &DeviceConfigurationServerInterface_AddKeyValueDescription_Call{Call: _e.mock.On("AddKeyValueDescription", description)} +} + +func (_c *DeviceConfigurationServerInterface_AddKeyValueDescription_Call) Run(run func(description model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationServerInterface_AddKeyValueDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_AddKeyValueDescription_Call) Return(_a0 *model.DeviceConfigurationKeyIdType) *DeviceConfigurationServerInterface_AddKeyValueDescription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationServerInterface_AddKeyValueDescription_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyIdType) *DeviceConfigurationServerInterface_AddKeyValueDescription_Call { + _c.Call.Return(run) + return _c +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *DeviceConfigurationServerInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *DeviceConfigurationServerInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { + return &DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationServerInterface) GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForFilter") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForFilter' +type DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDataForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationServerInterface_Expecter) GetKeyValueDataForFilter(filter interface{}) *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call { + return &DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call{Call: _e.mock.On("GetKeyValueDataForFilter", filter)} +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationServerInterface_GetKeyValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDataForKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationServerInterface) GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDataForKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDataForKeyId' +type DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDataForKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationServerInterface_Expecter) GetKeyValueDataForKeyId(keyId interface{}) *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call { + return &DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call{Call: _e.mock.On("GetKeyValueDataForKeyId", keyId)} +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDataType, _a1 error) *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)) *DeviceConfigurationServerInterface_GetKeyValueDataForKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionFoKeyId provides a mock function with given fields: keyId +func (_m *DeviceConfigurationServerInterface) GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(keyId) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionFoKeyId") + } + + var r0 *model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(keyId) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyIdType) *model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(keyId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyIdType) error); ok { + r1 = rf(keyId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionFoKeyId' +type DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionFoKeyId is a helper method to define mock.On call +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationServerInterface_Expecter) GetKeyValueDescriptionFoKeyId(keyId interface{}) *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call { + return &DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call{Call: _e.mock.On("GetKeyValueDescriptionFoKeyId", keyId)} +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call) Run(run func(keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call) Return(_a0 *model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationServerInterface_GetKeyValueDescriptionFoKeyId_Call { + _c.Call.Return(run) + return _c +} + +// GetKeyValueDescriptionsForFilter provides a mock function with given fields: filter +func (_m *DeviceConfigurationServerInterface) GetKeyValueDescriptionsForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetKeyValueDescriptionsForFilter") + } + + var r0 []model.DeviceConfigurationKeyValueDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDescriptionDataType) []model.DeviceConfigurationKeyValueDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.DeviceConfigurationKeyValueDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKeyValueDescriptionsForFilter' +type DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetKeyValueDescriptionsForFilter is a helper method to define mock.On call +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationServerInterface_Expecter) GetKeyValueDescriptionsForFilter(filter interface{}) *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call { + return &DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call{Call: _e.mock.On("GetKeyValueDescriptionsForFilter", filter)} +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call) Run(run func(filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call) Return(_a0 []model.DeviceConfigurationKeyValueDescriptionDataType, _a1 error) *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)) *DeviceConfigurationServerInterface_GetKeyValueDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// UpdateKeyValueDataForFilter provides a mock function with given fields: data, deleteElements, filter +func (_m *DeviceConfigurationServerInterface) UpdateKeyValueDataForFilter(data model.DeviceConfigurationKeyValueDataType, deleteElements *model.DeviceConfigurationKeyValueDataElementsType, filter model.DeviceConfigurationKeyValueDescriptionDataType) error { + ret := _m.Called(data, deleteElements, filter) + + if len(ret) == 0 { + panic("no return value specified for UpdateKeyValueDataForFilter") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDataType, *model.DeviceConfigurationKeyValueDataElementsType, model.DeviceConfigurationKeyValueDescriptionDataType) error); ok { + r0 = rf(data, deleteElements, filter) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateKeyValueDataForFilter' +type DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call struct { + *mock.Call +} + +// UpdateKeyValueDataForFilter is a helper method to define mock.On call +// - data model.DeviceConfigurationKeyValueDataType +// - deleteElements *model.DeviceConfigurationKeyValueDataElementsType +// - filter model.DeviceConfigurationKeyValueDescriptionDataType +func (_e *DeviceConfigurationServerInterface_Expecter) UpdateKeyValueDataForFilter(data interface{}, deleteElements interface{}, filter interface{}) *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call { + return &DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call{Call: _e.mock.On("UpdateKeyValueDataForFilter", data, deleteElements, filter)} +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call) Run(run func(data model.DeviceConfigurationKeyValueDataType, deleteElements *model.DeviceConfigurationKeyValueDataElementsType, filter model.DeviceConfigurationKeyValueDescriptionDataType)) *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDataType), args[1].(*model.DeviceConfigurationKeyValueDataElementsType), args[2].(model.DeviceConfigurationKeyValueDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call) Return(_a0 error) *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDataType, *model.DeviceConfigurationKeyValueDataElementsType, model.DeviceConfigurationKeyValueDescriptionDataType) error) *DeviceConfigurationServerInterface_UpdateKeyValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// UpdateKeyValueDataForKeyId provides a mock function with given fields: data, deleteElements, keyId +func (_m *DeviceConfigurationServerInterface) UpdateKeyValueDataForKeyId(data model.DeviceConfigurationKeyValueDataType, deleteElements *model.DeviceConfigurationKeyValueDataElementsType, keyId model.DeviceConfigurationKeyIdType) error { + ret := _m.Called(data, deleteElements, keyId) + + if len(ret) == 0 { + panic("no return value specified for UpdateKeyValueDataForKeyId") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.DeviceConfigurationKeyValueDataType, *model.DeviceConfigurationKeyValueDataElementsType, model.DeviceConfigurationKeyIdType) error); ok { + r0 = rf(data, deleteElements, keyId) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateKeyValueDataForKeyId' +type DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call struct { + *mock.Call +} + +// UpdateKeyValueDataForKeyId is a helper method to define mock.On call +// - data model.DeviceConfigurationKeyValueDataType +// - deleteElements *model.DeviceConfigurationKeyValueDataElementsType +// - keyId model.DeviceConfigurationKeyIdType +func (_e *DeviceConfigurationServerInterface_Expecter) UpdateKeyValueDataForKeyId(data interface{}, deleteElements interface{}, keyId interface{}) *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call { + return &DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call{Call: _e.mock.On("UpdateKeyValueDataForKeyId", data, deleteElements, keyId)} +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call) Run(run func(data model.DeviceConfigurationKeyValueDataType, deleteElements *model.DeviceConfigurationKeyValueDataElementsType, keyId model.DeviceConfigurationKeyIdType)) *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceConfigurationKeyValueDataType), args[1].(*model.DeviceConfigurationKeyValueDataElementsType), args[2].(model.DeviceConfigurationKeyIdType)) + }) + return _c +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call) Return(_a0 error) *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call) RunAndReturn(run func(model.DeviceConfigurationKeyValueDataType, *model.DeviceConfigurationKeyValueDataElementsType, model.DeviceConfigurationKeyIdType) error) *DeviceConfigurationServerInterface_UpdateKeyValueDataForKeyId_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceConfigurationServerInterface creates a new instance of DeviceConfigurationServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceConfigurationServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceConfigurationServerInterface { + mock := &DeviceConfigurationServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisClientInterface.go new file mode 100644 index 0000000..f2096d2 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisClientInterface.go @@ -0,0 +1,149 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceDiagnosisClientInterface is an autogenerated mock type for the DeviceDiagnosisClientInterface type +type DeviceDiagnosisClientInterface struct { + mock.Mock +} + +type DeviceDiagnosisClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceDiagnosisClientInterface) EXPECT() *DeviceDiagnosisClientInterface_Expecter { + return &DeviceDiagnosisClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestHeartbeat provides a mock function with given fields: +func (_m *DeviceDiagnosisClientInterface) RequestHeartbeat() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestHeartbeat") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceDiagnosisClientInterface_RequestHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestHeartbeat' +type DeviceDiagnosisClientInterface_RequestHeartbeat_Call struct { + *mock.Call +} + +// RequestHeartbeat is a helper method to define mock.On call +func (_e *DeviceDiagnosisClientInterface_Expecter) RequestHeartbeat() *DeviceDiagnosisClientInterface_RequestHeartbeat_Call { + return &DeviceDiagnosisClientInterface_RequestHeartbeat_Call{Call: _e.mock.On("RequestHeartbeat")} +} + +func (_c *DeviceDiagnosisClientInterface_RequestHeartbeat_Call) Run(run func()) *DeviceDiagnosisClientInterface_RequestHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceDiagnosisClientInterface_RequestHeartbeat_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceDiagnosisClientInterface_RequestHeartbeat_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceDiagnosisClientInterface_RequestHeartbeat_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *DeviceDiagnosisClientInterface_RequestHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// RequestState provides a mock function with given fields: +func (_m *DeviceDiagnosisClientInterface) RequestState() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestState") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceDiagnosisClientInterface_RequestState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestState' +type DeviceDiagnosisClientInterface_RequestState_Call struct { + *mock.Call +} + +// RequestState is a helper method to define mock.On call +func (_e *DeviceDiagnosisClientInterface_Expecter) RequestState() *DeviceDiagnosisClientInterface_RequestState_Call { + return &DeviceDiagnosisClientInterface_RequestState_Call{Call: _e.mock.On("RequestState")} +} + +func (_c *DeviceDiagnosisClientInterface_RequestState_Call) Run(run func()) *DeviceDiagnosisClientInterface_RequestState_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceDiagnosisClientInterface_RequestState_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceDiagnosisClientInterface_RequestState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceDiagnosisClientInterface_RequestState_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *DeviceDiagnosisClientInterface_RequestState_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceDiagnosisClientInterface creates a new instance of DeviceDiagnosisClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceDiagnosisClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceDiagnosisClientInterface { + mock := &DeviceDiagnosisClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisCommonInterface.go new file mode 100644 index 0000000..c5c7123 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisCommonInterface.go @@ -0,0 +1,140 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// DeviceDiagnosisCommonInterface is an autogenerated mock type for the DeviceDiagnosisCommonInterface type +type DeviceDiagnosisCommonInterface struct { + mock.Mock +} + +type DeviceDiagnosisCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceDiagnosisCommonInterface) EXPECT() *DeviceDiagnosisCommonInterface_Expecter { + return &DeviceDiagnosisCommonInterface_Expecter{mock: &_m.Mock} +} + +// GetState provides a mock function with given fields: +func (_m *DeviceDiagnosisCommonInterface) GetState() (*model.DeviceDiagnosisStateDataType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetState") + } + + var r0 *model.DeviceDiagnosisStateDataType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.DeviceDiagnosisStateDataType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.DeviceDiagnosisStateDataType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceDiagnosisStateDataType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceDiagnosisCommonInterface_GetState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetState' +type DeviceDiagnosisCommonInterface_GetState_Call struct { + *mock.Call +} + +// GetState is a helper method to define mock.On call +func (_e *DeviceDiagnosisCommonInterface_Expecter) GetState() *DeviceDiagnosisCommonInterface_GetState_Call { + return &DeviceDiagnosisCommonInterface_GetState_Call{Call: _e.mock.On("GetState")} +} + +func (_c *DeviceDiagnosisCommonInterface_GetState_Call) Run(run func()) *DeviceDiagnosisCommonInterface_GetState_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceDiagnosisCommonInterface_GetState_Call) Return(_a0 *model.DeviceDiagnosisStateDataType, _a1 error) *DeviceDiagnosisCommonInterface_GetState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceDiagnosisCommonInterface_GetState_Call) RunAndReturn(run func() (*model.DeviceDiagnosisStateDataType, error)) *DeviceDiagnosisCommonInterface_GetState_Call { + _c.Call.Return(run) + return _c +} + +// IsHeartbeatWithinDuration provides a mock function with given fields: duration +func (_m *DeviceDiagnosisCommonInterface) IsHeartbeatWithinDuration(duration time.Duration) bool { + ret := _m.Called(duration) + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatWithinDuration") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(time.Duration) bool); ok { + r0 = rf(duration) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatWithinDuration' +type DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call struct { + *mock.Call +} + +// IsHeartbeatWithinDuration is a helper method to define mock.On call +// - duration time.Duration +func (_e *DeviceDiagnosisCommonInterface_Expecter) IsHeartbeatWithinDuration(duration interface{}) *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call { + return &DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call{Call: _e.mock.On("IsHeartbeatWithinDuration", duration)} +} + +func (_c *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call) Run(run func(duration time.Duration)) *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration)) + }) + return _c +} + +func (_c *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call) Return(_a0 bool) *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call) RunAndReturn(run func(time.Duration) bool) *DeviceDiagnosisCommonInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceDiagnosisCommonInterface creates a new instance of DeviceDiagnosisCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceDiagnosisCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceDiagnosisCommonInterface { + mock := &DeviceDiagnosisCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisServerInterface.go new file mode 100644 index 0000000..e6cdc56 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/DeviceDiagnosisServerInterface.go @@ -0,0 +1,68 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceDiagnosisServerInterface is an autogenerated mock type for the DeviceDiagnosisServerInterface type +type DeviceDiagnosisServerInterface struct { + mock.Mock +} + +type DeviceDiagnosisServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceDiagnosisServerInterface) EXPECT() *DeviceDiagnosisServerInterface_Expecter { + return &DeviceDiagnosisServerInterface_Expecter{mock: &_m.Mock} +} + +// SetLocalState provides a mock function with given fields: operatingState +func (_m *DeviceDiagnosisServerInterface) SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) { + _m.Called(operatingState) +} + +// DeviceDiagnosisServerInterface_SetLocalState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLocalState' +type DeviceDiagnosisServerInterface_SetLocalState_Call struct { + *mock.Call +} + +// SetLocalState is a helper method to define mock.On call +// - operatingState *model.DeviceDiagnosisStateDataType +func (_e *DeviceDiagnosisServerInterface_Expecter) SetLocalState(operatingState interface{}) *DeviceDiagnosisServerInterface_SetLocalState_Call { + return &DeviceDiagnosisServerInterface_SetLocalState_Call{Call: _e.mock.On("SetLocalState", operatingState)} +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalState_Call) Run(run func(operatingState *model.DeviceDiagnosisStateDataType)) *DeviceDiagnosisServerInterface_SetLocalState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DeviceDiagnosisStateDataType)) + }) + return _c +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalState_Call) Return() *DeviceDiagnosisServerInterface_SetLocalState_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalState_Call) RunAndReturn(run func(*model.DeviceDiagnosisStateDataType)) *DeviceDiagnosisServerInterface_SetLocalState_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceDiagnosisServerInterface creates a new instance of DeviceDiagnosisServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceDiagnosisServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceDiagnosisServerInterface { + mock := &DeviceDiagnosisServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionClientInterface.go new file mode 100644 index 0000000..b6605cc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionClientInterface.go @@ -0,0 +1,271 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// ElectricalConnectionClientInterface is an autogenerated mock type for the ElectricalConnectionClientInterface type +type ElectricalConnectionClientInterface struct { + mock.Mock +} + +type ElectricalConnectionClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ElectricalConnectionClientInterface) EXPECT() *ElectricalConnectionClientInterface_Expecter { + return &ElectricalConnectionClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestCharacteristics provides a mock function with given fields: selector, elements +func (_m *ElectricalConnectionClientInterface) RequestCharacteristics(selector *model.ElectricalConnectionCharacteristicListDataSelectorsType, elements *model.ElectricalConnectionCharacteristicDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestCharacteristics") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionCharacteristicListDataSelectorsType, *model.ElectricalConnectionCharacteristicDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionCharacteristicListDataSelectorsType, *model.ElectricalConnectionCharacteristicDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.ElectricalConnectionCharacteristicListDataSelectorsType, *model.ElectricalConnectionCharacteristicDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionClientInterface_RequestCharacteristics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestCharacteristics' +type ElectricalConnectionClientInterface_RequestCharacteristics_Call struct { + *mock.Call +} + +// RequestCharacteristics is a helper method to define mock.On call +// - selector *model.ElectricalConnectionCharacteristicListDataSelectorsType +// - elements *model.ElectricalConnectionCharacteristicDataElementsType +func (_e *ElectricalConnectionClientInterface_Expecter) RequestCharacteristics(selector interface{}, elements interface{}) *ElectricalConnectionClientInterface_RequestCharacteristics_Call { + return &ElectricalConnectionClientInterface_RequestCharacteristics_Call{Call: _e.mock.On("RequestCharacteristics", selector, elements)} +} + +func (_c *ElectricalConnectionClientInterface_RequestCharacteristics_Call) Run(run func(selector *model.ElectricalConnectionCharacteristicListDataSelectorsType, elements *model.ElectricalConnectionCharacteristicDataElementsType)) *ElectricalConnectionClientInterface_RequestCharacteristics_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.ElectricalConnectionCharacteristicListDataSelectorsType), args[1].(*model.ElectricalConnectionCharacteristicDataElementsType)) + }) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestCharacteristics_Call) Return(_a0 *model.MsgCounterType, _a1 error) *ElectricalConnectionClientInterface_RequestCharacteristics_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestCharacteristics_Call) RunAndReturn(run func(*model.ElectricalConnectionCharacteristicListDataSelectorsType, *model.ElectricalConnectionCharacteristicDataElementsType) (*model.MsgCounterType, error)) *ElectricalConnectionClientInterface_RequestCharacteristics_Call { + _c.Call.Return(run) + return _c +} + +// RequestDescriptions provides a mock function with given fields: selector, elements +func (_m *ElectricalConnectionClientInterface) RequestDescriptions(selector *model.ElectricalConnectionDescriptionListDataSelectorsType, elements *model.ElectricalConnectionDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionDescriptionListDataSelectorsType, *model.ElectricalConnectionDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionDescriptionListDataSelectorsType, *model.ElectricalConnectionDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.ElectricalConnectionDescriptionListDataSelectorsType, *model.ElectricalConnectionDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionClientInterface_RequestDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestDescriptions' +type ElectricalConnectionClientInterface_RequestDescriptions_Call struct { + *mock.Call +} + +// RequestDescriptions is a helper method to define mock.On call +// - selector *model.ElectricalConnectionDescriptionListDataSelectorsType +// - elements *model.ElectricalConnectionDescriptionDataElementsType +func (_e *ElectricalConnectionClientInterface_Expecter) RequestDescriptions(selector interface{}, elements interface{}) *ElectricalConnectionClientInterface_RequestDescriptions_Call { + return &ElectricalConnectionClientInterface_RequestDescriptions_Call{Call: _e.mock.On("RequestDescriptions", selector, elements)} +} + +func (_c *ElectricalConnectionClientInterface_RequestDescriptions_Call) Run(run func(selector *model.ElectricalConnectionDescriptionListDataSelectorsType, elements *model.ElectricalConnectionDescriptionDataElementsType)) *ElectricalConnectionClientInterface_RequestDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.ElectricalConnectionDescriptionListDataSelectorsType), args[1].(*model.ElectricalConnectionDescriptionDataElementsType)) + }) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *ElectricalConnectionClientInterface_RequestDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestDescriptions_Call) RunAndReturn(run func(*model.ElectricalConnectionDescriptionListDataSelectorsType, *model.ElectricalConnectionDescriptionDataElementsType) (*model.MsgCounterType, error)) *ElectricalConnectionClientInterface_RequestDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// RequestParameterDescriptions provides a mock function with given fields: selector, elements +func (_m *ElectricalConnectionClientInterface) RequestParameterDescriptions(selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType, elements *model.ElectricalConnectionParameterDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestParameterDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionParameterDescriptionListDataSelectorsType, *model.ElectricalConnectionParameterDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionParameterDescriptionListDataSelectorsType, *model.ElectricalConnectionParameterDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.ElectricalConnectionParameterDescriptionListDataSelectorsType, *model.ElectricalConnectionParameterDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionClientInterface_RequestParameterDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestParameterDescriptions' +type ElectricalConnectionClientInterface_RequestParameterDescriptions_Call struct { + *mock.Call +} + +// RequestParameterDescriptions is a helper method to define mock.On call +// - selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType +// - elements *model.ElectricalConnectionParameterDescriptionDataElementsType +func (_e *ElectricalConnectionClientInterface_Expecter) RequestParameterDescriptions(selector interface{}, elements interface{}) *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call { + return &ElectricalConnectionClientInterface_RequestParameterDescriptions_Call{Call: _e.mock.On("RequestParameterDescriptions", selector, elements)} +} + +func (_c *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call) Run(run func(selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType, elements *model.ElectricalConnectionParameterDescriptionDataElementsType)) *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.ElectricalConnectionParameterDescriptionListDataSelectorsType), args[1].(*model.ElectricalConnectionParameterDescriptionDataElementsType)) + }) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call) RunAndReturn(run func(*model.ElectricalConnectionParameterDescriptionListDataSelectorsType, *model.ElectricalConnectionParameterDescriptionDataElementsType) (*model.MsgCounterType, error)) *ElectricalConnectionClientInterface_RequestParameterDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// RequestPermittedValueSets provides a mock function with given fields: selector, elements +func (_m *ElectricalConnectionClientInterface) RequestPermittedValueSets(selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType, elements *model.ElectricalConnectionPermittedValueSetDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestPermittedValueSets") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionPermittedValueSetListDataSelectorsType, *model.ElectricalConnectionPermittedValueSetDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.ElectricalConnectionPermittedValueSetListDataSelectorsType, *model.ElectricalConnectionPermittedValueSetDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.ElectricalConnectionPermittedValueSetListDataSelectorsType, *model.ElectricalConnectionPermittedValueSetDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionClientInterface_RequestPermittedValueSets_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestPermittedValueSets' +type ElectricalConnectionClientInterface_RequestPermittedValueSets_Call struct { + *mock.Call +} + +// RequestPermittedValueSets is a helper method to define mock.On call +// - selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType +// - elements *model.ElectricalConnectionPermittedValueSetDataElementsType +func (_e *ElectricalConnectionClientInterface_Expecter) RequestPermittedValueSets(selector interface{}, elements interface{}) *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call { + return &ElectricalConnectionClientInterface_RequestPermittedValueSets_Call{Call: _e.mock.On("RequestPermittedValueSets", selector, elements)} +} + +func (_c *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call) Run(run func(selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType, elements *model.ElectricalConnectionPermittedValueSetDataElementsType)) *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.ElectricalConnectionPermittedValueSetListDataSelectorsType), args[1].(*model.ElectricalConnectionPermittedValueSetDataElementsType)) + }) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call) Return(_a0 *model.MsgCounterType, _a1 error) *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call) RunAndReturn(run func(*model.ElectricalConnectionPermittedValueSetListDataSelectorsType, *model.ElectricalConnectionPermittedValueSetDataElementsType) (*model.MsgCounterType, error)) *ElectricalConnectionClientInterface_RequestPermittedValueSets_Call { + _c.Call.Return(run) + return _c +} + +// NewElectricalConnectionClientInterface creates a new instance of ElectricalConnectionClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewElectricalConnectionClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ElectricalConnectionClientInterface { + mock := &ElectricalConnectionClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionCommonInterface.go new file mode 100644 index 0000000..6fb4402 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionCommonInterface.go @@ -0,0 +1,565 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// ElectricalConnectionCommonInterface is an autogenerated mock type for the ElectricalConnectionCommonInterface type +type ElectricalConnectionCommonInterface struct { + mock.Mock +} + +type ElectricalConnectionCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ElectricalConnectionCommonInterface) EXPECT() *ElectricalConnectionCommonInterface_Expecter { + return &ElectricalConnectionCommonInterface_Expecter{mock: &_m.Mock} +} + +// AdjustValueToBeWithinPermittedValuesForParameterId provides a mock function with given fields: value, parameterId +func (_m *ElectricalConnectionCommonInterface) AdjustValueToBeWithinPermittedValuesForParameterId(value float64, parameterId model.ElectricalConnectionParameterIdType) float64 { + ret := _m.Called(value, parameterId) + + if len(ret) == 0 { + panic("no return value specified for AdjustValueToBeWithinPermittedValuesForParameterId") + } + + var r0 float64 + if rf, ok := ret.Get(0).(func(float64, model.ElectricalConnectionParameterIdType) float64); ok { + r0 = rf(value, parameterId) + } else { + r0 = ret.Get(0).(float64) + } + + return r0 +} + +// ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AdjustValueToBeWithinPermittedValuesForParameterId' +type ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call struct { + *mock.Call +} + +// AdjustValueToBeWithinPermittedValuesForParameterId is a helper method to define mock.On call +// - value float64 +// - parameterId model.ElectricalConnectionParameterIdType +func (_e *ElectricalConnectionCommonInterface_Expecter) AdjustValueToBeWithinPermittedValuesForParameterId(value interface{}, parameterId interface{}) *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + return &ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call{Call: _e.mock.On("AdjustValueToBeWithinPermittedValuesForParameterId", value, parameterId)} +} + +func (_c *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) Run(run func(value float64, parameterId model.ElectricalConnectionParameterIdType)) *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(model.ElectricalConnectionParameterIdType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) Return(_a0 float64) *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) RunAndReturn(run func(float64, model.ElectricalConnectionParameterIdType) float64) *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Return(run) + return _c +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *ElectricalConnectionCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *ElectricalConnectionCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { + return &ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetCharacteristicsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetCharacteristicsForFilter(filter model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetCharacteristicsForFilter") + } + + var r0 []model.ElectricalConnectionCharacteristicDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) []model.ElectricalConnectionCharacteristicDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionCharacteristicDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionCharacteristicDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCharacteristicsForFilter' +type ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call struct { + *mock.Call +} + +// GetCharacteristicsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionCharacteristicDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetCharacteristicsForFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call { + return &ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call{Call: _e.mock.On("GetCharacteristicsForFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call) Run(run func(filter model.ElectricalConnectionCharacteristicDataType)) *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionCharacteristicDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call) Return(_a0 []model.ElectricalConnectionCharacteristicDataType, _a1 error) *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error)) *ElectricalConnectionCommonInterface_GetCharacteristicsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionForParameterDescriptionFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetDescriptionForParameterDescriptionFilter(filter model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionForParameterDescriptionFilter") + } + + var r0 *model.ElectricalConnectionDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) *model.ElectricalConnectionDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ElectricalConnectionDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionParameterDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionForParameterDescriptionFilter' +type ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call struct { + *mock.Call +} + +// GetDescriptionForParameterDescriptionFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionParameterDescriptionDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetDescriptionForParameterDescriptionFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call { + return &ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call{Call: _e.mock.On("GetDescriptionForParameterDescriptionFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call) Run(run func(filter model.ElectricalConnectionParameterDescriptionDataType)) *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionParameterDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call) Return(_a0 *model.ElectricalConnectionDescriptionDataType, _a1 error) *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call) RunAndReturn(run func(model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error)) *ElectricalConnectionCommonInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetDescriptionsForFilter(filter model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionsForFilter") + } + + var r0 []model.ElectricalConnectionDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionDescriptionDataType) []model.ElectricalConnectionDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionsForFilter' +type ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetDescriptionsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionDescriptionDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetDescriptionsForFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call { + return &ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call{Call: _e.mock.On("GetDescriptionsForFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call) Run(run func(filter model.ElectricalConnectionDescriptionDataType)) *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call) Return(_a0 []model.ElectricalConnectionDescriptionDataType, _a1 error) *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error)) *ElectricalConnectionCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetParameterDescriptionsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetParameterDescriptionsForFilter(filter model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetParameterDescriptionsForFilter") + } + + var r0 []model.ElectricalConnectionParameterDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) []model.ElectricalConnectionParameterDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionParameterDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionParameterDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetParameterDescriptionsForFilter' +type ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetParameterDescriptionsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionParameterDescriptionDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetParameterDescriptionsForFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call { + return &ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call{Call: _e.mock.On("GetParameterDescriptionsForFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call) Run(run func(filter model.ElectricalConnectionParameterDescriptionDataType)) *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionParameterDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call) Return(_a0 []model.ElectricalConnectionParameterDescriptionDataType, _a1 error) *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error)) *ElectricalConnectionCommonInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPermittedValueDataForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetPermittedValueDataForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetPermittedValueDataForFilter") + } + + var r0 float64 + var r1 float64 + var r2 float64 + var r3 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r0 = rf(filter) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r1 = rf(filter) + } else { + r1 = ret.Get(1).(float64) + } + + if rf, ok := ret.Get(2).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r2 = rf(filter) + } else { + r2 = ret.Get(2).(float64) + } + + if rf, ok := ret.Get(3).(func(model.ElectricalConnectionPermittedValueSetDataType) error); ok { + r3 = rf(filter) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPermittedValueDataForFilter' +type ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call struct { + *mock.Call +} + +// GetPermittedValueDataForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionPermittedValueSetDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetPermittedValueDataForFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call { + return &ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call{Call: _e.mock.On("GetPermittedValueDataForFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call) Run(run func(filter model.ElectricalConnectionPermittedValueSetDataType)) *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionPermittedValueSetDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call) Return(_a0 float64, _a1 float64, _a2 float64, _a3 error) *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error)) *ElectricalConnectionCommonInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPermittedValueSetForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionCommonInterface) GetPermittedValueSetForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetPermittedValueSetForFilter") + } + + var r0 []model.ElectricalConnectionPermittedValueSetDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) []model.ElectricalConnectionPermittedValueSetDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionPermittedValueSetDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionPermittedValueSetDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPermittedValueSetForFilter' +type ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call struct { + *mock.Call +} + +// GetPermittedValueSetForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionPermittedValueSetDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetPermittedValueSetForFilter(filter interface{}) *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call { + return &ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call{Call: _e.mock.On("GetPermittedValueSetForFilter", filter)} +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call) Run(run func(filter model.ElectricalConnectionPermittedValueSetDataType)) *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionPermittedValueSetDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call) Return(_a0 []model.ElectricalConnectionPermittedValueSetDataType, _a1 error) *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error)) *ElectricalConnectionCommonInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPhaseCurrentLimits provides a mock function with given fields: measDesc +func (_m *ElectricalConnectionCommonInterface) GetPhaseCurrentLimits(measDesc []model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error) { + ret := _m.Called(measDesc) + + if len(ret) == 0 { + panic("no return value specified for GetPhaseCurrentLimits") + } + + var r0 []float64 + var r1 []float64 + var r2 []float64 + var r3 error + if rf, ok := ret.Get(0).(func([]model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error)); ok { + return rf(measDesc) + } + if rf, ok := ret.Get(0).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r0 = rf(measDesc) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r1 = rf(measDesc) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]float64) + } + } + + if rf, ok := ret.Get(2).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r2 = rf(measDesc) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([]float64) + } + } + + if rf, ok := ret.Get(3).(func([]model.MeasurementDescriptionDataType) error); ok { + r3 = rf(measDesc) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPhaseCurrentLimits' +type ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call struct { + *mock.Call +} + +// GetPhaseCurrentLimits is a helper method to define mock.On call +// - measDesc []model.MeasurementDescriptionDataType +func (_e *ElectricalConnectionCommonInterface_Expecter) GetPhaseCurrentLimits(measDesc interface{}) *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call { + return &ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call{Call: _e.mock.On("GetPhaseCurrentLimits", measDesc)} +} + +func (_c *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call) Run(run func(measDesc []model.MeasurementDescriptionDataType)) *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call) Return(resultMin []float64, resultMax []float64, resultDefault []float64, resultErr error) *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call { + _c.Call.Return(resultMin, resultMax, resultDefault, resultErr) + return _c +} + +func (_c *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call) RunAndReturn(run func([]model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error)) *ElectricalConnectionCommonInterface_GetPhaseCurrentLimits_Call { + _c.Call.Return(run) + return _c +} + +// NewElectricalConnectionCommonInterface creates a new instance of ElectricalConnectionCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewElectricalConnectionCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ElectricalConnectionCommonInterface { + mock := &ElectricalConnectionCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionServerInterface.go new file mode 100644 index 0000000..888f60a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/ElectricalConnectionServerInterface.go @@ -0,0 +1,764 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// ElectricalConnectionServerInterface is an autogenerated mock type for the ElectricalConnectionServerInterface type +type ElectricalConnectionServerInterface struct { + mock.Mock +} + +type ElectricalConnectionServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ElectricalConnectionServerInterface) EXPECT() *ElectricalConnectionServerInterface_Expecter { + return &ElectricalConnectionServerInterface_Expecter{mock: &_m.Mock} +} + +// AddCharacteristic provides a mock function with given fields: data +func (_m *ElectricalConnectionServerInterface) AddCharacteristic(data model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for AddCharacteristic") + } + + var r0 *model.ElectricalConnectionCharacteristicIdType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) *model.ElectricalConnectionCharacteristicIdType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ElectricalConnectionCharacteristicIdType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionCharacteristicDataType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_AddCharacteristic_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddCharacteristic' +type ElectricalConnectionServerInterface_AddCharacteristic_Call struct { + *mock.Call +} + +// AddCharacteristic is a helper method to define mock.On call +// - data model.ElectricalConnectionCharacteristicDataType +func (_e *ElectricalConnectionServerInterface_Expecter) AddCharacteristic(data interface{}) *ElectricalConnectionServerInterface_AddCharacteristic_Call { + return &ElectricalConnectionServerInterface_AddCharacteristic_Call{Call: _e.mock.On("AddCharacteristic", data)} +} + +func (_c *ElectricalConnectionServerInterface_AddCharacteristic_Call) Run(run func(data model.ElectricalConnectionCharacteristicDataType)) *ElectricalConnectionServerInterface_AddCharacteristic_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionCharacteristicDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddCharacteristic_Call) Return(_a0 *model.ElectricalConnectionCharacteristicIdType, _a1 error) *ElectricalConnectionServerInterface_AddCharacteristic_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddCharacteristic_Call) RunAndReturn(run func(model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error)) *ElectricalConnectionServerInterface_AddCharacteristic_Call { + _c.Call.Return(run) + return _c +} + +// AddDescription provides a mock function with given fields: description +func (_m *ElectricalConnectionServerInterface) AddDescription(description model.ElectricalConnectionDescriptionDataType) error { + ret := _m.Called(description) + + if len(ret) == 0 { + panic("no return value specified for AddDescription") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionDescriptionDataType) error); ok { + r0 = rf(description) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ElectricalConnectionServerInterface_AddDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddDescription' +type ElectricalConnectionServerInterface_AddDescription_Call struct { + *mock.Call +} + +// AddDescription is a helper method to define mock.On call +// - description model.ElectricalConnectionDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) AddDescription(description interface{}) *ElectricalConnectionServerInterface_AddDescription_Call { + return &ElectricalConnectionServerInterface_AddDescription_Call{Call: _e.mock.On("AddDescription", description)} +} + +func (_c *ElectricalConnectionServerInterface_AddDescription_Call) Run(run func(description model.ElectricalConnectionDescriptionDataType)) *ElectricalConnectionServerInterface_AddDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddDescription_Call) Return(_a0 error) *ElectricalConnectionServerInterface_AddDescription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddDescription_Call) RunAndReturn(run func(model.ElectricalConnectionDescriptionDataType) error) *ElectricalConnectionServerInterface_AddDescription_Call { + _c.Call.Return(run) + return _c +} + +// AddParameterDescription provides a mock function with given fields: description +func (_m *ElectricalConnectionServerInterface) AddParameterDescription(description model.ElectricalConnectionParameterDescriptionDataType) *model.ElectricalConnectionParameterIdType { + ret := _m.Called(description) + + if len(ret) == 0 { + panic("no return value specified for AddParameterDescription") + } + + var r0 *model.ElectricalConnectionParameterIdType + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) *model.ElectricalConnectionParameterIdType); ok { + r0 = rf(description) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ElectricalConnectionParameterIdType) + } + } + + return r0 +} + +// ElectricalConnectionServerInterface_AddParameterDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddParameterDescription' +type ElectricalConnectionServerInterface_AddParameterDescription_Call struct { + *mock.Call +} + +// AddParameterDescription is a helper method to define mock.On call +// - description model.ElectricalConnectionParameterDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) AddParameterDescription(description interface{}) *ElectricalConnectionServerInterface_AddParameterDescription_Call { + return &ElectricalConnectionServerInterface_AddParameterDescription_Call{Call: _e.mock.On("AddParameterDescription", description)} +} + +func (_c *ElectricalConnectionServerInterface_AddParameterDescription_Call) Run(run func(description model.ElectricalConnectionParameterDescriptionDataType)) *ElectricalConnectionServerInterface_AddParameterDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionParameterDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddParameterDescription_Call) Return(_a0 *model.ElectricalConnectionParameterIdType) *ElectricalConnectionServerInterface_AddParameterDescription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AddParameterDescription_Call) RunAndReturn(run func(model.ElectricalConnectionParameterDescriptionDataType) *model.ElectricalConnectionParameterIdType) *ElectricalConnectionServerInterface_AddParameterDescription_Call { + _c.Call.Return(run) + return _c +} + +// AdjustValueToBeWithinPermittedValuesForParameterId provides a mock function with given fields: value, parameterId +func (_m *ElectricalConnectionServerInterface) AdjustValueToBeWithinPermittedValuesForParameterId(value float64, parameterId model.ElectricalConnectionParameterIdType) float64 { + ret := _m.Called(value, parameterId) + + if len(ret) == 0 { + panic("no return value specified for AdjustValueToBeWithinPermittedValuesForParameterId") + } + + var r0 float64 + if rf, ok := ret.Get(0).(func(float64, model.ElectricalConnectionParameterIdType) float64); ok { + r0 = rf(value, parameterId) + } else { + r0 = ret.Get(0).(float64) + } + + return r0 +} + +// ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AdjustValueToBeWithinPermittedValuesForParameterId' +type ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call struct { + *mock.Call +} + +// AdjustValueToBeWithinPermittedValuesForParameterId is a helper method to define mock.On call +// - value float64 +// - parameterId model.ElectricalConnectionParameterIdType +func (_e *ElectricalConnectionServerInterface_Expecter) AdjustValueToBeWithinPermittedValuesForParameterId(value interface{}, parameterId interface{}) *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + return &ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call{Call: _e.mock.On("AdjustValueToBeWithinPermittedValuesForParameterId", value, parameterId)} +} + +func (_c *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) Run(run func(value float64, parameterId model.ElectricalConnectionParameterIdType)) *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(model.ElectricalConnectionParameterIdType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) Return(_a0 float64) *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call) RunAndReturn(run func(float64, model.ElectricalConnectionParameterIdType) float64) *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValuesForParameterId_Call { + _c.Call.Return(run) + return _c +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *ElectricalConnectionServerInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *ElectricalConnectionServerInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { + return &ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetCharacteristicsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetCharacteristicsForFilter(filter model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetCharacteristicsForFilter") + } + + var r0 []model.ElectricalConnectionCharacteristicDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType) []model.ElectricalConnectionCharacteristicDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionCharacteristicDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionCharacteristicDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCharacteristicsForFilter' +type ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call struct { + *mock.Call +} + +// GetCharacteristicsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionCharacteristicDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetCharacteristicsForFilter(filter interface{}) *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call { + return &ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call{Call: _e.mock.On("GetCharacteristicsForFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call) Run(run func(filter model.ElectricalConnectionCharacteristicDataType)) *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionCharacteristicDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call) Return(_a0 []model.ElectricalConnectionCharacteristicDataType, _a1 error) *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionCharacteristicDataType) ([]model.ElectricalConnectionCharacteristicDataType, error)) *ElectricalConnectionServerInterface_GetCharacteristicsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionForParameterDescriptionFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetDescriptionForParameterDescriptionFilter(filter model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionForParameterDescriptionFilter") + } + + var r0 *model.ElectricalConnectionDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) *model.ElectricalConnectionDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ElectricalConnectionDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionParameterDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionForParameterDescriptionFilter' +type ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call struct { + *mock.Call +} + +// GetDescriptionForParameterDescriptionFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionParameterDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetDescriptionForParameterDescriptionFilter(filter interface{}) *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call { + return &ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call{Call: _e.mock.On("GetDescriptionForParameterDescriptionFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call) Run(run func(filter model.ElectricalConnectionParameterDescriptionDataType)) *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionParameterDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call) Return(_a0 *model.ElectricalConnectionDescriptionDataType, _a1 error) *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call) RunAndReturn(run func(model.ElectricalConnectionParameterDescriptionDataType) (*model.ElectricalConnectionDescriptionDataType, error)) *ElectricalConnectionServerInterface_GetDescriptionForParameterDescriptionFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetDescriptionsForFilter(filter model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionsForFilter") + } + + var r0 []model.ElectricalConnectionDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionDescriptionDataType) []model.ElectricalConnectionDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionsForFilter' +type ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetDescriptionsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetDescriptionsForFilter(filter interface{}) *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call { + return &ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call{Call: _e.mock.On("GetDescriptionsForFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call) Run(run func(filter model.ElectricalConnectionDescriptionDataType)) *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call) Return(_a0 []model.ElectricalConnectionDescriptionDataType, _a1 error) *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionDescriptionDataType) ([]model.ElectricalConnectionDescriptionDataType, error)) *ElectricalConnectionServerInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetParameterDescriptionsForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetParameterDescriptionsForFilter(filter model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetParameterDescriptionsForFilter") + } + + var r0 []model.ElectricalConnectionParameterDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionParameterDescriptionDataType) []model.ElectricalConnectionParameterDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionParameterDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionParameterDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetParameterDescriptionsForFilter' +type ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetParameterDescriptionsForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionParameterDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetParameterDescriptionsForFilter(filter interface{}) *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call { + return &ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call{Call: _e.mock.On("GetParameterDescriptionsForFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call) Run(run func(filter model.ElectricalConnectionParameterDescriptionDataType)) *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionParameterDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call) Return(_a0 []model.ElectricalConnectionParameterDescriptionDataType, _a1 error) *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionParameterDescriptionDataType) ([]model.ElectricalConnectionParameterDescriptionDataType, error)) *ElectricalConnectionServerInterface_GetParameterDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPermittedValueDataForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetPermittedValueDataForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetPermittedValueDataForFilter") + } + + var r0 float64 + var r1 float64 + var r2 float64 + var r3 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r0 = rf(filter) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r1 = rf(filter) + } else { + r1 = ret.Get(1).(float64) + } + + if rf, ok := ret.Get(2).(func(model.ElectricalConnectionPermittedValueSetDataType) float64); ok { + r2 = rf(filter) + } else { + r2 = ret.Get(2).(float64) + } + + if rf, ok := ret.Get(3).(func(model.ElectricalConnectionPermittedValueSetDataType) error); ok { + r3 = rf(filter) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPermittedValueDataForFilter' +type ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call struct { + *mock.Call +} + +// GetPermittedValueDataForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionPermittedValueSetDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetPermittedValueDataForFilter(filter interface{}) *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call { + return &ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call{Call: _e.mock.On("GetPermittedValueDataForFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call) Run(run func(filter model.ElectricalConnectionPermittedValueSetDataType)) *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionPermittedValueSetDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call) Return(_a0 float64, _a1 float64, _a2 float64, _a3 error) *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionPermittedValueSetDataType) (float64, float64, float64, error)) *ElectricalConnectionServerInterface_GetPermittedValueDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPermittedValueSetForFilter provides a mock function with given fields: filter +func (_m *ElectricalConnectionServerInterface) GetPermittedValueSetForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetPermittedValueSetForFilter") + } + + var r0 []model.ElectricalConnectionPermittedValueSetDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionPermittedValueSetDataType) []model.ElectricalConnectionPermittedValueSetDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.ElectricalConnectionPermittedValueSetDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.ElectricalConnectionPermittedValueSetDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPermittedValueSetForFilter' +type ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call struct { + *mock.Call +} + +// GetPermittedValueSetForFilter is a helper method to define mock.On call +// - filter model.ElectricalConnectionPermittedValueSetDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetPermittedValueSetForFilter(filter interface{}) *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call { + return &ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call{Call: _e.mock.On("GetPermittedValueSetForFilter", filter)} +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call) Run(run func(filter model.ElectricalConnectionPermittedValueSetDataType)) *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionPermittedValueSetDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call) Return(_a0 []model.ElectricalConnectionPermittedValueSetDataType, _a1 error) *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call) RunAndReturn(run func(model.ElectricalConnectionPermittedValueSetDataType) ([]model.ElectricalConnectionPermittedValueSetDataType, error)) *ElectricalConnectionServerInterface_GetPermittedValueSetForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetPhaseCurrentLimits provides a mock function with given fields: measDesc +func (_m *ElectricalConnectionServerInterface) GetPhaseCurrentLimits(measDesc []model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error) { + ret := _m.Called(measDesc) + + if len(ret) == 0 { + panic("no return value specified for GetPhaseCurrentLimits") + } + + var r0 []float64 + var r1 []float64 + var r2 []float64 + var r3 error + if rf, ok := ret.Get(0).(func([]model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error)); ok { + return rf(measDesc) + } + if rf, ok := ret.Get(0).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r0 = rf(measDesc) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r1 = rf(measDesc) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]float64) + } + } + + if rf, ok := ret.Get(2).(func([]model.MeasurementDescriptionDataType) []float64); ok { + r2 = rf(measDesc) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([]float64) + } + } + + if rf, ok := ret.Get(3).(func([]model.MeasurementDescriptionDataType) error); ok { + r3 = rf(measDesc) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPhaseCurrentLimits' +type ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call struct { + *mock.Call +} + +// GetPhaseCurrentLimits is a helper method to define mock.On call +// - measDesc []model.MeasurementDescriptionDataType +func (_e *ElectricalConnectionServerInterface_Expecter) GetPhaseCurrentLimits(measDesc interface{}) *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call { + return &ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call{Call: _e.mock.On("GetPhaseCurrentLimits", measDesc)} +} + +func (_c *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call) Run(run func(measDesc []model.MeasurementDescriptionDataType)) *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call) Return(resultMin []float64, resultMax []float64, resultDefault []float64, resultErr error) *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call { + _c.Call.Return(resultMin, resultMax, resultDefault, resultErr) + return _c +} + +func (_c *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call) RunAndReturn(run func([]model.MeasurementDescriptionDataType) ([]float64, []float64, []float64, error)) *ElectricalConnectionServerInterface_GetPhaseCurrentLimits_Call { + _c.Call.Return(run) + return _c +} + +// UpdateCharacteristic provides a mock function with given fields: data, deleteElements +func (_m *ElectricalConnectionServerInterface) UpdateCharacteristic(data model.ElectricalConnectionCharacteristicDataType, deleteElements *model.ElectricalConnectionCharacteristicDataElementsType) error { + ret := _m.Called(data, deleteElements) + + if len(ret) == 0 { + panic("no return value specified for UpdateCharacteristic") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.ElectricalConnectionCharacteristicDataType, *model.ElectricalConnectionCharacteristicDataElementsType) error); ok { + r0 = rf(data, deleteElements) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ElectricalConnectionServerInterface_UpdateCharacteristic_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCharacteristic' +type ElectricalConnectionServerInterface_UpdateCharacteristic_Call struct { + *mock.Call +} + +// UpdateCharacteristic is a helper method to define mock.On call +// - data model.ElectricalConnectionCharacteristicDataType +// - deleteElements *model.ElectricalConnectionCharacteristicDataElementsType +func (_e *ElectricalConnectionServerInterface_Expecter) UpdateCharacteristic(data interface{}, deleteElements interface{}) *ElectricalConnectionServerInterface_UpdateCharacteristic_Call { + return &ElectricalConnectionServerInterface_UpdateCharacteristic_Call{Call: _e.mock.On("UpdateCharacteristic", data, deleteElements)} +} + +func (_c *ElectricalConnectionServerInterface_UpdateCharacteristic_Call) Run(run func(data model.ElectricalConnectionCharacteristicDataType, deleteElements *model.ElectricalConnectionCharacteristicDataElementsType)) *ElectricalConnectionServerInterface_UpdateCharacteristic_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.ElectricalConnectionCharacteristicDataType), args[1].(*model.ElectricalConnectionCharacteristicDataElementsType)) + }) + return _c +} + +func (_c *ElectricalConnectionServerInterface_UpdateCharacteristic_Call) Return(_a0 error) *ElectricalConnectionServerInterface_UpdateCharacteristic_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ElectricalConnectionServerInterface_UpdateCharacteristic_Call) RunAndReturn(run func(model.ElectricalConnectionCharacteristicDataType, *model.ElectricalConnectionCharacteristicDataElementsType) error) *ElectricalConnectionServerInterface_UpdateCharacteristic_Call { + _c.Call.Return(run) + return _c +} + +// NewElectricalConnectionServerInterface creates a new instance of ElectricalConnectionServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewElectricalConnectionServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ElectricalConnectionServerInterface { + mock := &ElectricalConnectionServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/EntityEventCallback.go b/src/eebus-bridge/third_party/eebus-go/mocks/EntityEventCallback.go new file mode 100644 index 0000000..042ca19 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/EntityEventCallback.go @@ -0,0 +1,73 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/spine-go/api" + + mock "github.com/stretchr/testify/mock" +) + +// EntityEventCallback is an autogenerated mock type for the EntityEventCallback type +type EntityEventCallback struct { + mock.Mock +} + +type EntityEventCallback_Expecter struct { + mock *mock.Mock +} + +func (_m *EntityEventCallback) EXPECT() *EntityEventCallback_Expecter { + return &EntityEventCallback_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: ski, device, entity, event +func (_m *EntityEventCallback) Execute(ski string, device api.DeviceRemoteInterface, entity api.EntityRemoteInterface, event eebus_goapi.EventType) { + _m.Called(ski, device, entity, event) +} + +// EntityEventCallback_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type EntityEventCallback_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - ski string +// - device api.DeviceRemoteInterface +// - entity api.EntityRemoteInterface +// - event eebus_goapi.EventType +func (_e *EntityEventCallback_Expecter) Execute(ski interface{}, device interface{}, entity interface{}, event interface{}) *EntityEventCallback_Execute_Call { + return &EntityEventCallback_Execute_Call{Call: _e.mock.On("Execute", ski, device, entity, event)} +} + +func (_c *EntityEventCallback_Execute_Call) Run(run func(ski string, device api.DeviceRemoteInterface, entity api.EntityRemoteInterface, event eebus_goapi.EventType)) *EntityEventCallback_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(api.DeviceRemoteInterface), args[2].(api.EntityRemoteInterface), args[3].(eebus_goapi.EventType)) + }) + return _c +} + +func (_c *EntityEventCallback_Execute_Call) Return() *EntityEventCallback_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityEventCallback_Execute_Call) RunAndReturn(run func(string, api.DeviceRemoteInterface, api.EntityRemoteInterface, eebus_goapi.EventType)) *EntityEventCallback_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewEntityEventCallback creates a new instance of EntityEventCallback. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEntityEventCallback(t interface { + mock.TestingT + Cleanup(func()) +}) *EntityEventCallback { + mock := &EntityEventCallback{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/FeatureClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureClientInterface.go new file mode 100644 index 0000000..d6ac99b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureClientInterface.go @@ -0,0 +1,322 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// FeatureClientInterface is an autogenerated mock type for the FeatureClientInterface type +type FeatureClientInterface struct { + mock.Mock +} + +type FeatureClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureClientInterface) EXPECT() *FeatureClientInterface_Expecter { + return &FeatureClientInterface_Expecter{mock: &_m.Mock} +} + +// AddResponseCallback provides a mock function with given fields: msgCounterReference, function +func (_m *FeatureClientInterface) AddResponseCallback(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage)) error { + ret := _m.Called(msgCounterReference, function) + + if len(ret) == 0 { + panic("no return value specified for AddResponseCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MsgCounterType, func(api.ResponseMessage)) error); ok { + r0 = rf(msgCounterReference, function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FeatureClientInterface_AddResponseCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResponseCallback' +type FeatureClientInterface_AddResponseCallback_Call struct { + *mock.Call +} + +// AddResponseCallback is a helper method to define mock.On call +// - msgCounterReference model.MsgCounterType +// - function func(api.ResponseMessage) +func (_e *FeatureClientInterface_Expecter) AddResponseCallback(msgCounterReference interface{}, function interface{}) *FeatureClientInterface_AddResponseCallback_Call { + return &FeatureClientInterface_AddResponseCallback_Call{Call: _e.mock.On("AddResponseCallback", msgCounterReference, function)} +} + +func (_c *FeatureClientInterface_AddResponseCallback_Call) Run(run func(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage))) *FeatureClientInterface_AddResponseCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureClientInterface_AddResponseCallback_Call) Return(_a0 error) *FeatureClientInterface_AddResponseCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureClientInterface_AddResponseCallback_Call) RunAndReturn(run func(model.MsgCounterType, func(api.ResponseMessage)) error) *FeatureClientInterface_AddResponseCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddResultCallback provides a mock function with given fields: function +func (_m *FeatureClientInterface) AddResultCallback(function func(api.ResponseMessage)) { + _m.Called(function) +} + +// FeatureClientInterface_AddResultCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResultCallback' +type FeatureClientInterface_AddResultCallback_Call struct { + *mock.Call +} + +// AddResultCallback is a helper method to define mock.On call +// - function func(api.ResponseMessage) +func (_e *FeatureClientInterface_Expecter) AddResultCallback(function interface{}) *FeatureClientInterface_AddResultCallback_Call { + return &FeatureClientInterface_AddResultCallback_Call{Call: _e.mock.On("AddResultCallback", function)} +} + +func (_c *FeatureClientInterface_AddResultCallback_Call) Run(run func(function func(api.ResponseMessage))) *FeatureClientInterface_AddResultCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureClientInterface_AddResultCallback_Call) Return() *FeatureClientInterface_AddResultCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureClientInterface_AddResultCallback_Call) RunAndReturn(run func(func(api.ResponseMessage))) *FeatureClientInterface_AddResultCallback_Call { + _c.Call.Return(run) + return _c +} + +// Bind provides a mock function with given fields: +func (_m *FeatureClientInterface) Bind() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Bind") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FeatureClientInterface_Bind_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bind' +type FeatureClientInterface_Bind_Call struct { + *mock.Call +} + +// Bind is a helper method to define mock.On call +func (_e *FeatureClientInterface_Expecter) Bind() *FeatureClientInterface_Bind_Call { + return &FeatureClientInterface_Bind_Call{Call: _e.mock.On("Bind")} +} + +func (_c *FeatureClientInterface_Bind_Call) Run(run func()) *FeatureClientInterface_Bind_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureClientInterface_Bind_Call) Return(_a0 *model.MsgCounterType, _a1 error) *FeatureClientInterface_Bind_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureClientInterface_Bind_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *FeatureClientInterface_Bind_Call { + _c.Call.Return(run) + return _c +} + +// HasBinding provides a mock function with given fields: +func (_m *FeatureClientInterface) HasBinding() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasBinding") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureClientInterface_HasBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasBinding' +type FeatureClientInterface_HasBinding_Call struct { + *mock.Call +} + +// HasBinding is a helper method to define mock.On call +func (_e *FeatureClientInterface_Expecter) HasBinding() *FeatureClientInterface_HasBinding_Call { + return &FeatureClientInterface_HasBinding_Call{Call: _e.mock.On("HasBinding")} +} + +func (_c *FeatureClientInterface_HasBinding_Call) Run(run func()) *FeatureClientInterface_HasBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureClientInterface_HasBinding_Call) Return(_a0 bool) *FeatureClientInterface_HasBinding_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureClientInterface_HasBinding_Call) RunAndReturn(run func() bool) *FeatureClientInterface_HasBinding_Call { + _c.Call.Return(run) + return _c +} + +// HasSubscription provides a mock function with given fields: +func (_m *FeatureClientInterface) HasSubscription() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasSubscription") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureClientInterface_HasSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasSubscription' +type FeatureClientInterface_HasSubscription_Call struct { + *mock.Call +} + +// HasSubscription is a helper method to define mock.On call +func (_e *FeatureClientInterface_Expecter) HasSubscription() *FeatureClientInterface_HasSubscription_Call { + return &FeatureClientInterface_HasSubscription_Call{Call: _e.mock.On("HasSubscription")} +} + +func (_c *FeatureClientInterface_HasSubscription_Call) Run(run func()) *FeatureClientInterface_HasSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureClientInterface_HasSubscription_Call) Return(_a0 bool) *FeatureClientInterface_HasSubscription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureClientInterface_HasSubscription_Call) RunAndReturn(run func() bool) *FeatureClientInterface_HasSubscription_Call { + _c.Call.Return(run) + return _c +} + +// Subscribe provides a mock function with given fields: +func (_m *FeatureClientInterface) Subscribe() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FeatureClientInterface_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe' +type FeatureClientInterface_Subscribe_Call struct { + *mock.Call +} + +// Subscribe is a helper method to define mock.On call +func (_e *FeatureClientInterface_Expecter) Subscribe() *FeatureClientInterface_Subscribe_Call { + return &FeatureClientInterface_Subscribe_Call{Call: _e.mock.On("Subscribe")} +} + +func (_c *FeatureClientInterface_Subscribe_Call) Run(run func()) *FeatureClientInterface_Subscribe_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureClientInterface_Subscribe_Call) Return(_a0 *model.MsgCounterType, _a1 error) *FeatureClientInterface_Subscribe_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureClientInterface_Subscribe_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *FeatureClientInterface_Subscribe_Call { + _c.Call.Return(run) + return _c +} + +// NewFeatureClientInterface creates a new instance of FeatureClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureClientInterface { + mock := &FeatureClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/FeatureInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureInterface.go new file mode 100644 index 0000000..6626b09 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureInterface.go @@ -0,0 +1,322 @@ +// Code generated by mockery v2.42.1. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// FeatureInterface is an autogenerated mock type for the FeatureInterface type +type FeatureInterface struct { + mock.Mock +} + +type FeatureInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureInterface) EXPECT() *FeatureInterface_Expecter { + return &FeatureInterface_Expecter{mock: &_m.Mock} +} + +// AddResponseCallback provides a mock function with given fields: msgCounterReference, function +func (_m *FeatureInterface) AddResponseCallback(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage)) error { + ret := _m.Called(msgCounterReference, function) + + if len(ret) == 0 { + panic("no return value specified for AddResponseCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MsgCounterType, func(api.ResponseMessage)) error); ok { + r0 = rf(msgCounterReference, function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FeatureInterface_AddResponseCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResponseCallback' +type FeatureInterface_AddResponseCallback_Call struct { + *mock.Call +} + +// AddResponseCallback is a helper method to define mock.On call +// - msgCounterReference model.MsgCounterType +// - function func(api.ResponseMessage) +func (_e *FeatureInterface_Expecter) AddResponseCallback(msgCounterReference interface{}, function interface{}) *FeatureInterface_AddResponseCallback_Call { + return &FeatureInterface_AddResponseCallback_Call{Call: _e.mock.On("AddResponseCallback", msgCounterReference, function)} +} + +func (_c *FeatureInterface_AddResponseCallback_Call) Run(run func(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage))) *FeatureInterface_AddResponseCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureInterface_AddResponseCallback_Call) Return(_a0 error) *FeatureInterface_AddResponseCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_AddResponseCallback_Call) RunAndReturn(run func(model.MsgCounterType, func(api.ResponseMessage)) error) *FeatureInterface_AddResponseCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddResultCallback provides a mock function with given fields: function +func (_m *FeatureInterface) AddResultCallback(function func(api.ResponseMessage)) { + _m.Called(function) +} + +// FeatureInterface_AddResultCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResultCallback' +type FeatureInterface_AddResultCallback_Call struct { + *mock.Call +} + +// AddResultCallback is a helper method to define mock.On call +// - function func(api.ResponseMessage) +func (_e *FeatureInterface_Expecter) AddResultCallback(function interface{}) *FeatureInterface_AddResultCallback_Call { + return &FeatureInterface_AddResultCallback_Call{Call: _e.mock.On("AddResultCallback", function)} +} + +func (_c *FeatureInterface_AddResultCallback_Call) Run(run func(function func(api.ResponseMessage))) *FeatureInterface_AddResultCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureInterface_AddResultCallback_Call) Return() *FeatureInterface_AddResultCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureInterface_AddResultCallback_Call) RunAndReturn(run func(func(api.ResponseMessage))) *FeatureInterface_AddResultCallback_Call { + _c.Call.Return(run) + return _c +} + +// Bind provides a mock function with given fields: +func (_m *FeatureInterface) Bind() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Bind") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FeatureInterface_Bind_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bind' +type FeatureInterface_Bind_Call struct { + *mock.Call +} + +// Bind is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Bind() *FeatureInterface_Bind_Call { + return &FeatureInterface_Bind_Call{Call: _e.mock.On("Bind")} +} + +func (_c *FeatureInterface_Bind_Call) Run(run func()) *FeatureInterface_Bind_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Bind_Call) Return(_a0 *model.MsgCounterType, _a1 error) *FeatureInterface_Bind_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureInterface_Bind_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *FeatureInterface_Bind_Call { + _c.Call.Return(run) + return _c +} + +// HasBinding provides a mock function with given fields: +func (_m *FeatureInterface) HasBinding() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasBinding") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureInterface_HasBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasBinding' +type FeatureInterface_HasBinding_Call struct { + *mock.Call +} + +// HasBinding is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) HasBinding() *FeatureInterface_HasBinding_Call { + return &FeatureInterface_HasBinding_Call{Call: _e.mock.On("HasBinding")} +} + +func (_c *FeatureInterface_HasBinding_Call) Run(run func()) *FeatureInterface_HasBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_HasBinding_Call) Return(_a0 bool) *FeatureInterface_HasBinding_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_HasBinding_Call) RunAndReturn(run func() bool) *FeatureInterface_HasBinding_Call { + _c.Call.Return(run) + return _c +} + +// HasSubscription provides a mock function with given fields: +func (_m *FeatureInterface) HasSubscription() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HasSubscription") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureInterface_HasSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasSubscription' +type FeatureInterface_HasSubscription_Call struct { + *mock.Call +} + +// HasSubscription is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) HasSubscription() *FeatureInterface_HasSubscription_Call { + return &FeatureInterface_HasSubscription_Call{Call: _e.mock.On("HasSubscription")} +} + +func (_c *FeatureInterface_HasSubscription_Call) Run(run func()) *FeatureInterface_HasSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_HasSubscription_Call) Return(_a0 bool) *FeatureInterface_HasSubscription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_HasSubscription_Call) RunAndReturn(run func() bool) *FeatureInterface_HasSubscription_Call { + _c.Call.Return(run) + return _c +} + +// Subscribe provides a mock function with given fields: +func (_m *FeatureInterface) Subscribe() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// FeatureInterface_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe' +type FeatureInterface_Subscribe_Call struct { + *mock.Call +} + +// Subscribe is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Subscribe() *FeatureInterface_Subscribe_Call { + return &FeatureInterface_Subscribe_Call{Call: _e.mock.On("Subscribe")} +} + +func (_c *FeatureInterface_Subscribe_Call) Run(run func()) *FeatureInterface_Subscribe_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Subscribe_Call) Return(_a0 *model.MsgCounterType, _a1 error) *FeatureInterface_Subscribe_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureInterface_Subscribe_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *FeatureInterface_Subscribe_Call { + _c.Call.Return(run) + return _c +} + +// NewFeatureInterface creates a new instance of FeatureInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureInterface { + mock := &FeatureInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/FeatureServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureServerInterface.go new file mode 100644 index 0000000..32cf51d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/FeatureServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// FeatureServerInterface is an autogenerated mock type for the FeatureServerInterface type +type FeatureServerInterface struct { + mock.Mock +} + +type FeatureServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureServerInterface) EXPECT() *FeatureServerInterface_Expecter { + return &FeatureServerInterface_Expecter{mock: &_m.Mock} +} + +// NewFeatureServerInterface creates a new instance of FeatureServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureServerInterface { + mock := &FeatureServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationClientInterface.go new file mode 100644 index 0000000..a58d983 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationClientInterface.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// IdentificationClientInterface is an autogenerated mock type for the IdentificationClientInterface type +type IdentificationClientInterface struct { + mock.Mock +} + +type IdentificationClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IdentificationClientInterface) EXPECT() *IdentificationClientInterface_Expecter { + return &IdentificationClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestValues provides a mock function with given fields: +func (_m *IdentificationClientInterface) RequestValues() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestValues") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IdentificationClientInterface_RequestValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestValues' +type IdentificationClientInterface_RequestValues_Call struct { + *mock.Call +} + +// RequestValues is a helper method to define mock.On call +func (_e *IdentificationClientInterface_Expecter) RequestValues() *IdentificationClientInterface_RequestValues_Call { + return &IdentificationClientInterface_RequestValues_Call{Call: _e.mock.On("RequestValues")} +} + +func (_c *IdentificationClientInterface_RequestValues_Call) Run(run func()) *IdentificationClientInterface_RequestValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IdentificationClientInterface_RequestValues_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IdentificationClientInterface_RequestValues_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IdentificationClientInterface_RequestValues_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *IdentificationClientInterface_RequestValues_Call { + _c.Call.Return(run) + return _c +} + +// NewIdentificationClientInterface creates a new instance of IdentificationClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIdentificationClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IdentificationClientInterface { + mock := &IdentificationClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationCommonInterface.go new file mode 100644 index 0000000..fa18d8a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationCommonInterface.go @@ -0,0 +1,139 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// IdentificationCommonInterface is an autogenerated mock type for the IdentificationCommonInterface type +type IdentificationCommonInterface struct { + mock.Mock +} + +type IdentificationCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IdentificationCommonInterface) EXPECT() *IdentificationCommonInterface_Expecter { + return &IdentificationCommonInterface_Expecter{mock: &_m.Mock} +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData +func (_m *IdentificationCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}) bool { + ret := _m.Called(payloadData) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}) bool); ok { + r0 = rf(payloadData) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +func (_e *IdentificationCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { + return &IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData)} +} + +func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{})) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{})) + }) + return _c +} + +func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}) bool) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDataForFilter provides a mock function with given fields: filter +func (_m *IdentificationCommonInterface) GetDataForFilter(filter model.IdentificationDataType) ([]model.IdentificationDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDataForFilter") + } + + var r0 []model.IdentificationDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.IdentificationDataType) ([]model.IdentificationDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.IdentificationDataType) []model.IdentificationDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.IdentificationDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.IdentificationDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IdentificationCommonInterface_GetDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDataForFilter' +type IdentificationCommonInterface_GetDataForFilter_Call struct { + *mock.Call +} + +// GetDataForFilter is a helper method to define mock.On call +// - filter model.IdentificationDataType +func (_e *IdentificationCommonInterface_Expecter) GetDataForFilter(filter interface{}) *IdentificationCommonInterface_GetDataForFilter_Call { + return &IdentificationCommonInterface_GetDataForFilter_Call{Call: _e.mock.On("GetDataForFilter", filter)} +} + +func (_c *IdentificationCommonInterface_GetDataForFilter_Call) Run(run func(filter model.IdentificationDataType)) *IdentificationCommonInterface_GetDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.IdentificationDataType)) + }) + return _c +} + +func (_c *IdentificationCommonInterface_GetDataForFilter_Call) Return(_a0 []model.IdentificationDataType, _a1 error) *IdentificationCommonInterface_GetDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IdentificationCommonInterface_GetDataForFilter_Call) RunAndReturn(run func(model.IdentificationDataType) ([]model.IdentificationDataType, error)) *IdentificationCommonInterface_GetDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewIdentificationCommonInterface creates a new instance of IdentificationCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIdentificationCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IdentificationCommonInterface { + mock := &IdentificationCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationServerInterface.go new file mode 100644 index 0000000..19acc2b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IdentificationServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// IdentificationServerInterface is an autogenerated mock type for the IdentificationServerInterface type +type IdentificationServerInterface struct { + mock.Mock +} + +type IdentificationServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IdentificationServerInterface) EXPECT() *IdentificationServerInterface_Expecter { + return &IdentificationServerInterface_Expecter{mock: &_m.Mock} +} + +// NewIdentificationServerInterface creates a new instance of IdentificationServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIdentificationServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IdentificationServerInterface { + mock := &IdentificationServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableClientInterface.go new file mode 100644 index 0000000..a392e22 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableClientInterface.go @@ -0,0 +1,322 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// IncentiveTableClientInterface is an autogenerated mock type for the IncentiveTableClientInterface type +type IncentiveTableClientInterface struct { + mock.Mock +} + +type IncentiveTableClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IncentiveTableClientInterface) EXPECT() *IncentiveTableClientInterface_Expecter { + return &IncentiveTableClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestConstraints provides a mock function with given fields: +func (_m *IncentiveTableClientInterface) RequestConstraints() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestConstraints") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableClientInterface_RequestConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestConstraints' +type IncentiveTableClientInterface_RequestConstraints_Call struct { + *mock.Call +} + +// RequestConstraints is a helper method to define mock.On call +func (_e *IncentiveTableClientInterface_Expecter) RequestConstraints() *IncentiveTableClientInterface_RequestConstraints_Call { + return &IncentiveTableClientInterface_RequestConstraints_Call{Call: _e.mock.On("RequestConstraints")} +} + +func (_c *IncentiveTableClientInterface_RequestConstraints_Call) Run(run func()) *IncentiveTableClientInterface_RequestConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestConstraints_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IncentiveTableClientInterface_RequestConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestConstraints_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *IncentiveTableClientInterface_RequestConstraints_Call { + _c.Call.Return(run) + return _c +} + +// RequestDescriptions provides a mock function with given fields: +func (_m *IncentiveTableClientInterface) RequestDescriptions() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableClientInterface_RequestDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestDescriptions' +type IncentiveTableClientInterface_RequestDescriptions_Call struct { + *mock.Call +} + +// RequestDescriptions is a helper method to define mock.On call +func (_e *IncentiveTableClientInterface_Expecter) RequestDescriptions() *IncentiveTableClientInterface_RequestDescriptions_Call { + return &IncentiveTableClientInterface_RequestDescriptions_Call{Call: _e.mock.On("RequestDescriptions")} +} + +func (_c *IncentiveTableClientInterface_RequestDescriptions_Call) Run(run func()) *IncentiveTableClientInterface_RequestDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IncentiveTableClientInterface_RequestDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestDescriptions_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *IncentiveTableClientInterface_RequestDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// RequestValues provides a mock function with given fields: +func (_m *IncentiveTableClientInterface) RequestValues() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestValues") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableClientInterface_RequestValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestValues' +type IncentiveTableClientInterface_RequestValues_Call struct { + *mock.Call +} + +// RequestValues is a helper method to define mock.On call +func (_e *IncentiveTableClientInterface_Expecter) RequestValues() *IncentiveTableClientInterface_RequestValues_Call { + return &IncentiveTableClientInterface_RequestValues_Call{Call: _e.mock.On("RequestValues")} +} + +func (_c *IncentiveTableClientInterface_RequestValues_Call) Run(run func()) *IncentiveTableClientInterface_RequestValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestValues_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IncentiveTableClientInterface_RequestValues_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableClientInterface_RequestValues_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *IncentiveTableClientInterface_RequestValues_Call { + _c.Call.Return(run) + return _c +} + +// WriteDescriptions provides a mock function with given fields: data +func (_m *IncentiveTableClientInterface) WriteDescriptions(data []model.IncentiveTableDescriptionType) (*model.MsgCounterType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for WriteDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]model.IncentiveTableDescriptionType) (*model.MsgCounterType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func([]model.IncentiveTableDescriptionType) *model.MsgCounterType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]model.IncentiveTableDescriptionType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableClientInterface_WriteDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteDescriptions' +type IncentiveTableClientInterface_WriteDescriptions_Call struct { + *mock.Call +} + +// WriteDescriptions is a helper method to define mock.On call +// - data []model.IncentiveTableDescriptionType +func (_e *IncentiveTableClientInterface_Expecter) WriteDescriptions(data interface{}) *IncentiveTableClientInterface_WriteDescriptions_Call { + return &IncentiveTableClientInterface_WriteDescriptions_Call{Call: _e.mock.On("WriteDescriptions", data)} +} + +func (_c *IncentiveTableClientInterface_WriteDescriptions_Call) Run(run func(data []model.IncentiveTableDescriptionType)) *IncentiveTableClientInterface_WriteDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.IncentiveTableDescriptionType)) + }) + return _c +} + +func (_c *IncentiveTableClientInterface_WriteDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IncentiveTableClientInterface_WriteDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableClientInterface_WriteDescriptions_Call) RunAndReturn(run func([]model.IncentiveTableDescriptionType) (*model.MsgCounterType, error)) *IncentiveTableClientInterface_WriteDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// WriteValues provides a mock function with given fields: data +func (_m *IncentiveTableClientInterface) WriteValues(data []model.IncentiveTableType) (*model.MsgCounterType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for WriteValues") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]model.IncentiveTableType) (*model.MsgCounterType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func([]model.IncentiveTableType) *model.MsgCounterType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]model.IncentiveTableType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableClientInterface_WriteValues_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteValues' +type IncentiveTableClientInterface_WriteValues_Call struct { + *mock.Call +} + +// WriteValues is a helper method to define mock.On call +// - data []model.IncentiveTableType +func (_e *IncentiveTableClientInterface_Expecter) WriteValues(data interface{}) *IncentiveTableClientInterface_WriteValues_Call { + return &IncentiveTableClientInterface_WriteValues_Call{Call: _e.mock.On("WriteValues", data)} +} + +func (_c *IncentiveTableClientInterface_WriteValues_Call) Run(run func(data []model.IncentiveTableType)) *IncentiveTableClientInterface_WriteValues_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.IncentiveTableType)) + }) + return _c +} + +func (_c *IncentiveTableClientInterface_WriteValues_Call) Return(_a0 *model.MsgCounterType, _a1 error) *IncentiveTableClientInterface_WriteValues_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableClientInterface_WriteValues_Call) RunAndReturn(run func([]model.IncentiveTableType) (*model.MsgCounterType, error)) *IncentiveTableClientInterface_WriteValues_Call { + _c.Call.Return(run) + return _c +} + +// NewIncentiveTableClientInterface creates a new instance of IncentiveTableClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIncentiveTableClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IncentiveTableClientInterface { + mock := &IncentiveTableClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableCommonInterface.go new file mode 100644 index 0000000..f792f67 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableCommonInterface.go @@ -0,0 +1,207 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// IncentiveTableCommonInterface is an autogenerated mock type for the IncentiveTableCommonInterface type +type IncentiveTableCommonInterface struct { + mock.Mock +} + +type IncentiveTableCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IncentiveTableCommonInterface) EXPECT() *IncentiveTableCommonInterface_Expecter { + return &IncentiveTableCommonInterface_Expecter{mock: &_m.Mock} +} + +// GetConstraints provides a mock function with given fields: +func (_m *IncentiveTableCommonInterface) GetConstraints() ([]model.IncentiveTableConstraintsType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetConstraints") + } + + var r0 []model.IncentiveTableConstraintsType + var r1 error + if rf, ok := ret.Get(0).(func() ([]model.IncentiveTableConstraintsType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []model.IncentiveTableConstraintsType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.IncentiveTableConstraintsType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableCommonInterface_GetConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConstraints' +type IncentiveTableCommonInterface_GetConstraints_Call struct { + *mock.Call +} + +// GetConstraints is a helper method to define mock.On call +func (_e *IncentiveTableCommonInterface_Expecter) GetConstraints() *IncentiveTableCommonInterface_GetConstraints_Call { + return &IncentiveTableCommonInterface_GetConstraints_Call{Call: _e.mock.On("GetConstraints")} +} + +func (_c *IncentiveTableCommonInterface_GetConstraints_Call) Run(run func()) *IncentiveTableCommonInterface_GetConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetConstraints_Call) Return(_a0 []model.IncentiveTableConstraintsType, _a1 error) *IncentiveTableCommonInterface_GetConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetConstraints_Call) RunAndReturn(run func() ([]model.IncentiveTableConstraintsType, error)) *IncentiveTableCommonInterface_GetConstraints_Call { + _c.Call.Return(run) + return _c +} + +// GetData provides a mock function with given fields: +func (_m *IncentiveTableCommonInterface) GetData() ([]model.IncentiveTableType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetData") + } + + var r0 []model.IncentiveTableType + var r1 error + if rf, ok := ret.Get(0).(func() ([]model.IncentiveTableType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []model.IncentiveTableType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.IncentiveTableType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableCommonInterface_GetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetData' +type IncentiveTableCommonInterface_GetData_Call struct { + *mock.Call +} + +// GetData is a helper method to define mock.On call +func (_e *IncentiveTableCommonInterface_Expecter) GetData() *IncentiveTableCommonInterface_GetData_Call { + return &IncentiveTableCommonInterface_GetData_Call{Call: _e.mock.On("GetData")} +} + +func (_c *IncentiveTableCommonInterface_GetData_Call) Run(run func()) *IncentiveTableCommonInterface_GetData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetData_Call) Return(_a0 []model.IncentiveTableType, _a1 error) *IncentiveTableCommonInterface_GetData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetData_Call) RunAndReturn(run func() ([]model.IncentiveTableType, error)) *IncentiveTableCommonInterface_GetData_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionsForFilter provides a mock function with given fields: filter +func (_m *IncentiveTableCommonInterface) GetDescriptionsForFilter(filter model.TariffDescriptionDataType) ([]model.IncentiveTableDescriptionType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionsForFilter") + } + + var r0 []model.IncentiveTableDescriptionType + var r1 error + if rf, ok := ret.Get(0).(func(model.TariffDescriptionDataType) ([]model.IncentiveTableDescriptionType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.TariffDescriptionDataType) []model.IncentiveTableDescriptionType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.IncentiveTableDescriptionType) + } + } + + if rf, ok := ret.Get(1).(func(model.TariffDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// IncentiveTableCommonInterface_GetDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionsForFilter' +type IncentiveTableCommonInterface_GetDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetDescriptionsForFilter is a helper method to define mock.On call +// - filter model.TariffDescriptionDataType +func (_e *IncentiveTableCommonInterface_Expecter) GetDescriptionsForFilter(filter interface{}) *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call { + return &IncentiveTableCommonInterface_GetDescriptionsForFilter_Call{Call: _e.mock.On("GetDescriptionsForFilter", filter)} +} + +func (_c *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call) Run(run func(filter model.TariffDescriptionDataType)) *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.TariffDescriptionDataType)) + }) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call) Return(_a0 []model.IncentiveTableDescriptionType, _a1 error) *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call) RunAndReturn(run func(model.TariffDescriptionDataType) ([]model.IncentiveTableDescriptionType, error)) *IncentiveTableCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewIncentiveTableCommonInterface creates a new instance of IncentiveTableCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIncentiveTableCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IncentiveTableCommonInterface { + mock := &IncentiveTableCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableServerInterface.go new file mode 100644 index 0000000..c5dc48f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/IncentiveTableServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// IncentiveTableServerInterface is an autogenerated mock type for the IncentiveTableServerInterface type +type IncentiveTableServerInterface struct { + mock.Mock +} + +type IncentiveTableServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *IncentiveTableServerInterface) EXPECT() *IncentiveTableServerInterface_Expecter { + return &IncentiveTableServerInterface_Expecter{mock: &_m.Mock} +} + +// NewIncentiveTableServerInterface creates a new instance of IncentiveTableServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIncentiveTableServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *IncentiveTableServerInterface { + mock := &IncentiveTableServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlClientInterface.go new file mode 100644 index 0000000..74a5bfc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlClientInterface.go @@ -0,0 +1,272 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// LoadControlClientInterface is an autogenerated mock type for the LoadControlClientInterface type +type LoadControlClientInterface struct { + mock.Mock +} + +type LoadControlClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *LoadControlClientInterface) EXPECT() *LoadControlClientInterface_Expecter { + return &LoadControlClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestLimitConstraints provides a mock function with given fields: selector, elements +func (_m *LoadControlClientInterface) RequestLimitConstraints(selector *model.LoadControlLimitConstraintsListDataSelectorsType, elements *model.LoadControlLimitConstraintsDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestLimitConstraints") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitConstraintsListDataSelectorsType, *model.LoadControlLimitConstraintsDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitConstraintsListDataSelectorsType, *model.LoadControlLimitConstraintsDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.LoadControlLimitConstraintsListDataSelectorsType, *model.LoadControlLimitConstraintsDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlClientInterface_RequestLimitConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestLimitConstraints' +type LoadControlClientInterface_RequestLimitConstraints_Call struct { + *mock.Call +} + +// RequestLimitConstraints is a helper method to define mock.On call +// - selector *model.LoadControlLimitConstraintsListDataSelectorsType +// - elements *model.LoadControlLimitConstraintsDataElementsType +func (_e *LoadControlClientInterface_Expecter) RequestLimitConstraints(selector interface{}, elements interface{}) *LoadControlClientInterface_RequestLimitConstraints_Call { + return &LoadControlClientInterface_RequestLimitConstraints_Call{Call: _e.mock.On("RequestLimitConstraints", selector, elements)} +} + +func (_c *LoadControlClientInterface_RequestLimitConstraints_Call) Run(run func(selector *model.LoadControlLimitConstraintsListDataSelectorsType, elements *model.LoadControlLimitConstraintsDataElementsType)) *LoadControlClientInterface_RequestLimitConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.LoadControlLimitConstraintsListDataSelectorsType), args[1].(*model.LoadControlLimitConstraintsDataElementsType)) + }) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitConstraints_Call) Return(_a0 *model.MsgCounterType, _a1 error) *LoadControlClientInterface_RequestLimitConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitConstraints_Call) RunAndReturn(run func(*model.LoadControlLimitConstraintsListDataSelectorsType, *model.LoadControlLimitConstraintsDataElementsType) (*model.MsgCounterType, error)) *LoadControlClientInterface_RequestLimitConstraints_Call { + _c.Call.Return(run) + return _c +} + +// RequestLimitData provides a mock function with given fields: selector, elements +func (_m *LoadControlClientInterface) RequestLimitData(selector *model.LoadControlLimitListDataSelectorsType, elements *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestLimitData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlClientInterface_RequestLimitData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestLimitData' +type LoadControlClientInterface_RequestLimitData_Call struct { + *mock.Call +} + +// RequestLimitData is a helper method to define mock.On call +// - selector *model.LoadControlLimitListDataSelectorsType +// - elements *model.LoadControlLimitDataElementsType +func (_e *LoadControlClientInterface_Expecter) RequestLimitData(selector interface{}, elements interface{}) *LoadControlClientInterface_RequestLimitData_Call { + return &LoadControlClientInterface_RequestLimitData_Call{Call: _e.mock.On("RequestLimitData", selector, elements)} +} + +func (_c *LoadControlClientInterface_RequestLimitData_Call) Run(run func(selector *model.LoadControlLimitListDataSelectorsType, elements *model.LoadControlLimitDataElementsType)) *LoadControlClientInterface_RequestLimitData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.LoadControlLimitListDataSelectorsType), args[1].(*model.LoadControlLimitDataElementsType)) + }) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *LoadControlClientInterface_RequestLimitData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitData_Call) RunAndReturn(run func(*model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error)) *LoadControlClientInterface_RequestLimitData_Call { + _c.Call.Return(run) + return _c +} + +// RequestLimitDescriptions provides a mock function with given fields: selector, elements +func (_m *LoadControlClientInterface) RequestLimitDescriptions(selector *model.LoadControlLimitDescriptionListDataSelectorsType, elements *model.LoadControlLimitDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestLimitDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitDescriptionListDataSelectorsType, *model.LoadControlLimitDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.LoadControlLimitDescriptionListDataSelectorsType, *model.LoadControlLimitDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.LoadControlLimitDescriptionListDataSelectorsType, *model.LoadControlLimitDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlClientInterface_RequestLimitDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestLimitDescriptions' +type LoadControlClientInterface_RequestLimitDescriptions_Call struct { + *mock.Call +} + +// RequestLimitDescriptions is a helper method to define mock.On call +// - selector *model.LoadControlLimitDescriptionListDataSelectorsType +// - elements *model.LoadControlLimitDescriptionDataElementsType +func (_e *LoadControlClientInterface_Expecter) RequestLimitDescriptions(selector interface{}, elements interface{}) *LoadControlClientInterface_RequestLimitDescriptions_Call { + return &LoadControlClientInterface_RequestLimitDescriptions_Call{Call: _e.mock.On("RequestLimitDescriptions", selector, elements)} +} + +func (_c *LoadControlClientInterface_RequestLimitDescriptions_Call) Run(run func(selector *model.LoadControlLimitDescriptionListDataSelectorsType, elements *model.LoadControlLimitDescriptionDataElementsType)) *LoadControlClientInterface_RequestLimitDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.LoadControlLimitDescriptionListDataSelectorsType), args[1].(*model.LoadControlLimitDescriptionDataElementsType)) + }) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *LoadControlClientInterface_RequestLimitDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlClientInterface_RequestLimitDescriptions_Call) RunAndReturn(run func(*model.LoadControlLimitDescriptionListDataSelectorsType, *model.LoadControlLimitDescriptionDataElementsType) (*model.MsgCounterType, error)) *LoadControlClientInterface_RequestLimitDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// WriteLimitData provides a mock function with given fields: data, deleteSelectors, deleteElements +func (_m *LoadControlClientInterface) WriteLimitData(data []model.LoadControlLimitDataType, deleteSelectors *model.LoadControlLimitListDataSelectorsType, deleteElements *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(data, deleteSelectors, deleteElements) + + if len(ret) == 0 { + panic("no return value specified for WriteLimitData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]model.LoadControlLimitDataType, *model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(data, deleteSelectors, deleteElements) + } + if rf, ok := ret.Get(0).(func([]model.LoadControlLimitDataType, *model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) *model.MsgCounterType); ok { + r0 = rf(data, deleteSelectors, deleteElements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]model.LoadControlLimitDataType, *model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) error); ok { + r1 = rf(data, deleteSelectors, deleteElements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlClientInterface_WriteLimitData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteLimitData' +type LoadControlClientInterface_WriteLimitData_Call struct { + *mock.Call +} + +// WriteLimitData is a helper method to define mock.On call +// - data []model.LoadControlLimitDataType +// - deleteSelectors *model.LoadControlLimitListDataSelectorsType +// - deleteElements *model.LoadControlLimitDataElementsType +func (_e *LoadControlClientInterface_Expecter) WriteLimitData(data interface{}, deleteSelectors interface{}, deleteElements interface{}) *LoadControlClientInterface_WriteLimitData_Call { + return &LoadControlClientInterface_WriteLimitData_Call{Call: _e.mock.On("WriteLimitData", data, deleteSelectors, deleteElements)} +} + +func (_c *LoadControlClientInterface_WriteLimitData_Call) Run(run func(data []model.LoadControlLimitDataType, deleteSelectors *model.LoadControlLimitListDataSelectorsType, deleteElements *model.LoadControlLimitDataElementsType)) *LoadControlClientInterface_WriteLimitData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.LoadControlLimitDataType), args[1].(*model.LoadControlLimitListDataSelectorsType), args[2].(*model.LoadControlLimitDataElementsType)) + }) + return _c +} + +func (_c *LoadControlClientInterface_WriteLimitData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *LoadControlClientInterface_WriteLimitData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlClientInterface_WriteLimitData_Call) RunAndReturn(run func([]model.LoadControlLimitDataType, *model.LoadControlLimitListDataSelectorsType, *model.LoadControlLimitDataElementsType) (*model.MsgCounterType, error)) *LoadControlClientInterface_WriteLimitData_Call { + _c.Call.Return(run) + return _c +} + +// NewLoadControlClientInterface creates a new instance of LoadControlClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLoadControlClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *LoadControlClientInterface { + mock := &LoadControlClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlCommonInterface.go new file mode 100644 index 0000000..6796a96 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlCommonInterface.go @@ -0,0 +1,314 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// LoadControlCommonInterface is an autogenerated mock type for the LoadControlCommonInterface type +type LoadControlCommonInterface struct { + mock.Mock +} + +type LoadControlCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *LoadControlCommonInterface) EXPECT() *LoadControlCommonInterface_Expecter { + return &LoadControlCommonInterface_Expecter{mock: &_m.Mock} +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *LoadControlCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *LoadControlCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { + return &LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetLimitDataForFilter provides a mock function with given fields: filter +func (_m *LoadControlCommonInterface) GetLimitDataForFilter(filter model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetLimitDataForFilter") + } + + var r0 []model.LoadControlLimitDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDescriptionDataType) []model.LoadControlLimitDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.LoadControlLimitDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.LoadControlLimitDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlCommonInterface_GetLimitDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLimitDataForFilter' +type LoadControlCommonInterface_GetLimitDataForFilter_Call struct { + *mock.Call +} + +// GetLimitDataForFilter is a helper method to define mock.On call +// - filter model.LoadControlLimitDescriptionDataType +func (_e *LoadControlCommonInterface_Expecter) GetLimitDataForFilter(filter interface{}) *LoadControlCommonInterface_GetLimitDataForFilter_Call { + return &LoadControlCommonInterface_GetLimitDataForFilter_Call{Call: _e.mock.On("GetLimitDataForFilter", filter)} +} + +func (_c *LoadControlCommonInterface_GetLimitDataForFilter_Call) Run(run func(filter model.LoadControlLimitDescriptionDataType)) *LoadControlCommonInterface_GetLimitDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitDescriptionDataType)) + }) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDataForFilter_Call) Return(_a0 []model.LoadControlLimitDataType, _a1 error) *LoadControlCommonInterface_GetLimitDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDataForFilter_Call) RunAndReturn(run func(model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error)) *LoadControlCommonInterface_GetLimitDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetLimitDataForId provides a mock function with given fields: limitId +func (_m *LoadControlCommonInterface) GetLimitDataForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error) { + ret := _m.Called(limitId) + + if len(ret) == 0 { + panic("no return value specified for GetLimitDataForId") + } + + var r0 *model.LoadControlLimitDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error)); ok { + return rf(limitId) + } + if rf, ok := ret.Get(0).(func(model.LoadControlLimitIdType) *model.LoadControlLimitDataType); ok { + r0 = rf(limitId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.LoadControlLimitDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.LoadControlLimitIdType) error); ok { + r1 = rf(limitId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlCommonInterface_GetLimitDataForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLimitDataForId' +type LoadControlCommonInterface_GetLimitDataForId_Call struct { + *mock.Call +} + +// GetLimitDataForId is a helper method to define mock.On call +// - limitId model.LoadControlLimitIdType +func (_e *LoadControlCommonInterface_Expecter) GetLimitDataForId(limitId interface{}) *LoadControlCommonInterface_GetLimitDataForId_Call { + return &LoadControlCommonInterface_GetLimitDataForId_Call{Call: _e.mock.On("GetLimitDataForId", limitId)} +} + +func (_c *LoadControlCommonInterface_GetLimitDataForId_Call) Run(run func(limitId model.LoadControlLimitIdType)) *LoadControlCommonInterface_GetLimitDataForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitIdType)) + }) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDataForId_Call) Return(_a0 *model.LoadControlLimitDataType, _a1 error) *LoadControlCommonInterface_GetLimitDataForId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDataForId_Call) RunAndReturn(run func(model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error)) *LoadControlCommonInterface_GetLimitDataForId_Call { + _c.Call.Return(run) + return _c +} + +// GetLimitDescriptionForId provides a mock function with given fields: limitId +func (_m *LoadControlCommonInterface) GetLimitDescriptionForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDescriptionDataType, error) { + ret := _m.Called(limitId) + + if len(ret) == 0 { + panic("no return value specified for GetLimitDescriptionForId") + } + + var r0 *model.LoadControlLimitDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitIdType) (*model.LoadControlLimitDescriptionDataType, error)); ok { + return rf(limitId) + } + if rf, ok := ret.Get(0).(func(model.LoadControlLimitIdType) *model.LoadControlLimitDescriptionDataType); ok { + r0 = rf(limitId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.LoadControlLimitDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.LoadControlLimitIdType) error); ok { + r1 = rf(limitId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlCommonInterface_GetLimitDescriptionForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLimitDescriptionForId' +type LoadControlCommonInterface_GetLimitDescriptionForId_Call struct { + *mock.Call +} + +// GetLimitDescriptionForId is a helper method to define mock.On call +// - limitId model.LoadControlLimitIdType +func (_e *LoadControlCommonInterface_Expecter) GetLimitDescriptionForId(limitId interface{}) *LoadControlCommonInterface_GetLimitDescriptionForId_Call { + return &LoadControlCommonInterface_GetLimitDescriptionForId_Call{Call: _e.mock.On("GetLimitDescriptionForId", limitId)} +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionForId_Call) Run(run func(limitId model.LoadControlLimitIdType)) *LoadControlCommonInterface_GetLimitDescriptionForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitIdType)) + }) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionForId_Call) Return(_a0 *model.LoadControlLimitDescriptionDataType, _a1 error) *LoadControlCommonInterface_GetLimitDescriptionForId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionForId_Call) RunAndReturn(run func(model.LoadControlLimitIdType) (*model.LoadControlLimitDescriptionDataType, error)) *LoadControlCommonInterface_GetLimitDescriptionForId_Call { + _c.Call.Return(run) + return _c +} + +// GetLimitDescriptionsForFilter provides a mock function with given fields: filter +func (_m *LoadControlCommonInterface) GetLimitDescriptionsForFilter(filter model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetLimitDescriptionsForFilter") + } + + var r0 []model.LoadControlLimitDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDescriptionDataType) []model.LoadControlLimitDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.LoadControlLimitDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.LoadControlLimitDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLimitDescriptionsForFilter' +type LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetLimitDescriptionsForFilter is a helper method to define mock.On call +// - filter model.LoadControlLimitDescriptionDataType +func (_e *LoadControlCommonInterface_Expecter) GetLimitDescriptionsForFilter(filter interface{}) *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call { + return &LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call{Call: _e.mock.On("GetLimitDescriptionsForFilter", filter)} +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call) Run(run func(filter model.LoadControlLimitDescriptionDataType)) *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitDescriptionDataType)) + }) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call) Return(_a0 []model.LoadControlLimitDescriptionDataType, _a1 error) *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call) RunAndReturn(run func(model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDescriptionDataType, error)) *LoadControlCommonInterface_GetLimitDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewLoadControlCommonInterface creates a new instance of LoadControlCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLoadControlCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *LoadControlCommonInterface { + mock := &LoadControlCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlServerInterface.go new file mode 100644 index 0000000..16569a0 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/LoadControlServerInterface.go @@ -0,0 +1,179 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// LoadControlServerInterface is an autogenerated mock type for the LoadControlServerInterface type +type LoadControlServerInterface struct { + mock.Mock +} + +type LoadControlServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *LoadControlServerInterface) EXPECT() *LoadControlServerInterface_Expecter { + return &LoadControlServerInterface_Expecter{mock: &_m.Mock} +} + +// AddLimitDescription provides a mock function with given fields: description +func (_m *LoadControlServerInterface) AddLimitDescription(description model.LoadControlLimitDescriptionDataType) *model.LoadControlLimitIdType { + ret := _m.Called(description) + + if len(ret) == 0 { + panic("no return value specified for AddLimitDescription") + } + + var r0 *model.LoadControlLimitIdType + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDescriptionDataType) *model.LoadControlLimitIdType); ok { + r0 = rf(description) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.LoadControlLimitIdType) + } + } + + return r0 +} + +// LoadControlServerInterface_AddLimitDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddLimitDescription' +type LoadControlServerInterface_AddLimitDescription_Call struct { + *mock.Call +} + +// AddLimitDescription is a helper method to define mock.On call +// - description model.LoadControlLimitDescriptionDataType +func (_e *LoadControlServerInterface_Expecter) AddLimitDescription(description interface{}) *LoadControlServerInterface_AddLimitDescription_Call { + return &LoadControlServerInterface_AddLimitDescription_Call{Call: _e.mock.On("AddLimitDescription", description)} +} + +func (_c *LoadControlServerInterface_AddLimitDescription_Call) Run(run func(description model.LoadControlLimitDescriptionDataType)) *LoadControlServerInterface_AddLimitDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitDescriptionDataType)) + }) + return _c +} + +func (_c *LoadControlServerInterface_AddLimitDescription_Call) Return(_a0 *model.LoadControlLimitIdType) *LoadControlServerInterface_AddLimitDescription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *LoadControlServerInterface_AddLimitDescription_Call) RunAndReturn(run func(model.LoadControlLimitDescriptionDataType) *model.LoadControlLimitIdType) *LoadControlServerInterface_AddLimitDescription_Call { + _c.Call.Return(run) + return _c +} + +// UpdateLimitDataForFilter provides a mock function with given fields: data, deleteElements, filter +func (_m *LoadControlServerInterface) UpdateLimitDataForFilter(data model.LoadControlLimitDataType, deleteElements *model.LoadControlLimitDataElementsType, filter model.LoadControlLimitDescriptionDataType) error { + ret := _m.Called(data, deleteElements, filter) + + if len(ret) == 0 { + panic("no return value specified for UpdateLimitDataForFilter") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDataType, *model.LoadControlLimitDataElementsType, model.LoadControlLimitDescriptionDataType) error); ok { + r0 = rf(data, deleteElements, filter) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// LoadControlServerInterface_UpdateLimitDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateLimitDataForFilter' +type LoadControlServerInterface_UpdateLimitDataForFilter_Call struct { + *mock.Call +} + +// UpdateLimitDataForFilter is a helper method to define mock.On call +// - data model.LoadControlLimitDataType +// - deleteElements *model.LoadControlLimitDataElementsType +// - filter model.LoadControlLimitDescriptionDataType +func (_e *LoadControlServerInterface_Expecter) UpdateLimitDataForFilter(data interface{}, deleteElements interface{}, filter interface{}) *LoadControlServerInterface_UpdateLimitDataForFilter_Call { + return &LoadControlServerInterface_UpdateLimitDataForFilter_Call{Call: _e.mock.On("UpdateLimitDataForFilter", data, deleteElements, filter)} +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForFilter_Call) Run(run func(data model.LoadControlLimitDataType, deleteElements *model.LoadControlLimitDataElementsType, filter model.LoadControlLimitDescriptionDataType)) *LoadControlServerInterface_UpdateLimitDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitDataType), args[1].(*model.LoadControlLimitDataElementsType), args[2].(model.LoadControlLimitDescriptionDataType)) + }) + return _c +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForFilter_Call) Return(_a0 error) *LoadControlServerInterface_UpdateLimitDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForFilter_Call) RunAndReturn(run func(model.LoadControlLimitDataType, *model.LoadControlLimitDataElementsType, model.LoadControlLimitDescriptionDataType) error) *LoadControlServerInterface_UpdateLimitDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// UpdateLimitDataForId provides a mock function with given fields: data, deleteElements, limitId +func (_m *LoadControlServerInterface) UpdateLimitDataForId(data model.LoadControlLimitDataType, deleteElements *model.LoadControlLimitDataElementsType, limitId model.LoadControlLimitIdType) error { + ret := _m.Called(data, deleteElements, limitId) + + if len(ret) == 0 { + panic("no return value specified for UpdateLimitDataForId") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.LoadControlLimitDataType, *model.LoadControlLimitDataElementsType, model.LoadControlLimitIdType) error); ok { + r0 = rf(data, deleteElements, limitId) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// LoadControlServerInterface_UpdateLimitDataForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateLimitDataForId' +type LoadControlServerInterface_UpdateLimitDataForId_Call struct { + *mock.Call +} + +// UpdateLimitDataForId is a helper method to define mock.On call +// - data model.LoadControlLimitDataType +// - deleteElements *model.LoadControlLimitDataElementsType +// - limitId model.LoadControlLimitIdType +func (_e *LoadControlServerInterface_Expecter) UpdateLimitDataForId(data interface{}, deleteElements interface{}, limitId interface{}) *LoadControlServerInterface_UpdateLimitDataForId_Call { + return &LoadControlServerInterface_UpdateLimitDataForId_Call{Call: _e.mock.On("UpdateLimitDataForId", data, deleteElements, limitId)} +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForId_Call) Run(run func(data model.LoadControlLimitDataType, deleteElements *model.LoadControlLimitDataElementsType, limitId model.LoadControlLimitIdType)) *LoadControlServerInterface_UpdateLimitDataForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.LoadControlLimitDataType), args[1].(*model.LoadControlLimitDataElementsType), args[2].(model.LoadControlLimitIdType)) + }) + return _c +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForId_Call) Return(_a0 error) *LoadControlServerInterface_UpdateLimitDataForId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *LoadControlServerInterface_UpdateLimitDataForId_Call) RunAndReturn(run func(model.LoadControlLimitDataType, *model.LoadControlLimitDataElementsType, model.LoadControlLimitIdType) error) *LoadControlServerInterface_UpdateLimitDataForId_Call { + _c.Call.Return(run) + return _c +} + +// NewLoadControlServerInterface creates a new instance of LoadControlServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewLoadControlServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *LoadControlServerInterface { + mock := &LoadControlServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementClientInterface.go new file mode 100644 index 0000000..82c85af --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementClientInterface.go @@ -0,0 +1,212 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// MeasurementClientInterface is an autogenerated mock type for the MeasurementClientInterface type +type MeasurementClientInterface struct { + mock.Mock +} + +type MeasurementClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MeasurementClientInterface) EXPECT() *MeasurementClientInterface_Expecter { + return &MeasurementClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestConstraints provides a mock function with given fields: selector, elements +func (_m *MeasurementClientInterface) RequestConstraints(selector *model.MeasurementConstraintsListDataSelectorsType, elements *model.MeasurementConstraintsDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestConstraints") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.MeasurementConstraintsListDataSelectorsType, *model.MeasurementConstraintsDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.MeasurementConstraintsListDataSelectorsType, *model.MeasurementConstraintsDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.MeasurementConstraintsListDataSelectorsType, *model.MeasurementConstraintsDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementClientInterface_RequestConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestConstraints' +type MeasurementClientInterface_RequestConstraints_Call struct { + *mock.Call +} + +// RequestConstraints is a helper method to define mock.On call +// - selector *model.MeasurementConstraintsListDataSelectorsType +// - elements *model.MeasurementConstraintsDataElementsType +func (_e *MeasurementClientInterface_Expecter) RequestConstraints(selector interface{}, elements interface{}) *MeasurementClientInterface_RequestConstraints_Call { + return &MeasurementClientInterface_RequestConstraints_Call{Call: _e.mock.On("RequestConstraints", selector, elements)} +} + +func (_c *MeasurementClientInterface_RequestConstraints_Call) Run(run func(selector *model.MeasurementConstraintsListDataSelectorsType, elements *model.MeasurementConstraintsDataElementsType)) *MeasurementClientInterface_RequestConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.MeasurementConstraintsListDataSelectorsType), args[1].(*model.MeasurementConstraintsDataElementsType)) + }) + return _c +} + +func (_c *MeasurementClientInterface_RequestConstraints_Call) Return(_a0 *model.MsgCounterType, _a1 error) *MeasurementClientInterface_RequestConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementClientInterface_RequestConstraints_Call) RunAndReturn(run func(*model.MeasurementConstraintsListDataSelectorsType, *model.MeasurementConstraintsDataElementsType) (*model.MsgCounterType, error)) *MeasurementClientInterface_RequestConstraints_Call { + _c.Call.Return(run) + return _c +} + +// RequestData provides a mock function with given fields: selector, elements +func (_m *MeasurementClientInterface) RequestData(selector *model.MeasurementListDataSelectorsType, elements *model.MeasurementDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.MeasurementListDataSelectorsType, *model.MeasurementDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.MeasurementListDataSelectorsType, *model.MeasurementDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.MeasurementListDataSelectorsType, *model.MeasurementDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementClientInterface_RequestData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestData' +type MeasurementClientInterface_RequestData_Call struct { + *mock.Call +} + +// RequestData is a helper method to define mock.On call +// - selector *model.MeasurementListDataSelectorsType +// - elements *model.MeasurementDataElementsType +func (_e *MeasurementClientInterface_Expecter) RequestData(selector interface{}, elements interface{}) *MeasurementClientInterface_RequestData_Call { + return &MeasurementClientInterface_RequestData_Call{Call: _e.mock.On("RequestData", selector, elements)} +} + +func (_c *MeasurementClientInterface_RequestData_Call) Run(run func(selector *model.MeasurementListDataSelectorsType, elements *model.MeasurementDataElementsType)) *MeasurementClientInterface_RequestData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.MeasurementListDataSelectorsType), args[1].(*model.MeasurementDataElementsType)) + }) + return _c +} + +func (_c *MeasurementClientInterface_RequestData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *MeasurementClientInterface_RequestData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementClientInterface_RequestData_Call) RunAndReturn(run func(*model.MeasurementListDataSelectorsType, *model.MeasurementDataElementsType) (*model.MsgCounterType, error)) *MeasurementClientInterface_RequestData_Call { + _c.Call.Return(run) + return _c +} + +// RequestDescriptions provides a mock function with given fields: selector, elements +func (_m *MeasurementClientInterface) RequestDescriptions(selector *model.MeasurementDescriptionListDataSelectorsType, elements *model.MeasurementDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.MeasurementDescriptionListDataSelectorsType, *model.MeasurementDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.MeasurementDescriptionListDataSelectorsType, *model.MeasurementDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.MeasurementDescriptionListDataSelectorsType, *model.MeasurementDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementClientInterface_RequestDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestDescriptions' +type MeasurementClientInterface_RequestDescriptions_Call struct { + *mock.Call +} + +// RequestDescriptions is a helper method to define mock.On call +// - selector *model.MeasurementDescriptionListDataSelectorsType +// - elements *model.MeasurementDescriptionDataElementsType +func (_e *MeasurementClientInterface_Expecter) RequestDescriptions(selector interface{}, elements interface{}) *MeasurementClientInterface_RequestDescriptions_Call { + return &MeasurementClientInterface_RequestDescriptions_Call{Call: _e.mock.On("RequestDescriptions", selector, elements)} +} + +func (_c *MeasurementClientInterface_RequestDescriptions_Call) Run(run func(selector *model.MeasurementDescriptionListDataSelectorsType, elements *model.MeasurementDescriptionDataElementsType)) *MeasurementClientInterface_RequestDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.MeasurementDescriptionListDataSelectorsType), args[1].(*model.MeasurementDescriptionDataElementsType)) + }) + return _c +} + +func (_c *MeasurementClientInterface_RequestDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *MeasurementClientInterface_RequestDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementClientInterface_RequestDescriptions_Call) RunAndReturn(run func(*model.MeasurementDescriptionListDataSelectorsType, *model.MeasurementDescriptionDataElementsType) (*model.MsgCounterType, error)) *MeasurementClientInterface_RequestDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// NewMeasurementClientInterface creates a new instance of MeasurementClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMeasurementClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MeasurementClientInterface { + mock := &MeasurementClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementCommonInterface.go new file mode 100644 index 0000000..ab2ee75 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementCommonInterface.go @@ -0,0 +1,372 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// MeasurementCommonInterface is an autogenerated mock type for the MeasurementCommonInterface type +type MeasurementCommonInterface struct { + mock.Mock +} + +type MeasurementCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MeasurementCommonInterface) EXPECT() *MeasurementCommonInterface_Expecter { + return &MeasurementCommonInterface_Expecter{mock: &_m.Mock} +} + +// CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter +func (_m *MeasurementCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { + ret := _m.Called(payloadData, filter) + + if len(ret) == 0 { + panic("no return value specified for CheckEventPayloadDataForFilter") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + r0 = rf(payloadData, filter) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEventPayloadDataForFilter' +type MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call struct { + *mock.Call +} + +// CheckEventPayloadDataForFilter is a helper method to define mock.On call +// - payloadData interface{} +// - filter interface{} +func (_e *MeasurementCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { + return &MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} +} + +func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) Return(_a0 bool) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetConstraintsForFilter provides a mock function with given fields: filter +func (_m *MeasurementCommonInterface) GetConstraintsForFilter(filter model.MeasurementConstraintsDataType) ([]model.MeasurementConstraintsDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetConstraintsForFilter") + } + + var r0 []model.MeasurementConstraintsDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.MeasurementConstraintsDataType) ([]model.MeasurementConstraintsDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.MeasurementConstraintsDataType) []model.MeasurementConstraintsDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.MeasurementConstraintsDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.MeasurementConstraintsDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementCommonInterface_GetConstraintsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConstraintsForFilter' +type MeasurementCommonInterface_GetConstraintsForFilter_Call struct { + *mock.Call +} + +// GetConstraintsForFilter is a helper method to define mock.On call +// - filter model.MeasurementConstraintsDataType +func (_e *MeasurementCommonInterface_Expecter) GetConstraintsForFilter(filter interface{}) *MeasurementCommonInterface_GetConstraintsForFilter_Call { + return &MeasurementCommonInterface_GetConstraintsForFilter_Call{Call: _e.mock.On("GetConstraintsForFilter", filter)} +} + +func (_c *MeasurementCommonInterface_GetConstraintsForFilter_Call) Run(run func(filter model.MeasurementConstraintsDataType)) *MeasurementCommonInterface_GetConstraintsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementConstraintsDataType)) + }) + return _c +} + +func (_c *MeasurementCommonInterface_GetConstraintsForFilter_Call) Return(_a0 []model.MeasurementConstraintsDataType, _a1 error) *MeasurementCommonInterface_GetConstraintsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementCommonInterface_GetConstraintsForFilter_Call) RunAndReturn(run func(model.MeasurementConstraintsDataType) ([]model.MeasurementConstraintsDataType, error)) *MeasurementCommonInterface_GetConstraintsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDataForFilter provides a mock function with given fields: filter +func (_m *MeasurementCommonInterface) GetDataForFilter(filter model.MeasurementDescriptionDataType) ([]model.MeasurementDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDataForFilter") + } + + var r0 []model.MeasurementDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.MeasurementDescriptionDataType) ([]model.MeasurementDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.MeasurementDescriptionDataType) []model.MeasurementDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.MeasurementDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.MeasurementDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementCommonInterface_GetDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDataForFilter' +type MeasurementCommonInterface_GetDataForFilter_Call struct { + *mock.Call +} + +// GetDataForFilter is a helper method to define mock.On call +// - filter model.MeasurementDescriptionDataType +func (_e *MeasurementCommonInterface_Expecter) GetDataForFilter(filter interface{}) *MeasurementCommonInterface_GetDataForFilter_Call { + return &MeasurementCommonInterface_GetDataForFilter_Call{Call: _e.mock.On("GetDataForFilter", filter)} +} + +func (_c *MeasurementCommonInterface_GetDataForFilter_Call) Run(run func(filter model.MeasurementDescriptionDataType)) *MeasurementCommonInterface_GetDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *MeasurementCommonInterface_GetDataForFilter_Call) Return(_a0 []model.MeasurementDataType, _a1 error) *MeasurementCommonInterface_GetDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementCommonInterface_GetDataForFilter_Call) RunAndReturn(run func(model.MeasurementDescriptionDataType) ([]model.MeasurementDataType, error)) *MeasurementCommonInterface_GetDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDataForId provides a mock function with given fields: measurementId +func (_m *MeasurementCommonInterface) GetDataForId(measurementId model.MeasurementIdType) (*model.MeasurementDataType, error) { + ret := _m.Called(measurementId) + + if len(ret) == 0 { + panic("no return value specified for GetDataForId") + } + + var r0 *model.MeasurementDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.MeasurementIdType) (*model.MeasurementDataType, error)); ok { + return rf(measurementId) + } + if rf, ok := ret.Get(0).(func(model.MeasurementIdType) *model.MeasurementDataType); ok { + r0 = rf(measurementId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MeasurementDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.MeasurementIdType) error); ok { + r1 = rf(measurementId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementCommonInterface_GetDataForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDataForId' +type MeasurementCommonInterface_GetDataForId_Call struct { + *mock.Call +} + +// GetDataForId is a helper method to define mock.On call +// - measurementId model.MeasurementIdType +func (_e *MeasurementCommonInterface_Expecter) GetDataForId(measurementId interface{}) *MeasurementCommonInterface_GetDataForId_Call { + return &MeasurementCommonInterface_GetDataForId_Call{Call: _e.mock.On("GetDataForId", measurementId)} +} + +func (_c *MeasurementCommonInterface_GetDataForId_Call) Run(run func(measurementId model.MeasurementIdType)) *MeasurementCommonInterface_GetDataForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementIdType)) + }) + return _c +} + +func (_c *MeasurementCommonInterface_GetDataForId_Call) Return(_a0 *model.MeasurementDataType, _a1 error) *MeasurementCommonInterface_GetDataForId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementCommonInterface_GetDataForId_Call) RunAndReturn(run func(model.MeasurementIdType) (*model.MeasurementDataType, error)) *MeasurementCommonInterface_GetDataForId_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionForId provides a mock function with given fields: measurementId +func (_m *MeasurementCommonInterface) GetDescriptionForId(measurementId model.MeasurementIdType) (*model.MeasurementDescriptionDataType, error) { + ret := _m.Called(measurementId) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionForId") + } + + var r0 *model.MeasurementDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.MeasurementIdType) (*model.MeasurementDescriptionDataType, error)); ok { + return rf(measurementId) + } + if rf, ok := ret.Get(0).(func(model.MeasurementIdType) *model.MeasurementDescriptionDataType); ok { + r0 = rf(measurementId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MeasurementDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.MeasurementIdType) error); ok { + r1 = rf(measurementId) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementCommonInterface_GetDescriptionForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionForId' +type MeasurementCommonInterface_GetDescriptionForId_Call struct { + *mock.Call +} + +// GetDescriptionForId is a helper method to define mock.On call +// - measurementId model.MeasurementIdType +func (_e *MeasurementCommonInterface_Expecter) GetDescriptionForId(measurementId interface{}) *MeasurementCommonInterface_GetDescriptionForId_Call { + return &MeasurementCommonInterface_GetDescriptionForId_Call{Call: _e.mock.On("GetDescriptionForId", measurementId)} +} + +func (_c *MeasurementCommonInterface_GetDescriptionForId_Call) Run(run func(measurementId model.MeasurementIdType)) *MeasurementCommonInterface_GetDescriptionForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementIdType)) + }) + return _c +} + +func (_c *MeasurementCommonInterface_GetDescriptionForId_Call) Return(_a0 *model.MeasurementDescriptionDataType, _a1 error) *MeasurementCommonInterface_GetDescriptionForId_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementCommonInterface_GetDescriptionForId_Call) RunAndReturn(run func(model.MeasurementIdType) (*model.MeasurementDescriptionDataType, error)) *MeasurementCommonInterface_GetDescriptionForId_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionsForFilter provides a mock function with given fields: filter +func (_m *MeasurementCommonInterface) GetDescriptionsForFilter(filter model.MeasurementDescriptionDataType) ([]model.MeasurementDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionsForFilter") + } + + var r0 []model.MeasurementDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.MeasurementDescriptionDataType) ([]model.MeasurementDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.MeasurementDescriptionDataType) []model.MeasurementDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.MeasurementDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.MeasurementDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MeasurementCommonInterface_GetDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionsForFilter' +type MeasurementCommonInterface_GetDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetDescriptionsForFilter is a helper method to define mock.On call +// - filter model.MeasurementDescriptionDataType +func (_e *MeasurementCommonInterface_Expecter) GetDescriptionsForFilter(filter interface{}) *MeasurementCommonInterface_GetDescriptionsForFilter_Call { + return &MeasurementCommonInterface_GetDescriptionsForFilter_Call{Call: _e.mock.On("GetDescriptionsForFilter", filter)} +} + +func (_c *MeasurementCommonInterface_GetDescriptionsForFilter_Call) Run(run func(filter model.MeasurementDescriptionDataType)) *MeasurementCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *MeasurementCommonInterface_GetDescriptionsForFilter_Call) Return(_a0 []model.MeasurementDescriptionDataType, _a1 error) *MeasurementCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MeasurementCommonInterface_GetDescriptionsForFilter_Call) RunAndReturn(run func(model.MeasurementDescriptionDataType) ([]model.MeasurementDescriptionDataType, error)) *MeasurementCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewMeasurementCommonInterface creates a new instance of MeasurementCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMeasurementCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MeasurementCommonInterface { + mock := &MeasurementCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementServerInterface.go new file mode 100644 index 0000000..4ad5959 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/MeasurementServerInterface.go @@ -0,0 +1,179 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// MeasurementServerInterface is an autogenerated mock type for the MeasurementServerInterface type +type MeasurementServerInterface struct { + mock.Mock +} + +type MeasurementServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MeasurementServerInterface) EXPECT() *MeasurementServerInterface_Expecter { + return &MeasurementServerInterface_Expecter{mock: &_m.Mock} +} + +// AddDescription provides a mock function with given fields: description +func (_m *MeasurementServerInterface) AddDescription(description model.MeasurementDescriptionDataType) *model.MeasurementIdType { + ret := _m.Called(description) + + if len(ret) == 0 { + panic("no return value specified for AddDescription") + } + + var r0 *model.MeasurementIdType + if rf, ok := ret.Get(0).(func(model.MeasurementDescriptionDataType) *model.MeasurementIdType); ok { + r0 = rf(description) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MeasurementIdType) + } + } + + return r0 +} + +// MeasurementServerInterface_AddDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddDescription' +type MeasurementServerInterface_AddDescription_Call struct { + *mock.Call +} + +// AddDescription is a helper method to define mock.On call +// - description model.MeasurementDescriptionDataType +func (_e *MeasurementServerInterface_Expecter) AddDescription(description interface{}) *MeasurementServerInterface_AddDescription_Call { + return &MeasurementServerInterface_AddDescription_Call{Call: _e.mock.On("AddDescription", description)} +} + +func (_c *MeasurementServerInterface_AddDescription_Call) Run(run func(description model.MeasurementDescriptionDataType)) *MeasurementServerInterface_AddDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *MeasurementServerInterface_AddDescription_Call) Return(_a0 *model.MeasurementIdType) *MeasurementServerInterface_AddDescription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MeasurementServerInterface_AddDescription_Call) RunAndReturn(run func(model.MeasurementDescriptionDataType) *model.MeasurementIdType) *MeasurementServerInterface_AddDescription_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataForFilter provides a mock function with given fields: data, deleteElements, filter +func (_m *MeasurementServerInterface) UpdateDataForFilter(data model.MeasurementDataType, deleteElements *model.MeasurementDataElementsType, filter model.MeasurementDescriptionDataType) error { + ret := _m.Called(data, deleteElements, filter) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataForFilter") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MeasurementDataType, *model.MeasurementDataElementsType, model.MeasurementDescriptionDataType) error); ok { + r0 = rf(data, deleteElements, filter) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MeasurementServerInterface_UpdateDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataForFilter' +type MeasurementServerInterface_UpdateDataForFilter_Call struct { + *mock.Call +} + +// UpdateDataForFilter is a helper method to define mock.On call +// - data model.MeasurementDataType +// - deleteElements *model.MeasurementDataElementsType +// - filter model.MeasurementDescriptionDataType +func (_e *MeasurementServerInterface_Expecter) UpdateDataForFilter(data interface{}, deleteElements interface{}, filter interface{}) *MeasurementServerInterface_UpdateDataForFilter_Call { + return &MeasurementServerInterface_UpdateDataForFilter_Call{Call: _e.mock.On("UpdateDataForFilter", data, deleteElements, filter)} +} + +func (_c *MeasurementServerInterface_UpdateDataForFilter_Call) Run(run func(data model.MeasurementDataType, deleteElements *model.MeasurementDataElementsType, filter model.MeasurementDescriptionDataType)) *MeasurementServerInterface_UpdateDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementDataType), args[1].(*model.MeasurementDataElementsType), args[2].(model.MeasurementDescriptionDataType)) + }) + return _c +} + +func (_c *MeasurementServerInterface_UpdateDataForFilter_Call) Return(_a0 error) *MeasurementServerInterface_UpdateDataForFilter_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MeasurementServerInterface_UpdateDataForFilter_Call) RunAndReturn(run func(model.MeasurementDataType, *model.MeasurementDataElementsType, model.MeasurementDescriptionDataType) error) *MeasurementServerInterface_UpdateDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataForId provides a mock function with given fields: data, deleteElements, measurementId +func (_m *MeasurementServerInterface) UpdateDataForId(data model.MeasurementDataType, deleteElements *model.MeasurementDataElementsType, measurementId model.MeasurementIdType) error { + ret := _m.Called(data, deleteElements, measurementId) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataForId") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MeasurementDataType, *model.MeasurementDataElementsType, model.MeasurementIdType) error); ok { + r0 = rf(data, deleteElements, measurementId) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MeasurementServerInterface_UpdateDataForId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataForId' +type MeasurementServerInterface_UpdateDataForId_Call struct { + *mock.Call +} + +// UpdateDataForId is a helper method to define mock.On call +// - data model.MeasurementDataType +// - deleteElements *model.MeasurementDataElementsType +// - measurementId model.MeasurementIdType +func (_e *MeasurementServerInterface_Expecter) UpdateDataForId(data interface{}, deleteElements interface{}, measurementId interface{}) *MeasurementServerInterface_UpdateDataForId_Call { + return &MeasurementServerInterface_UpdateDataForId_Call{Call: _e.mock.On("UpdateDataForId", data, deleteElements, measurementId)} +} + +func (_c *MeasurementServerInterface_UpdateDataForId_Call) Run(run func(data model.MeasurementDataType, deleteElements *model.MeasurementDataElementsType, measurementId model.MeasurementIdType)) *MeasurementServerInterface_UpdateDataForId_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MeasurementDataType), args[1].(*model.MeasurementDataElementsType), args[2].(model.MeasurementIdType)) + }) + return _c +} + +func (_c *MeasurementServerInterface_UpdateDataForId_Call) Return(_a0 error) *MeasurementServerInterface_UpdateDataForId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MeasurementServerInterface_UpdateDataForId_Call) RunAndReturn(run func(model.MeasurementDataType, *model.MeasurementDataElementsType, model.MeasurementIdType) error) *MeasurementServerInterface_UpdateDataForId_Call { + _c.Call.Return(run) + return _c +} + +// NewMeasurementServerInterface creates a new instance of MeasurementServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMeasurementServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MeasurementServerInterface { + mock := &MeasurementServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/ServiceInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/ServiceInterface.go new file mode 100644 index 0000000..d37a951 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/ServiceInterface.go @@ -0,0 +1,697 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/api" + logging "github.com/enbility/ship-go/logging" + + mock "github.com/stretchr/testify/mock" + + ship_goapi "github.com/enbility/ship-go/api" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// ServiceInterface is an autogenerated mock type for the ServiceInterface type +type ServiceInterface struct { + mock.Mock +} + +type ServiceInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ServiceInterface) EXPECT() *ServiceInterface_Expecter { + return &ServiceInterface_Expecter{mock: &_m.Mock} +} + +// AddUseCase provides a mock function with given fields: useCase +func (_m *ServiceInterface) AddUseCase(useCase api.UseCaseInterface) { + _m.Called(useCase) +} + +// ServiceInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type ServiceInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +// - useCase api.UseCaseInterface +func (_e *ServiceInterface_Expecter) AddUseCase(useCase interface{}) *ServiceInterface_AddUseCase_Call { + return &ServiceInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase", useCase)} +} + +func (_c *ServiceInterface_AddUseCase_Call) Run(run func(useCase api.UseCaseInterface)) *ServiceInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.UseCaseInterface)) + }) + return _c +} + +func (_c *ServiceInterface_AddUseCase_Call) Return() *ServiceInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_AddUseCase_Call) RunAndReturn(run func(api.UseCaseInterface)) *ServiceInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// CancelPairingWithSKI provides a mock function with given fields: ski +func (_m *ServiceInterface) CancelPairingWithSKI(ski string) { + _m.Called(ski) +} + +// ServiceInterface_CancelPairingWithSKI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CancelPairingWithSKI' +type ServiceInterface_CancelPairingWithSKI_Call struct { + *mock.Call +} + +// CancelPairingWithSKI is a helper method to define mock.On call +// - ski string +func (_e *ServiceInterface_Expecter) CancelPairingWithSKI(ski interface{}) *ServiceInterface_CancelPairingWithSKI_Call { + return &ServiceInterface_CancelPairingWithSKI_Call{Call: _e.mock.On("CancelPairingWithSKI", ski)} +} + +func (_c *ServiceInterface_CancelPairingWithSKI_Call) Run(run func(ski string)) *ServiceInterface_CancelPairingWithSKI_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ServiceInterface_CancelPairingWithSKI_Call) Return() *ServiceInterface_CancelPairingWithSKI_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_CancelPairingWithSKI_Call) RunAndReturn(run func(string)) *ServiceInterface_CancelPairingWithSKI_Call { + _c.Call.Return(run) + return _c +} + +// Configuration provides a mock function with given fields: +func (_m *ServiceInterface) Configuration() *api.Configuration { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Configuration") + } + + var r0 *api.Configuration + if rf, ok := ret.Get(0).(func() *api.Configuration); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*api.Configuration) + } + } + + return r0 +} + +// ServiceInterface_Configuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Configuration' +type ServiceInterface_Configuration_Call struct { + *mock.Call +} + +// Configuration is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) Configuration() *ServiceInterface_Configuration_Call { + return &ServiceInterface_Configuration_Call{Call: _e.mock.On("Configuration")} +} + +func (_c *ServiceInterface_Configuration_Call) Run(run func()) *ServiceInterface_Configuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_Configuration_Call) Return(_a0 *api.Configuration) *ServiceInterface_Configuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_Configuration_Call) RunAndReturn(run func() *api.Configuration) *ServiceInterface_Configuration_Call { + _c.Call.Return(run) + return _c +} + +// DisconnectSKI provides a mock function with given fields: ski, reason +func (_m *ServiceInterface) DisconnectSKI(ski string, reason string) { + _m.Called(ski, reason) +} + +// ServiceInterface_DisconnectSKI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisconnectSKI' +type ServiceInterface_DisconnectSKI_Call struct { + *mock.Call +} + +// DisconnectSKI is a helper method to define mock.On call +// - ski string +// - reason string +func (_e *ServiceInterface_Expecter) DisconnectSKI(ski interface{}, reason interface{}) *ServiceInterface_DisconnectSKI_Call { + return &ServiceInterface_DisconnectSKI_Call{Call: _e.mock.On("DisconnectSKI", ski, reason)} +} + +func (_c *ServiceInterface_DisconnectSKI_Call) Run(run func(ski string, reason string)) *ServiceInterface_DisconnectSKI_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *ServiceInterface_DisconnectSKI_Call) Return() *ServiceInterface_DisconnectSKI_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_DisconnectSKI_Call) RunAndReturn(run func(string, string)) *ServiceInterface_DisconnectSKI_Call { + _c.Call.Return(run) + return _c +} + +// IsAutoAcceptEnabled provides a mock function with given fields: +func (_m *ServiceInterface) IsAutoAcceptEnabled() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsAutoAcceptEnabled") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// ServiceInterface_IsAutoAcceptEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsAutoAcceptEnabled' +type ServiceInterface_IsAutoAcceptEnabled_Call struct { + *mock.Call +} + +// IsAutoAcceptEnabled is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) IsAutoAcceptEnabled() *ServiceInterface_IsAutoAcceptEnabled_Call { + return &ServiceInterface_IsAutoAcceptEnabled_Call{Call: _e.mock.On("IsAutoAcceptEnabled")} +} + +func (_c *ServiceInterface_IsAutoAcceptEnabled_Call) Run(run func()) *ServiceInterface_IsAutoAcceptEnabled_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_IsAutoAcceptEnabled_Call) Return(_a0 bool) *ServiceInterface_IsAutoAcceptEnabled_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_IsAutoAcceptEnabled_Call) RunAndReturn(run func() bool) *ServiceInterface_IsAutoAcceptEnabled_Call { + _c.Call.Return(run) + return _c +} + +// LocalDevice provides a mock function with given fields: +func (_m *ServiceInterface) LocalDevice() spine_goapi.DeviceLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for LocalDevice") + } + + var r0 spine_goapi.DeviceLocalInterface + if rf, ok := ret.Get(0).(func() spine_goapi.DeviceLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(spine_goapi.DeviceLocalInterface) + } + } + + return r0 +} + +// ServiceInterface_LocalDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LocalDevice' +type ServiceInterface_LocalDevice_Call struct { + *mock.Call +} + +// LocalDevice is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) LocalDevice() *ServiceInterface_LocalDevice_Call { + return &ServiceInterface_LocalDevice_Call{Call: _e.mock.On("LocalDevice")} +} + +func (_c *ServiceInterface_LocalDevice_Call) Run(run func()) *ServiceInterface_LocalDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_LocalDevice_Call) Return(_a0 spine_goapi.DeviceLocalInterface) *ServiceInterface_LocalDevice_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_LocalDevice_Call) RunAndReturn(run func() spine_goapi.DeviceLocalInterface) *ServiceInterface_LocalDevice_Call { + _c.Call.Return(run) + return _c +} + +// LocalService provides a mock function with given fields: +func (_m *ServiceInterface) LocalService() *ship_goapi.ServiceDetails { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for LocalService") + } + + var r0 *ship_goapi.ServiceDetails + if rf, ok := ret.Get(0).(func() *ship_goapi.ServiceDetails); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ship_goapi.ServiceDetails) + } + } + + return r0 +} + +// ServiceInterface_LocalService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LocalService' +type ServiceInterface_LocalService_Call struct { + *mock.Call +} + +// LocalService is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) LocalService() *ServiceInterface_LocalService_Call { + return &ServiceInterface_LocalService_Call{Call: _e.mock.On("LocalService")} +} + +func (_c *ServiceInterface_LocalService_Call) Run(run func()) *ServiceInterface_LocalService_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_LocalService_Call) Return(_a0 *ship_goapi.ServiceDetails) *ServiceInterface_LocalService_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_LocalService_Call) RunAndReturn(run func() *ship_goapi.ServiceDetails) *ServiceInterface_LocalService_Call { + _c.Call.Return(run) + return _c +} + +// PairingDetailForSki provides a mock function with given fields: ski +func (_m *ServiceInterface) PairingDetailForSki(ski string) *ship_goapi.ConnectionStateDetail { + ret := _m.Called(ski) + + if len(ret) == 0 { + panic("no return value specified for PairingDetailForSki") + } + + var r0 *ship_goapi.ConnectionStateDetail + if rf, ok := ret.Get(0).(func(string) *ship_goapi.ConnectionStateDetail); ok { + r0 = rf(ski) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ship_goapi.ConnectionStateDetail) + } + } + + return r0 +} + +// ServiceInterface_PairingDetailForSki_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PairingDetailForSki' +type ServiceInterface_PairingDetailForSki_Call struct { + *mock.Call +} + +// PairingDetailForSki is a helper method to define mock.On call +// - ski string +func (_e *ServiceInterface_Expecter) PairingDetailForSki(ski interface{}) *ServiceInterface_PairingDetailForSki_Call { + return &ServiceInterface_PairingDetailForSki_Call{Call: _e.mock.On("PairingDetailForSki", ski)} +} + +func (_c *ServiceInterface_PairingDetailForSki_Call) Run(run func(ski string)) *ServiceInterface_PairingDetailForSki_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ServiceInterface_PairingDetailForSki_Call) Return(_a0 *ship_goapi.ConnectionStateDetail) *ServiceInterface_PairingDetailForSki_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_PairingDetailForSki_Call) RunAndReturn(run func(string) *ship_goapi.ConnectionStateDetail) *ServiceInterface_PairingDetailForSki_Call { + _c.Call.Return(run) + return _c +} + +// RegisterRemoteSKI provides a mock function with given fields: ski +func (_m *ServiceInterface) RegisterRemoteSKI(ski string) { + _m.Called(ski) +} + +// ServiceInterface_RegisterRemoteSKI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisterRemoteSKI' +type ServiceInterface_RegisterRemoteSKI_Call struct { + *mock.Call +} + +// RegisterRemoteSKI is a helper method to define mock.On call +// - ski string +func (_e *ServiceInterface_Expecter) RegisterRemoteSKI(ski interface{}) *ServiceInterface_RegisterRemoteSKI_Call { + return &ServiceInterface_RegisterRemoteSKI_Call{Call: _e.mock.On("RegisterRemoteSKI", ski)} +} + +func (_c *ServiceInterface_RegisterRemoteSKI_Call) Run(run func(ski string)) *ServiceInterface_RegisterRemoteSKI_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ServiceInterface_RegisterRemoteSKI_Call) Return() *ServiceInterface_RegisterRemoteSKI_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_RegisterRemoteSKI_Call) RunAndReturn(run func(string)) *ServiceInterface_RegisterRemoteSKI_Call { + _c.Call.Return(run) + return _c +} + +// RemoteServiceForSKI provides a mock function with given fields: ski +func (_m *ServiceInterface) RemoteServiceForSKI(ski string) *ship_goapi.ServiceDetails { + ret := _m.Called(ski) + + if len(ret) == 0 { + panic("no return value specified for RemoteServiceForSKI") + } + + var r0 *ship_goapi.ServiceDetails + if rf, ok := ret.Get(0).(func(string) *ship_goapi.ServiceDetails); ok { + r0 = rf(ski) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*ship_goapi.ServiceDetails) + } + } + + return r0 +} + +// ServiceInterface_RemoteServiceForSKI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteServiceForSKI' +type ServiceInterface_RemoteServiceForSKI_Call struct { + *mock.Call +} + +// RemoteServiceForSKI is a helper method to define mock.On call +// - ski string +func (_e *ServiceInterface_Expecter) RemoteServiceForSKI(ski interface{}) *ServiceInterface_RemoteServiceForSKI_Call { + return &ServiceInterface_RemoteServiceForSKI_Call{Call: _e.mock.On("RemoteServiceForSKI", ski)} +} + +func (_c *ServiceInterface_RemoteServiceForSKI_Call) Run(run func(ski string)) *ServiceInterface_RemoteServiceForSKI_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ServiceInterface_RemoteServiceForSKI_Call) Return(_a0 *ship_goapi.ServiceDetails) *ServiceInterface_RemoteServiceForSKI_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_RemoteServiceForSKI_Call) RunAndReturn(run func(string) *ship_goapi.ServiceDetails) *ServiceInterface_RemoteServiceForSKI_Call { + _c.Call.Return(run) + return _c +} + +// SetAutoAccept provides a mock function with given fields: value +func (_m *ServiceInterface) SetAutoAccept(value bool) { + _m.Called(value) +} + +// ServiceInterface_SetAutoAccept_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetAutoAccept' +type ServiceInterface_SetAutoAccept_Call struct { + *mock.Call +} + +// SetAutoAccept is a helper method to define mock.On call +// - value bool +func (_e *ServiceInterface_Expecter) SetAutoAccept(value interface{}) *ServiceInterface_SetAutoAccept_Call { + return &ServiceInterface_SetAutoAccept_Call{Call: _e.mock.On("SetAutoAccept", value)} +} + +func (_c *ServiceInterface_SetAutoAccept_Call) Run(run func(value bool)) *ServiceInterface_SetAutoAccept_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *ServiceInterface_SetAutoAccept_Call) Return() *ServiceInterface_SetAutoAccept_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_SetAutoAccept_Call) RunAndReturn(run func(bool)) *ServiceInterface_SetAutoAccept_Call { + _c.Call.Return(run) + return _c +} + +// SetLogging provides a mock function with given fields: logger +func (_m *ServiceInterface) SetLogging(logger logging.LoggingInterface) { + _m.Called(logger) +} + +// ServiceInterface_SetLogging_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLogging' +type ServiceInterface_SetLogging_Call struct { + *mock.Call +} + +// SetLogging is a helper method to define mock.On call +// - logger logging.LoggingInterface +func (_e *ServiceInterface_Expecter) SetLogging(logger interface{}) *ServiceInterface_SetLogging_Call { + return &ServiceInterface_SetLogging_Call{Call: _e.mock.On("SetLogging", logger)} +} + +func (_c *ServiceInterface_SetLogging_Call) Run(run func(logger logging.LoggingInterface)) *ServiceInterface_SetLogging_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(logging.LoggingInterface)) + }) + return _c +} + +func (_c *ServiceInterface_SetLogging_Call) Return() *ServiceInterface_SetLogging_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_SetLogging_Call) RunAndReturn(run func(logging.LoggingInterface)) *ServiceInterface_SetLogging_Call { + _c.Call.Return(run) + return _c +} + +// Setup provides a mock function with given fields: +func (_m *ServiceInterface) Setup() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Setup") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ServiceInterface_Setup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Setup' +type ServiceInterface_Setup_Call struct { + *mock.Call +} + +// Setup is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) Setup() *ServiceInterface_Setup_Call { + return &ServiceInterface_Setup_Call{Call: _e.mock.On("Setup")} +} + +func (_c *ServiceInterface_Setup_Call) Run(run func()) *ServiceInterface_Setup_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_Setup_Call) Return(_a0 error) *ServiceInterface_Setup_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ServiceInterface_Setup_Call) RunAndReturn(run func() error) *ServiceInterface_Setup_Call { + _c.Call.Return(run) + return _c +} + +// Shutdown provides a mock function with given fields: +func (_m *ServiceInterface) Shutdown() { + _m.Called() +} + +// ServiceInterface_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown' +type ServiceInterface_Shutdown_Call struct { + *mock.Call +} + +// Shutdown is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) Shutdown() *ServiceInterface_Shutdown_Call { + return &ServiceInterface_Shutdown_Call{Call: _e.mock.On("Shutdown")} +} + +func (_c *ServiceInterface_Shutdown_Call) Run(run func()) *ServiceInterface_Shutdown_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_Shutdown_Call) Return() *ServiceInterface_Shutdown_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_Shutdown_Call) RunAndReturn(run func()) *ServiceInterface_Shutdown_Call { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with given fields: +func (_m *ServiceInterface) Start() { + _m.Called() +} + +// ServiceInterface_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type ServiceInterface_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +func (_e *ServiceInterface_Expecter) Start() *ServiceInterface_Start_Call { + return &ServiceInterface_Start_Call{Call: _e.mock.On("Start")} +} + +func (_c *ServiceInterface_Start_Call) Run(run func()) *ServiceInterface_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ServiceInterface_Start_Call) Return() *ServiceInterface_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_Start_Call) RunAndReturn(run func()) *ServiceInterface_Start_Call { + _c.Call.Return(run) + return _c +} + +// UnregisterRemoteSKI provides a mock function with given fields: ski +func (_m *ServiceInterface) UnregisterRemoteSKI(ski string) { + _m.Called(ski) +} + +// ServiceInterface_UnregisterRemoteSKI_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UnregisterRemoteSKI' +type ServiceInterface_UnregisterRemoteSKI_Call struct { + *mock.Call +} + +// UnregisterRemoteSKI is a helper method to define mock.On call +// - ski string +func (_e *ServiceInterface_Expecter) UnregisterRemoteSKI(ski interface{}) *ServiceInterface_UnregisterRemoteSKI_Call { + return &ServiceInterface_UnregisterRemoteSKI_Call{Call: _e.mock.On("UnregisterRemoteSKI", ski)} +} + +func (_c *ServiceInterface_UnregisterRemoteSKI_Call) Run(run func(ski string)) *ServiceInterface_UnregisterRemoteSKI_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ServiceInterface_UnregisterRemoteSKI_Call) Return() *ServiceInterface_UnregisterRemoteSKI_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_UnregisterRemoteSKI_Call) RunAndReturn(run func(string)) *ServiceInterface_UnregisterRemoteSKI_Call { + _c.Call.Return(run) + return _c +} + +// UserIsAbleToApproveOrCancelPairingRequests provides a mock function with given fields: allow +func (_m *ServiceInterface) UserIsAbleToApproveOrCancelPairingRequests(allow bool) { + _m.Called(allow) +} + +// ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UserIsAbleToApproveOrCancelPairingRequests' +type ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call struct { + *mock.Call +} + +// UserIsAbleToApproveOrCancelPairingRequests is a helper method to define mock.On call +// - allow bool +func (_e *ServiceInterface_Expecter) UserIsAbleToApproveOrCancelPairingRequests(allow interface{}) *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call { + return &ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call{Call: _e.mock.On("UserIsAbleToApproveOrCancelPairingRequests", allow)} +} + +func (_c *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call) Run(run func(allow bool)) *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call) Return() *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call) RunAndReturn(run func(bool)) *ServiceInterface_UserIsAbleToApproveOrCancelPairingRequests_Call { + _c.Call.Return(run) + return _c +} + +// NewServiceInterface creates a new instance of ServiceInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServiceInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ServiceInterface { + mock := &ServiceInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/ServiceReaderInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/ServiceReaderInterface.go new file mode 100644 index 0000000..7aaa7d2 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/ServiceReaderInterface.go @@ -0,0 +1,207 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + ship_goapi "github.com/enbility/ship-go/api" +) + +// ServiceReaderInterface is an autogenerated mock type for the ServiceReaderInterface type +type ServiceReaderInterface struct { + mock.Mock +} + +type ServiceReaderInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ServiceReaderInterface) EXPECT() *ServiceReaderInterface_Expecter { + return &ServiceReaderInterface_Expecter{mock: &_m.Mock} +} + +// RemoteSKIConnected provides a mock function with given fields: service, ski +func (_m *ServiceReaderInterface) RemoteSKIConnected(service api.ServiceInterface, ski string) { + _m.Called(service, ski) +} + +// ServiceReaderInterface_RemoteSKIConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteSKIConnected' +type ServiceReaderInterface_RemoteSKIConnected_Call struct { + *mock.Call +} + +// RemoteSKIConnected is a helper method to define mock.On call +// - service api.ServiceInterface +// - ski string +func (_e *ServiceReaderInterface_Expecter) RemoteSKIConnected(service interface{}, ski interface{}) *ServiceReaderInterface_RemoteSKIConnected_Call { + return &ServiceReaderInterface_RemoteSKIConnected_Call{Call: _e.mock.On("RemoteSKIConnected", service, ski)} +} + +func (_c *ServiceReaderInterface_RemoteSKIConnected_Call) Run(run func(service api.ServiceInterface, ski string)) *ServiceReaderInterface_RemoteSKIConnected_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.ServiceInterface), args[1].(string)) + }) + return _c +} + +func (_c *ServiceReaderInterface_RemoteSKIConnected_Call) Return() *ServiceReaderInterface_RemoteSKIConnected_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceReaderInterface_RemoteSKIConnected_Call) RunAndReturn(run func(api.ServiceInterface, string)) *ServiceReaderInterface_RemoteSKIConnected_Call { + _c.Call.Return(run) + return _c +} + +// RemoteSKIDisconnected provides a mock function with given fields: service, ski +func (_m *ServiceReaderInterface) RemoteSKIDisconnected(service api.ServiceInterface, ski string) { + _m.Called(service, ski) +} + +// ServiceReaderInterface_RemoteSKIDisconnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteSKIDisconnected' +type ServiceReaderInterface_RemoteSKIDisconnected_Call struct { + *mock.Call +} + +// RemoteSKIDisconnected is a helper method to define mock.On call +// - service api.ServiceInterface +// - ski string +func (_e *ServiceReaderInterface_Expecter) RemoteSKIDisconnected(service interface{}, ski interface{}) *ServiceReaderInterface_RemoteSKIDisconnected_Call { + return &ServiceReaderInterface_RemoteSKIDisconnected_Call{Call: _e.mock.On("RemoteSKIDisconnected", service, ski)} +} + +func (_c *ServiceReaderInterface_RemoteSKIDisconnected_Call) Run(run func(service api.ServiceInterface, ski string)) *ServiceReaderInterface_RemoteSKIDisconnected_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.ServiceInterface), args[1].(string)) + }) + return _c +} + +func (_c *ServiceReaderInterface_RemoteSKIDisconnected_Call) Return() *ServiceReaderInterface_RemoteSKIDisconnected_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceReaderInterface_RemoteSKIDisconnected_Call) RunAndReturn(run func(api.ServiceInterface, string)) *ServiceReaderInterface_RemoteSKIDisconnected_Call { + _c.Call.Return(run) + return _c +} + +// ServicePairingDetailUpdate provides a mock function with given fields: ski, detail +func (_m *ServiceReaderInterface) ServicePairingDetailUpdate(ski string, detail *ship_goapi.ConnectionStateDetail) { + _m.Called(ski, detail) +} + +// ServiceReaderInterface_ServicePairingDetailUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ServicePairingDetailUpdate' +type ServiceReaderInterface_ServicePairingDetailUpdate_Call struct { + *mock.Call +} + +// ServicePairingDetailUpdate is a helper method to define mock.On call +// - ski string +// - detail *ship_goapi.ConnectionStateDetail +func (_e *ServiceReaderInterface_Expecter) ServicePairingDetailUpdate(ski interface{}, detail interface{}) *ServiceReaderInterface_ServicePairingDetailUpdate_Call { + return &ServiceReaderInterface_ServicePairingDetailUpdate_Call{Call: _e.mock.On("ServicePairingDetailUpdate", ski, detail)} +} + +func (_c *ServiceReaderInterface_ServicePairingDetailUpdate_Call) Run(run func(ski string, detail *ship_goapi.ConnectionStateDetail)) *ServiceReaderInterface_ServicePairingDetailUpdate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(*ship_goapi.ConnectionStateDetail)) + }) + return _c +} + +func (_c *ServiceReaderInterface_ServicePairingDetailUpdate_Call) Return() *ServiceReaderInterface_ServicePairingDetailUpdate_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceReaderInterface_ServicePairingDetailUpdate_Call) RunAndReturn(run func(string, *ship_goapi.ConnectionStateDetail)) *ServiceReaderInterface_ServicePairingDetailUpdate_Call { + _c.Call.Return(run) + return _c +} + +// ServiceShipIDUpdate provides a mock function with given fields: ski, shipdID +func (_m *ServiceReaderInterface) ServiceShipIDUpdate(ski string, shipdID string) { + _m.Called(ski, shipdID) +} + +// ServiceReaderInterface_ServiceShipIDUpdate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ServiceShipIDUpdate' +type ServiceReaderInterface_ServiceShipIDUpdate_Call struct { + *mock.Call +} + +// ServiceShipIDUpdate is a helper method to define mock.On call +// - ski string +// - shipdID string +func (_e *ServiceReaderInterface_Expecter) ServiceShipIDUpdate(ski interface{}, shipdID interface{}) *ServiceReaderInterface_ServiceShipIDUpdate_Call { + return &ServiceReaderInterface_ServiceShipIDUpdate_Call{Call: _e.mock.On("ServiceShipIDUpdate", ski, shipdID)} +} + +func (_c *ServiceReaderInterface_ServiceShipIDUpdate_Call) Run(run func(ski string, shipdID string)) *ServiceReaderInterface_ServiceShipIDUpdate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *ServiceReaderInterface_ServiceShipIDUpdate_Call) Return() *ServiceReaderInterface_ServiceShipIDUpdate_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceReaderInterface_ServiceShipIDUpdate_Call) RunAndReturn(run func(string, string)) *ServiceReaderInterface_ServiceShipIDUpdate_Call { + _c.Call.Return(run) + return _c +} + +// VisibleRemoteServicesUpdated provides a mock function with given fields: service, entries +func (_m *ServiceReaderInterface) VisibleRemoteServicesUpdated(service api.ServiceInterface, entries []ship_goapi.RemoteService) { + _m.Called(service, entries) +} + +// ServiceReaderInterface_VisibleRemoteServicesUpdated_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VisibleRemoteServicesUpdated' +type ServiceReaderInterface_VisibleRemoteServicesUpdated_Call struct { + *mock.Call +} + +// VisibleRemoteServicesUpdated is a helper method to define mock.On call +// - service api.ServiceInterface +// - entries []ship_goapi.RemoteService +func (_e *ServiceReaderInterface_Expecter) VisibleRemoteServicesUpdated(service interface{}, entries interface{}) *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call { + return &ServiceReaderInterface_VisibleRemoteServicesUpdated_Call{Call: _e.mock.On("VisibleRemoteServicesUpdated", service, entries)} +} + +func (_c *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call) Run(run func(service api.ServiceInterface, entries []ship_goapi.RemoteService)) *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.ServiceInterface), args[1].([]ship_goapi.RemoteService)) + }) + return _c +} + +func (_c *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call) Return() *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call { + _c.Call.Return() + return _c +} + +func (_c *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call) RunAndReturn(run func(api.ServiceInterface, []ship_goapi.RemoteService)) *ServiceReaderInterface_VisibleRemoteServicesUpdated_Call { + _c.Call.Return(run) + return _c +} + +// NewServiceReaderInterface creates a new instance of ServiceReaderInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewServiceReaderInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ServiceReaderInterface { + mock := &ServiceReaderInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsClientInterface.go new file mode 100644 index 0000000..ab3f15b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsClientInterface.go @@ -0,0 +1,150 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// SmartEnergyManagementPsClientInterface is an autogenerated mock type for the SmartEnergyManagementPsClientInterface type +type SmartEnergyManagementPsClientInterface struct { + mock.Mock +} + +type SmartEnergyManagementPsClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *SmartEnergyManagementPsClientInterface) EXPECT() *SmartEnergyManagementPsClientInterface_Expecter { + return &SmartEnergyManagementPsClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestData provides a mock function with given fields: +func (_m *SmartEnergyManagementPsClientInterface) RequestData() (*model.MsgCounterType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RequestData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.MsgCounterType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.MsgCounterType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SmartEnergyManagementPsClientInterface_RequestData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestData' +type SmartEnergyManagementPsClientInterface_RequestData_Call struct { + *mock.Call +} + +// RequestData is a helper method to define mock.On call +func (_e *SmartEnergyManagementPsClientInterface_Expecter) RequestData() *SmartEnergyManagementPsClientInterface_RequestData_Call { + return &SmartEnergyManagementPsClientInterface_RequestData_Call{Call: _e.mock.On("RequestData")} +} + +func (_c *SmartEnergyManagementPsClientInterface_RequestData_Call) Run(run func()) *SmartEnergyManagementPsClientInterface_RequestData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SmartEnergyManagementPsClientInterface_RequestData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SmartEnergyManagementPsClientInterface_RequestData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SmartEnergyManagementPsClientInterface_RequestData_Call) RunAndReturn(run func() (*model.MsgCounterType, error)) *SmartEnergyManagementPsClientInterface_RequestData_Call { + _c.Call.Return(run) + return _c +} + +// WriteData provides a mock function with given fields: data +func (_m *SmartEnergyManagementPsClientInterface) WriteData(data *model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for WriteData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func(*model.SmartEnergyManagementPsDataType) *model.MsgCounterType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.SmartEnergyManagementPsDataType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SmartEnergyManagementPsClientInterface_WriteData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteData' +type SmartEnergyManagementPsClientInterface_WriteData_Call struct { + *mock.Call +} + +// WriteData is a helper method to define mock.On call +// - data *model.SmartEnergyManagementPsDataType +func (_e *SmartEnergyManagementPsClientInterface_Expecter) WriteData(data interface{}) *SmartEnergyManagementPsClientInterface_WriteData_Call { + return &SmartEnergyManagementPsClientInterface_WriteData_Call{Call: _e.mock.On("WriteData", data)} +} + +func (_c *SmartEnergyManagementPsClientInterface_WriteData_Call) Run(run func(data *model.SmartEnergyManagementPsDataType)) *SmartEnergyManagementPsClientInterface_WriteData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.SmartEnergyManagementPsDataType)) + }) + return _c +} + +func (_c *SmartEnergyManagementPsClientInterface_WriteData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SmartEnergyManagementPsClientInterface_WriteData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SmartEnergyManagementPsClientInterface_WriteData_Call) RunAndReturn(run func(*model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error)) *SmartEnergyManagementPsClientInterface_WriteData_Call { + _c.Call.Return(run) + return _c +} + +// NewSmartEnergyManagementPsClientInterface creates a new instance of SmartEnergyManagementPsClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSmartEnergyManagementPsClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *SmartEnergyManagementPsClientInterface { + mock := &SmartEnergyManagementPsClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsCommonInterface.go new file mode 100644 index 0000000..e77ecd6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsCommonInterface.go @@ -0,0 +1,92 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// SmartEnergyManagementPsCommonInterface is an autogenerated mock type for the SmartEnergyManagementPsCommonInterface type +type SmartEnergyManagementPsCommonInterface struct { + mock.Mock +} + +type SmartEnergyManagementPsCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *SmartEnergyManagementPsCommonInterface) EXPECT() *SmartEnergyManagementPsCommonInterface_Expecter { + return &SmartEnergyManagementPsCommonInterface_Expecter{mock: &_m.Mock} +} + +// GetData provides a mock function with given fields: +func (_m *SmartEnergyManagementPsCommonInterface) GetData() (*model.SmartEnergyManagementPsDataType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetData") + } + + var r0 *model.SmartEnergyManagementPsDataType + var r1 error + if rf, ok := ret.Get(0).(func() (*model.SmartEnergyManagementPsDataType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() *model.SmartEnergyManagementPsDataType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.SmartEnergyManagementPsDataType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SmartEnergyManagementPsCommonInterface_GetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetData' +type SmartEnergyManagementPsCommonInterface_GetData_Call struct { + *mock.Call +} + +// GetData is a helper method to define mock.On call +func (_e *SmartEnergyManagementPsCommonInterface_Expecter) GetData() *SmartEnergyManagementPsCommonInterface_GetData_Call { + return &SmartEnergyManagementPsCommonInterface_GetData_Call{Call: _e.mock.On("GetData")} +} + +func (_c *SmartEnergyManagementPsCommonInterface_GetData_Call) Run(run func()) *SmartEnergyManagementPsCommonInterface_GetData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SmartEnergyManagementPsCommonInterface_GetData_Call) Return(_a0 *model.SmartEnergyManagementPsDataType, _a1 error) *SmartEnergyManagementPsCommonInterface_GetData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SmartEnergyManagementPsCommonInterface_GetData_Call) RunAndReturn(run func() (*model.SmartEnergyManagementPsDataType, error)) *SmartEnergyManagementPsCommonInterface_GetData_Call { + _c.Call.Return(run) + return _c +} + +// NewSmartEnergyManagementPsCommonInterface creates a new instance of SmartEnergyManagementPsCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSmartEnergyManagementPsCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *SmartEnergyManagementPsCommonInterface { + mock := &SmartEnergyManagementPsCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsServerInterface.go new file mode 100644 index 0000000..d311565 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/SmartEnergyManagementPsServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// SmartEnergyManagementPsServerInterface is an autogenerated mock type for the SmartEnergyManagementPsServerInterface type +type SmartEnergyManagementPsServerInterface struct { + mock.Mock +} + +type SmartEnergyManagementPsServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *SmartEnergyManagementPsServerInterface) EXPECT() *SmartEnergyManagementPsServerInterface_Expecter { + return &SmartEnergyManagementPsServerInterface_Expecter{mock: &_m.Mock} +} + +// NewSmartEnergyManagementPsServerInterface creates a new instance of SmartEnergyManagementPsServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSmartEnergyManagementPsServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *SmartEnergyManagementPsServerInterface { + mock := &SmartEnergyManagementPsServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesClientInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesClientInterface.go new file mode 100644 index 0000000..c5498cb --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesClientInterface.go @@ -0,0 +1,270 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// TimeSeriesClientInterface is an autogenerated mock type for the TimeSeriesClientInterface type +type TimeSeriesClientInterface struct { + mock.Mock +} + +type TimeSeriesClientInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *TimeSeriesClientInterface) EXPECT() *TimeSeriesClientInterface_Expecter { + return &TimeSeriesClientInterface_Expecter{mock: &_m.Mock} +} + +// RequestConstraints provides a mock function with given fields: selector, elements +func (_m *TimeSeriesClientInterface) RequestConstraints(selector *model.TimeSeriesConstraintsListDataSelectorsType, elements *model.TimeSeriesConstraintsDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestConstraints") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.TimeSeriesConstraintsListDataSelectorsType, *model.TimeSeriesConstraintsDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.TimeSeriesConstraintsListDataSelectorsType, *model.TimeSeriesConstraintsDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.TimeSeriesConstraintsListDataSelectorsType, *model.TimeSeriesConstraintsDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesClientInterface_RequestConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestConstraints' +type TimeSeriesClientInterface_RequestConstraints_Call struct { + *mock.Call +} + +// RequestConstraints is a helper method to define mock.On call +// - selector *model.TimeSeriesConstraintsListDataSelectorsType +// - elements *model.TimeSeriesConstraintsDataElementsType +func (_e *TimeSeriesClientInterface_Expecter) RequestConstraints(selector interface{}, elements interface{}) *TimeSeriesClientInterface_RequestConstraints_Call { + return &TimeSeriesClientInterface_RequestConstraints_Call{Call: _e.mock.On("RequestConstraints", selector, elements)} +} + +func (_c *TimeSeriesClientInterface_RequestConstraints_Call) Run(run func(selector *model.TimeSeriesConstraintsListDataSelectorsType, elements *model.TimeSeriesConstraintsDataElementsType)) *TimeSeriesClientInterface_RequestConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.TimeSeriesConstraintsListDataSelectorsType), args[1].(*model.TimeSeriesConstraintsDataElementsType)) + }) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestConstraints_Call) Return(_a0 *model.MsgCounterType, _a1 error) *TimeSeriesClientInterface_RequestConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestConstraints_Call) RunAndReturn(run func(*model.TimeSeriesConstraintsListDataSelectorsType, *model.TimeSeriesConstraintsDataElementsType) (*model.MsgCounterType, error)) *TimeSeriesClientInterface_RequestConstraints_Call { + _c.Call.Return(run) + return _c +} + +// RequestData provides a mock function with given fields: selector, elements +func (_m *TimeSeriesClientInterface) RequestData(selector *model.TimeSeriesListDataSelectorsType, elements *model.TimeSeriesDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.TimeSeriesListDataSelectorsType, *model.TimeSeriesDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.TimeSeriesListDataSelectorsType, *model.TimeSeriesDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.TimeSeriesListDataSelectorsType, *model.TimeSeriesDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesClientInterface_RequestData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestData' +type TimeSeriesClientInterface_RequestData_Call struct { + *mock.Call +} + +// RequestData is a helper method to define mock.On call +// - selector *model.TimeSeriesListDataSelectorsType +// - elements *model.TimeSeriesDataElementsType +func (_e *TimeSeriesClientInterface_Expecter) RequestData(selector interface{}, elements interface{}) *TimeSeriesClientInterface_RequestData_Call { + return &TimeSeriesClientInterface_RequestData_Call{Call: _e.mock.On("RequestData", selector, elements)} +} + +func (_c *TimeSeriesClientInterface_RequestData_Call) Run(run func(selector *model.TimeSeriesListDataSelectorsType, elements *model.TimeSeriesDataElementsType)) *TimeSeriesClientInterface_RequestData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.TimeSeriesListDataSelectorsType), args[1].(*model.TimeSeriesDataElementsType)) + }) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *TimeSeriesClientInterface_RequestData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestData_Call) RunAndReturn(run func(*model.TimeSeriesListDataSelectorsType, *model.TimeSeriesDataElementsType) (*model.MsgCounterType, error)) *TimeSeriesClientInterface_RequestData_Call { + _c.Call.Return(run) + return _c +} + +// RequestDescriptions provides a mock function with given fields: selector, elements +func (_m *TimeSeriesClientInterface) RequestDescriptions(selector *model.TimeSeriesDescriptionListDataSelectorsType, elements *model.TimeSeriesDescriptionDataElementsType) (*model.MsgCounterType, error) { + ret := _m.Called(selector, elements) + + if len(ret) == 0 { + panic("no return value specified for RequestDescriptions") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.TimeSeriesDescriptionListDataSelectorsType, *model.TimeSeriesDescriptionDataElementsType) (*model.MsgCounterType, error)); ok { + return rf(selector, elements) + } + if rf, ok := ret.Get(0).(func(*model.TimeSeriesDescriptionListDataSelectorsType, *model.TimeSeriesDescriptionDataElementsType) *model.MsgCounterType); ok { + r0 = rf(selector, elements) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.TimeSeriesDescriptionListDataSelectorsType, *model.TimeSeriesDescriptionDataElementsType) error); ok { + r1 = rf(selector, elements) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesClientInterface_RequestDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestDescriptions' +type TimeSeriesClientInterface_RequestDescriptions_Call struct { + *mock.Call +} + +// RequestDescriptions is a helper method to define mock.On call +// - selector *model.TimeSeriesDescriptionListDataSelectorsType +// - elements *model.TimeSeriesDescriptionDataElementsType +func (_e *TimeSeriesClientInterface_Expecter) RequestDescriptions(selector interface{}, elements interface{}) *TimeSeriesClientInterface_RequestDescriptions_Call { + return &TimeSeriesClientInterface_RequestDescriptions_Call{Call: _e.mock.On("RequestDescriptions", selector, elements)} +} + +func (_c *TimeSeriesClientInterface_RequestDescriptions_Call) Run(run func(selector *model.TimeSeriesDescriptionListDataSelectorsType, elements *model.TimeSeriesDescriptionDataElementsType)) *TimeSeriesClientInterface_RequestDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.TimeSeriesDescriptionListDataSelectorsType), args[1].(*model.TimeSeriesDescriptionDataElementsType)) + }) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestDescriptions_Call) Return(_a0 *model.MsgCounterType, _a1 error) *TimeSeriesClientInterface_RequestDescriptions_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesClientInterface_RequestDescriptions_Call) RunAndReturn(run func(*model.TimeSeriesDescriptionListDataSelectorsType, *model.TimeSeriesDescriptionDataElementsType) (*model.MsgCounterType, error)) *TimeSeriesClientInterface_RequestDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// WriteData provides a mock function with given fields: data +func (_m *TimeSeriesClientInterface) WriteData(data []model.TimeSeriesDataType) (*model.MsgCounterType, error) { + ret := _m.Called(data) + + if len(ret) == 0 { + panic("no return value specified for WriteData") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]model.TimeSeriesDataType) (*model.MsgCounterType, error)); ok { + return rf(data) + } + if rf, ok := ret.Get(0).(func([]model.TimeSeriesDataType) *model.MsgCounterType); ok { + r0 = rf(data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]model.TimeSeriesDataType) error); ok { + r1 = rf(data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesClientInterface_WriteData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteData' +type TimeSeriesClientInterface_WriteData_Call struct { + *mock.Call +} + +// WriteData is a helper method to define mock.On call +// - data []model.TimeSeriesDataType +func (_e *TimeSeriesClientInterface_Expecter) WriteData(data interface{}) *TimeSeriesClientInterface_WriteData_Call { + return &TimeSeriesClientInterface_WriteData_Call{Call: _e.mock.On("WriteData", data)} +} + +func (_c *TimeSeriesClientInterface_WriteData_Call) Run(run func(data []model.TimeSeriesDataType)) *TimeSeriesClientInterface_WriteData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.TimeSeriesDataType)) + }) + return _c +} + +func (_c *TimeSeriesClientInterface_WriteData_Call) Return(_a0 *model.MsgCounterType, _a1 error) *TimeSeriesClientInterface_WriteData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesClientInterface_WriteData_Call) RunAndReturn(run func([]model.TimeSeriesDataType) (*model.MsgCounterType, error)) *TimeSeriesClientInterface_WriteData_Call { + _c.Call.Return(run) + return _c +} + +// NewTimeSeriesClientInterface creates a new instance of TimeSeriesClientInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTimeSeriesClientInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *TimeSeriesClientInterface { + mock := &TimeSeriesClientInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesCommonInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesCommonInterface.go new file mode 100644 index 0000000..667242a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesCommonInterface.go @@ -0,0 +1,208 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// TimeSeriesCommonInterface is an autogenerated mock type for the TimeSeriesCommonInterface type +type TimeSeriesCommonInterface struct { + mock.Mock +} + +type TimeSeriesCommonInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *TimeSeriesCommonInterface) EXPECT() *TimeSeriesCommonInterface_Expecter { + return &TimeSeriesCommonInterface_Expecter{mock: &_m.Mock} +} + +// GetConstraints provides a mock function with given fields: +func (_m *TimeSeriesCommonInterface) GetConstraints() ([]model.TimeSeriesConstraintsDataType, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetConstraints") + } + + var r0 []model.TimeSeriesConstraintsDataType + var r1 error + if rf, ok := ret.Get(0).(func() ([]model.TimeSeriesConstraintsDataType, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []model.TimeSeriesConstraintsDataType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.TimeSeriesConstraintsDataType) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesCommonInterface_GetConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConstraints' +type TimeSeriesCommonInterface_GetConstraints_Call struct { + *mock.Call +} + +// GetConstraints is a helper method to define mock.On call +func (_e *TimeSeriesCommonInterface_Expecter) GetConstraints() *TimeSeriesCommonInterface_GetConstraints_Call { + return &TimeSeriesCommonInterface_GetConstraints_Call{Call: _e.mock.On("GetConstraints")} +} + +func (_c *TimeSeriesCommonInterface_GetConstraints_Call) Run(run func()) *TimeSeriesCommonInterface_GetConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetConstraints_Call) Return(_a0 []model.TimeSeriesConstraintsDataType, _a1 error) *TimeSeriesCommonInterface_GetConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetConstraints_Call) RunAndReturn(run func() ([]model.TimeSeriesConstraintsDataType, error)) *TimeSeriesCommonInterface_GetConstraints_Call { + _c.Call.Return(run) + return _c +} + +// GetDataForFilter provides a mock function with given fields: filter +func (_m *TimeSeriesCommonInterface) GetDataForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDataForFilter") + } + + var r0 []model.TimeSeriesDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.TimeSeriesDescriptionDataType) []model.TimeSeriesDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.TimeSeriesDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.TimeSeriesDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesCommonInterface_GetDataForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDataForFilter' +type TimeSeriesCommonInterface_GetDataForFilter_Call struct { + *mock.Call +} + +// GetDataForFilter is a helper method to define mock.On call +// - filter model.TimeSeriesDescriptionDataType +func (_e *TimeSeriesCommonInterface_Expecter) GetDataForFilter(filter interface{}) *TimeSeriesCommonInterface_GetDataForFilter_Call { + return &TimeSeriesCommonInterface_GetDataForFilter_Call{Call: _e.mock.On("GetDataForFilter", filter)} +} + +func (_c *TimeSeriesCommonInterface_GetDataForFilter_Call) Run(run func(filter model.TimeSeriesDescriptionDataType)) *TimeSeriesCommonInterface_GetDataForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.TimeSeriesDescriptionDataType)) + }) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetDataForFilter_Call) Return(_a0 []model.TimeSeriesDataType, _a1 error) *TimeSeriesCommonInterface_GetDataForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetDataForFilter_Call) RunAndReturn(run func(model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error)) *TimeSeriesCommonInterface_GetDataForFilter_Call { + _c.Call.Return(run) + return _c +} + +// GetDescriptionsForFilter provides a mock function with given fields: filter +func (_m *TimeSeriesCommonInterface) GetDescriptionsForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDescriptionDataType, error) { + ret := _m.Called(filter) + + if len(ret) == 0 { + panic("no return value specified for GetDescriptionsForFilter") + } + + var r0 []model.TimeSeriesDescriptionDataType + var r1 error + if rf, ok := ret.Get(0).(func(model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDescriptionDataType, error)); ok { + return rf(filter) + } + if rf, ok := ret.Get(0).(func(model.TimeSeriesDescriptionDataType) []model.TimeSeriesDescriptionDataType); ok { + r0 = rf(filter) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.TimeSeriesDescriptionDataType) + } + } + + if rf, ok := ret.Get(1).(func(model.TimeSeriesDescriptionDataType) error); ok { + r1 = rf(filter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// TimeSeriesCommonInterface_GetDescriptionsForFilter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDescriptionsForFilter' +type TimeSeriesCommonInterface_GetDescriptionsForFilter_Call struct { + *mock.Call +} + +// GetDescriptionsForFilter is a helper method to define mock.On call +// - filter model.TimeSeriesDescriptionDataType +func (_e *TimeSeriesCommonInterface_Expecter) GetDescriptionsForFilter(filter interface{}) *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call { + return &TimeSeriesCommonInterface_GetDescriptionsForFilter_Call{Call: _e.mock.On("GetDescriptionsForFilter", filter)} +} + +func (_c *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call) Run(run func(filter model.TimeSeriesDescriptionDataType)) *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.TimeSeriesDescriptionDataType)) + }) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call) Return(_a0 []model.TimeSeriesDescriptionDataType, _a1 error) *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call) RunAndReturn(run func(model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDescriptionDataType, error)) *TimeSeriesCommonInterface_GetDescriptionsForFilter_Call { + _c.Call.Return(run) + return _c +} + +// NewTimeSeriesCommonInterface creates a new instance of TimeSeriesCommonInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTimeSeriesCommonInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *TimeSeriesCommonInterface { + mock := &TimeSeriesCommonInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesServerInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesServerInterface.go new file mode 100644 index 0000000..e9de6a8 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/TimeSeriesServerInterface.go @@ -0,0 +1,32 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// TimeSeriesServerInterface is an autogenerated mock type for the TimeSeriesServerInterface type +type TimeSeriesServerInterface struct { + mock.Mock +} + +type TimeSeriesServerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *TimeSeriesServerInterface) EXPECT() *TimeSeriesServerInterface_Expecter { + return &TimeSeriesServerInterface_Expecter{mock: &_m.Mock} +} + +// NewTimeSeriesServerInterface creates a new instance of TimeSeriesServerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewTimeSeriesServerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *TimeSeriesServerInterface { + mock := &TimeSeriesServerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseBaseInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseBaseInterface.go new file mode 100644 index 0000000..db3fe67 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseBaseInterface.go @@ -0,0 +1,322 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// UseCaseBaseInterface is an autogenerated mock type for the UseCaseBaseInterface type +type UseCaseBaseInterface struct { + mock.Mock +} + +type UseCaseBaseInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *UseCaseBaseInterface) EXPECT() *UseCaseBaseInterface_Expecter { + return &UseCaseBaseInterface_Expecter{mock: &_m.Mock} +} + +// AddUseCase provides a mock function with given fields: +func (_m *UseCaseBaseInterface) AddUseCase() { + _m.Called() +} + +// UseCaseBaseInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type UseCaseBaseInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *UseCaseBaseInterface_Expecter) AddUseCase() *UseCaseBaseInterface_AddUseCase_Call { + return &UseCaseBaseInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *UseCaseBaseInterface_AddUseCase_Call) Run(run func()) *UseCaseBaseInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseBaseInterface_AddUseCase_Call) Return() *UseCaseBaseInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseBaseInterface_AddUseCase_Call) RunAndReturn(run func()) *UseCaseBaseInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *UseCaseBaseInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// UseCaseBaseInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type UseCaseBaseInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *UseCaseBaseInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *UseCaseBaseInterface_AvailableScenariosForEntity_Call { + return &UseCaseBaseInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *UseCaseBaseInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *UseCaseBaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *UseCaseBaseInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *UseCaseBaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseBaseInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *UseCaseBaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *UseCaseBaseInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UseCaseBaseInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type UseCaseBaseInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *UseCaseBaseInterface_Expecter) IsCompatibleEntityType(entity interface{}) *UseCaseBaseInterface_IsCompatibleEntityType_Call { + return &UseCaseBaseInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *UseCaseBaseInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *UseCaseBaseInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *UseCaseBaseInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *UseCaseBaseInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseBaseInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *UseCaseBaseInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *UseCaseBaseInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *UseCaseBaseInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call { + return &UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *UseCaseBaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *UseCaseBaseInterface) RemoteEntitiesScenarios() []api.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []api.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []api.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.RemoteEntityScenarios) + } + } + + return r0 +} + +// UseCaseBaseInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type UseCaseBaseInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *UseCaseBaseInterface_Expecter) RemoteEntitiesScenarios() *UseCaseBaseInterface_RemoteEntitiesScenarios_Call { + return &UseCaseBaseInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *UseCaseBaseInterface_RemoteEntitiesScenarios_Call) Run(run func()) *UseCaseBaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseBaseInterface_RemoteEntitiesScenarios_Call) Return(_a0 []api.RemoteEntityScenarios) *UseCaseBaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseBaseInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []api.RemoteEntityScenarios) *UseCaseBaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *UseCaseBaseInterface) RemoveUseCase() { + _m.Called() +} + +// UseCaseBaseInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type UseCaseBaseInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *UseCaseBaseInterface_Expecter) RemoveUseCase() *UseCaseBaseInterface_RemoveUseCase_Call { + return &UseCaseBaseInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *UseCaseBaseInterface_RemoveUseCase_Call) Run(run func()) *UseCaseBaseInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseBaseInterface_RemoveUseCase_Call) Return() *UseCaseBaseInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseBaseInterface_RemoveUseCase_Call) RunAndReturn(run func()) *UseCaseBaseInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *UseCaseBaseInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// UseCaseBaseInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type UseCaseBaseInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *UseCaseBaseInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *UseCaseBaseInterface_UpdateUseCaseAvailability_Call { + return &UseCaseBaseInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *UseCaseBaseInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *UseCaseBaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *UseCaseBaseInterface_UpdateUseCaseAvailability_Call) Return() *UseCaseBaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseBaseInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *UseCaseBaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewUseCaseBaseInterface creates a new instance of UseCaseBaseInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUseCaseBaseInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *UseCaseBaseInterface { + mock := &UseCaseBaseInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseInterface.go b/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseInterface.go new file mode 100644 index 0000000..c7136f6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/mocks/UseCaseInterface.go @@ -0,0 +1,354 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// UseCaseInterface is an autogenerated mock type for the UseCaseInterface type +type UseCaseInterface struct { + mock.Mock +} + +type UseCaseInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *UseCaseInterface) EXPECT() *UseCaseInterface_Expecter { + return &UseCaseInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *UseCaseInterface) AddFeatures() { + _m.Called() +} + +// UseCaseInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type UseCaseInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *UseCaseInterface_Expecter) AddFeatures() *UseCaseInterface_AddFeatures_Call { + return &UseCaseInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *UseCaseInterface_AddFeatures_Call) Run(run func()) *UseCaseInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseInterface_AddFeatures_Call) Return() *UseCaseInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseInterface_AddFeatures_Call) RunAndReturn(run func()) *UseCaseInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *UseCaseInterface) AddUseCase() { + _m.Called() +} + +// UseCaseInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type UseCaseInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *UseCaseInterface_Expecter) AddUseCase() *UseCaseInterface_AddUseCase_Call { + return &UseCaseInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *UseCaseInterface_AddUseCase_Call) Run(run func()) *UseCaseInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseInterface_AddUseCase_Call) Return() *UseCaseInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseInterface_AddUseCase_Call) RunAndReturn(run func()) *UseCaseInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *UseCaseInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// UseCaseInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type UseCaseInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *UseCaseInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *UseCaseInterface_AvailableScenariosForEntity_Call { + return &UseCaseInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *UseCaseInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *UseCaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *UseCaseInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *UseCaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *UseCaseInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *UseCaseInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UseCaseInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type UseCaseInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *UseCaseInterface_Expecter) IsCompatibleEntityType(entity interface{}) *UseCaseInterface_IsCompatibleEntityType_Call { + return &UseCaseInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *UseCaseInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *UseCaseInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *UseCaseInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *UseCaseInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *UseCaseInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *UseCaseInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UseCaseInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type UseCaseInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *UseCaseInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *UseCaseInterface_IsScenarioAvailableAtEntity_Call { + return &UseCaseInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *UseCaseInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *UseCaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *UseCaseInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *UseCaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *UseCaseInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *UseCaseInterface) RemoteEntitiesScenarios() []api.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []api.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []api.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.RemoteEntityScenarios) + } + } + + return r0 +} + +// UseCaseInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type UseCaseInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *UseCaseInterface_Expecter) RemoteEntitiesScenarios() *UseCaseInterface_RemoteEntitiesScenarios_Call { + return &UseCaseInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *UseCaseInterface_RemoteEntitiesScenarios_Call) Run(run func()) *UseCaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseInterface_RemoteEntitiesScenarios_Call) Return(_a0 []api.RemoteEntityScenarios) *UseCaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UseCaseInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []api.RemoteEntityScenarios) *UseCaseInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *UseCaseInterface) RemoveUseCase() { + _m.Called() +} + +// UseCaseInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type UseCaseInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *UseCaseInterface_Expecter) RemoveUseCase() *UseCaseInterface_RemoveUseCase_Call { + return &UseCaseInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *UseCaseInterface_RemoveUseCase_Call) Run(run func()) *UseCaseInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UseCaseInterface_RemoveUseCase_Call) Return() *UseCaseInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseInterface_RemoveUseCase_Call) RunAndReturn(run func()) *UseCaseInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *UseCaseInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// UseCaseInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type UseCaseInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *UseCaseInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *UseCaseInterface_UpdateUseCaseAvailability_Call { + return &UseCaseInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *UseCaseInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *UseCaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *UseCaseInterface_UpdateUseCaseAvailability_Call) Return() *UseCaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *UseCaseInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *UseCaseInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewUseCaseInterface creates a new instance of UseCaseInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUseCaseInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *UseCaseInterface { + mock := &UseCaseInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/service/service.go b/src/eebus-bridge/third_party/eebus-go/service/service.go new file mode 100644 index 0000000..cddbd36 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/service/service.go @@ -0,0 +1,244 @@ +package service + +import ( + "crypto/x509" + "errors" + "fmt" + "strconv" + "sync" + + "github.com/enbility/eebus-go/api" + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/cert" + "github.com/enbility/ship-go/hub" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/mdns" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +// A service is the central element of an EEBUS service +// including its websocket server and a zeroconf service. +type Service struct { + configuration *api.Configuration + + // The local service details + localService *shipapi.ServiceDetails + + // Connection Registrations + connectionsHub shipapi.HubInterface + + // The SPINE specific device definition + spineLocalDevice spineapi.DeviceLocalInterface + + serviceHandler api.ServiceReaderInterface + + usecases []api.UseCaseInterface + + // defines wether a user interaction to accept pairing is possible + isPairingPossible bool + + startOnce sync.Once + + mux sync.Mutex +} + +// creates a new EEBUS service +func NewService(configuration *api.Configuration, serviceHandler api.ServiceReaderInterface) *Service { + return &Service{ + configuration: configuration, + serviceHandler: serviceHandler, + } +} + +var _ api.ServiceInterface = (*Service)(nil) + +// Starts the service by initializeing mDNS and the server. +func (s *Service) Setup() error { + sd := s.configuration + + if len(sd.Certificate().Certificate) == 0 { + return errors.New("missing certificate") + } + + leaf, err := x509.ParseCertificate(sd.Certificate().Certificate[0]) + if err != nil { + return err + } + + ski, err := cert.SkiFromCertificate(leaf) + if err != nil { + return err + } + + // Initialize the local service + // The ShipID is defined in SHIP Spec 3. as + // Each SHIP node has a globally unique SHIP ID. The SHIP ID is used to uniquely identify a SHIP node, + // e.g. in its service discovery. This ID is present in the mDNS/DNS-SD local service discovery; + // In SHIP 13.4.6.2 the accessMethods.id is defined as + // The originator's unique ID + // I assume those two to mean the same. + // TODO: clarify + s.localService = shipapi.NewServiceDetails(ski) + s.localService.SetShipID(sd.Identifier()) + s.localService.SetDeviceType(string(sd.DeviceType())) + + logging.Log().Info("Local SKI:", ski) + + vendor := sd.VendorCode() + if vendor == "" { + vendor = sd.DeviceBrand() + } + + serial := sd.DeviceSerialNumber() + if serial != "" { + serial = fmt.Sprintf("-%s", serial) + } + + // Create the SPINE device address, according to Protocol Specification 7.1.1.2 + var deviceAddress string + vendorType := "i" + if _, err := strconv.Atoi(vendor); err != nil { + vendorType = "n" + } + deviceAddress = fmt.Sprintf("d:_%s:%s_%s%s", vendorType, vendor, sd.DeviceModel(), serial) + + if len(deviceAddress) > 256 { + return fmt.Errorf("generated device address may not be longer than 256 characters: %s", deviceAddress) + } + + // Create the local SPINE device + s.spineLocalDevice = spine.NewDeviceLocal( + sd.DeviceBrand(), + sd.DeviceModel(), + sd.DeviceSerialNumber(), + sd.Identifier(), + deviceAddress, + sd.DeviceType(), + sd.FeatureSet(), + ) + + // Create the device entities and add it to the SPINE device + for _, entityType := range sd.EntityTypes() { + entityAddressId := model.AddressEntityType(len(s.spineLocalDevice.Entities())) + entityAddress := []model.AddressEntityType{entityAddressId} + entity := spine.NewEntityLocal(s.spineLocalDevice, entityType, entityAddress, sd.HeartbeatTimeout()) + s.spineLocalDevice.AddEntity(entity) + } + + // setup mDNS + mdns := mdns.NewMDNS( + s.localService.SKI(), + sd.DeviceBrand(), + sd.DeviceModel(), + string(sd.DeviceType()), + sd.Identifier(), + sd.MdnsServiceName(), + sd.Port(), + sd.Interfaces(), + sd.MdnsProviderSelection(), + ) + + // Setup connections hub with mDNS and websocket connection handling + s.connectionsHub = hub.NewHub(s, mdns, s.configuration.Port(), s.configuration.Certificate(), s.localService) + + return nil +} + +// Starts the service +func (s *Service) Start() { + s.startOnce.Do(func() { + s.connectionsHub.Start() + }) +} + +// Shutdown all services and stop the server. +func (s *Service) Shutdown() { + // Shut down all running connections + s.connectionsHub.Shutdown() +} + +// add a use case to the service +func (s *Service) AddUseCase(useCase api.UseCaseInterface) { + s.usecases = append(s.usecases, useCase) + + useCase.AddFeatures() + useCase.AddUseCase() +} + +func (s *Service) Configuration() *api.Configuration { + return s.configuration +} + +func (s *Service) LocalService() *shipapi.ServiceDetails { + return s.localService +} + +func (s *Service) LocalDevice() spineapi.DeviceLocalInterface { + return s.spineLocalDevice +} + +// Sets a custom logging implementation +// By default NoLogging is used, so no logs are printed +func (s *Service) SetLogging(logger logging.LoggingInterface) { + if logger == nil { + return + } + logging.SetLogging(logger) +} + +// Get the current pairing details for a given SKI +func (s *Service) PairingDetailForSki(ski string) *shipapi.ConnectionStateDetail { + return s.connectionsHub.PairingDetailForSki(ski) +} + +// Returns the Service detail of a given remote SKI +func (s *Service) RemoteServiceForSKI(ski string) *shipapi.ServiceDetails { + return s.connectionsHub.ServiceForSKI(ski) +} + +func (s *Service) SetAutoAccept(value bool) { + s.localService.SetAutoAccept(value) + s.connectionsHub.SetAutoAccept(value) +} + +func (s *Service) IsAutoAcceptEnabled() bool { + return s.localService.AutoAccept() +} + +// Sets the SKI as being paired +// and connect it if paired and not currently being connected +func (s *Service) RegisterRemoteSKI(ski string) { + s.connectionsHub.RegisterRemoteSKI(ski) +} + +// Sets the SKI as not being paired +// and disconnects it if connected +func (s *Service) UnregisterRemoteSKI(ski string) { + s.connectionsHub.UnregisterRemoteSKI(ski) +} + +// Close a connection to a remote SKI +func (s *Service) DisconnectSKI(ski string, reason string) { + s.connectionsHub.DisconnectSKI(ski, reason) +} + +// Cancels the pairing process for a SKI +func (s *Service) CancelPairingWithSKI(ski string) { + s.connectionsHub.CancelPairingWithSKI(ski) +} + +// Define wether the user is able to react to an incoming pairing request +// +// Call this with `true` e.g. if the user is currently using a web interface +// where an incoming request can be accepted or denied +// +// Default is set to false, meaning every incoming pairing request will be +// automatically denied +func (s *Service) UserIsAbleToApproveOrCancelPairingRequests(allow bool) { + s.mux.Lock() + defer s.mux.Unlock() + + s.isPairingPossible = allow +} diff --git a/src/eebus-bridge/third_party/eebus-go/service/service_hub.go b/src/eebus-bridge/third_party/eebus-go/service/service_hub.go new file mode 100644 index 0000000..27230d7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/service/service_hub.go @@ -0,0 +1,53 @@ +package service + +import ( + shipapi "github.com/enbility/ship-go/api" +) + +var _ shipapi.HubReaderInterface = (*Service)(nil) + +// report a connection to a SKI +func (s *Service) RemoteSKIConnected(ski string) { + s.serviceHandler.RemoteSKIConnected(s, ski) +} + +// report a disconnection to a SKI +func (s *Service) RemoteSKIDisconnected(ski string) { + if s.spineLocalDevice != nil { + s.spineLocalDevice.RemoveRemoteDeviceConnection(ski) + } + + s.serviceHandler.RemoteSKIDisconnected(s, ski) +} + +// report an approved handshake by a remote device +func (s *Service) SetupRemoteDevice(ski string, writeI shipapi.ShipConnectionDataWriterInterface) shipapi.ShipConnectionDataReaderInterface { + return s.LocalDevice().SetupRemoteDevice(ski, writeI) +} + +// report all currently visible EEBUS services +func (s *Service) VisibleRemoteServicesUpdated(entries []shipapi.RemoteService) { + s.serviceHandler.VisibleRemoteServicesUpdated(s, entries) +} + +// Provides the SHIP ID the remote service reported during the handshake process +// This needs to be persisted and passed on for future remote service connections +// when using `PairRemoteService` +func (s *Service) ServiceShipIDUpdate(ski string, shipdID string) { + s.serviceHandler.ServiceShipIDUpdate(ski, shipdID) +} + +// Provides the current pairing state for the remote service +// This is called whenever the state changes and can be used to +// provide user information for the pairing/connection process +func (s *Service) ServicePairingDetailUpdate(ski string, detail *shipapi.ConnectionStateDetail) { + s.serviceHandler.ServicePairingDetailUpdate(ski, detail) +} + +// return if the user is still able to trust the connection +func (s *Service) AllowWaitingForTrust(ski string) bool { + s.mux.Lock() + defer s.mux.Unlock() + + return s.isPairingPossible +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/README.md b/src/eebus-bridge/third_party/eebus-go/usecases/README.md new file mode 100644 index 0000000..47a977b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/README.md @@ -0,0 +1,36 @@ +# Use Cases + +This folder contains various use case implementations for different use case actors. Each use case provides a scenario based API and messages for event / data updates. + +Actors: + +- `cem`: Customer Energy Management + + Use Cases: + - `cevc`: Coordinated EV Charging + - `evcc`: EV Commissioning and Configuration + - `evcem`: EV Charging Electricity Measurement + - `evsecc`: EVSE Commissioning and Configuration + - `evsoc`: EV State Of Charge + - `opev`: Overload Protection by EV Charging Current Curtailment + - `oscev`: Optimization of Self-Consumption During EV Charging + - `vabd`: Visualization of Aggregated Battery Data + - `vapd`: Visualization of Aggregated Photovoltaic Data + +- `cs`: Controllable System + + Use Cases: + - `lpc`: Limitation of Power Consumption + - `lpp`: Limitation of Power Production + +- `eg`: Energy Guard + + Use Cases: + - `lpc`: Limitation of Power Consumption + - `lpp`: Limitation of Power Production + +- `ma`: Monitoring Appliance + + Use Cases: + - `mpc`: Monitoring of Power Consumption + - `mgcp`: Monitoring of Grid Connection Point diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/api.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/api.go new file mode 100644 index 0000000..898b38b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/api.go @@ -0,0 +1,7 @@ +package api + +import "github.com/enbility/spine-go/model" + +//go:generate mockery + +var PhaseNameMapping = []model.ElectricalConnectionPhaseNameType{model.ElectricalConnectionPhaseNameTypeA, model.ElectricalConnectionPhaseNameTypeB, model.ElectricalConnectionPhaseNameTypeC} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_cevc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_cevc.go new file mode 100644 index 0000000..13c1862 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_cevc.go @@ -0,0 +1,91 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Customer Energy Management +// UseCase: Coordinated EV Charging +type CemCEVCInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // returns the current charging stratey + // + // parameters: + // - entity: the entity of the EV + // + // returns EVChargeStrategyTypeUnknown if it could not be determined, e.g. + // if the vehicle communication is via IEC61851 or the EV doesn't provide + // any information about its charging mode or plan + ChargeStrategy(remoteEntity spineapi.EntityRemoteInterface) EVChargeStrategyType + + // returns the current energy demand + // + // parameters: + // - entity: the entity of the EV + // + // return values: + // - EVDemand: details about the actual demands from the EV + // - error: if no data is available + // + // if duration is 0, direct charging is active, otherwise timed charging is active + EnergyDemand(remoteEntity spineapi.EntityRemoteInterface) (Demand, error) + + // Scenario 2 + + TimeSlotConstraints(entity spineapi.EntityRemoteInterface) (TimeSlotConstraints, error) + + // send power limits to the EV + // + // parameters: + // - entity: the entity of the EV + // - data: the power limits + // + // if no data is provided, default power limits with the max possible value for 7 days will be sent + WritePowerLimits(entity spineapi.EntityRemoteInterface, data []DurationSlotValue) error + + // Scenario 3 + + // return the current incentive constraints + // + // parameters: + // - entity: the entity of the EV + IncentiveConstraints(entity spineapi.EntityRemoteInterface) (IncentiveSlotConstraints, error) + + // send new incentives to the EV + // + // parameters: + // - entity: the entity of the EV + // - data: the incentive descriptions + WriteIncentiveTableDescriptions(entity spineapi.EntityRemoteInterface, data []IncentiveTariffDescription) error + + // send incentives to the EV + // + // parameters: + // - entity: the entity of the EV + // - data: the incentives + // + // if no data is provided, default incentives with the same price for 7 days will be sent + WriteIncentives(entity spineapi.EntityRemoteInterface, data []DurationSlotValue) error + + // Scenario 4 + + // return the current charge plan constraints + // + // parameters: + // - entity: the entity of the EV + ChargePlanConstraints(entity spineapi.EntityRemoteInterface) ([]DurationSlotValue, error) + + // return the current charge plan of the EV + // + // parameters: + // - entity: the entity of the EV + ChargePlan(entity spineapi.EntityRemoteInterface) (ChargePlan, error) + + // Scenario 5 & 6 + + // this is automatically covered by the SPINE implementation +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcc.go new file mode 100644 index 0000000..f8b3fdb --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcc.go @@ -0,0 +1,77 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Customer Energy Management +// UseCase: EV Commissioning and Configuration +type CemEVCCInterface interface { + api.UseCaseInterface + + // return the current charge state of the EV + // + // parameters: + // - entity: the entity of the EV + ChargeState(entity spineapi.EntityRemoteInterface) (EVChargeStateType, error) + + // Scenario 1 & 8 + + // return if the EV is connected + // + // parameters: + // - entity: the entity of the EV + EVConnected(entity spineapi.EntityRemoteInterface) bool + + // Scenario 2 + + // return the current communication standard type used to communicate between EVSE and EV + // + // parameters: + // - entity: the entity of the EV + CommunicationStandard(entity spineapi.EntityRemoteInterface) (model.DeviceConfigurationKeyValueStringType, error) + + // Scenario 3 + + // return if the EV supports asymmetric charging + // + // parameters: + // - entity: the entity of the EV + AsymmetricChargingSupport(entity spineapi.EntityRemoteInterface) (bool, error) + + // Scenario 4 + + // return the identifications of the currently connected EV or nil if not available + // these can be multiple, e.g. PCID, Mac Address, RFID + // + // parameters: + // - entity: the entity of the EV + Identifications(entity spineapi.EntityRemoteInterface) ([]IdentificationItem, error) + + // Scenario 5 + + // the manufacturer data of an EVSE + // returns deviceName, serialNumber, error + // + // parameters: + // - entity: the entity of the EV + ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error) + + // Scenario 6 + + // return the minimum, maximum charging and, standby power of the connected EV + // + // parameters: + // - entity: the entity of the EV + ChargingPowerLimits(entity spineapi.EntityRemoteInterface) (float64, float64, float64, error) + + // Scenario 7 + + // is the EV in sleep mode + // + // parameters: + // - entity: the entity of the EV + IsInSleepMode(entity spineapi.EntityRemoteInterface) (bool, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcem.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcem.go new file mode 100644 index 0000000..af7d00d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evcem.go @@ -0,0 +1,42 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Customer Energy Management +// UseCase: EV Charging Electricity Measurement +type CemEVCEMInterface interface { + api.UseCaseInterface + + // return the number of ac connected phases of the EV or 0 if it is unknown + // + // parameters: + // - entity: the entity of the EV + PhasesConnected(entity spineapi.EntityRemoteInterface) (uint, error) + + // Scenario 1 + + // return the last current measurement for each phase of the connected EV + // + // parameters: + // - entity: the entity of the EV + CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 2 + + // return the last power measurement for each phase of the connected EV + // + // parameters: + // - entity: the entity of the EV + PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 3 + + // return the charged energy measurement in Wh of the connected EV + // + // parameters: + // - entity: the entity of the EV + EnergyCharged(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsecc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsecc.go new file mode 100644 index 0000000..1d7aaf3 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsecc.go @@ -0,0 +1,29 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Customer Energy Management +// UseCase: EVSE Commissioning and Configuration +type CemEVSECCInterface interface { + api.UseCaseInterface + + // the manufacturer data of an EVSE + // + // parameters: + // - entity: the entity of the EV + // + // returns deviceName, serialNumber, error + ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error) + + // the operating state data of an EVSE + // + // parameters: + // - entity: the entity of the EV + // + // returns operatingState, lastErrorCode, error + OperatingState(entity spineapi.EntityRemoteInterface) (model.DeviceDiagnosisOperatingStateType, string, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsoc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsoc.go new file mode 100644 index 0000000..7ccc2fd --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_evsoc.go @@ -0,0 +1,22 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Customer Energy Management +// UseCase: EV State Of Charge +type CemEVSOCInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the EVscurrent state of charge of the EV or an error it is unknown + // + // parameters: + // - entity: the entity of the EV + StateOfCharge(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 2 to 4 are not supported, as there is no EV supporting this as of today +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_opev.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_opev.go new file mode 100644 index 0000000..1746a55 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_opev.go @@ -0,0 +1,69 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Customer Energy Management +// UseCase: Overload Protection by EV Charging Current Curtailment +type CemOPEVInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the min, max, default limits for each phase of the connected EV + // + // parameters: + // - entity: the entity of the EV + CurrentLimits(entity spineapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) + + // return the current loadcontrol obligation limits + // + // parameters: + // - entity: the entity of the EV + // + // return values: + // - limits: per phase data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + LoadControlLimits(entity spineapi.EntityRemoteInterface) (limits []LoadLimitsPhase, resultErr error) + + // send new LoadControlLimits to the remote EV + // + // parameters: + // - entity: the entity of the EV + // - limits: a set of limits containing phase specific limit data + // - resultCB: callback function for handling the result response + // + // Sets a maximum A limit for each phase that the EV may not exceed. + // Mainly used for implementing overload protection of the site or limiting the + // maximum charge power of EVs when the EV and EVSE communicate via IEC61851 + // and with ISO15118 if the EV does not support the Optimization of Self Consumption + // usecase. + // + // note: + // For obligations to work for optimizing solar excess power, the EV needs to + // have an energy demand. Recommendations work even if the EV does not have an active + // energy demand, given it communicated with the EVSE via ISO15118 and supports the usecase. + // In ISO15118-2 the usecase is only supported via VAS extensions which are vendor specific + // and needs to have specific EVSE support for the specific EV brand. + // In ISO15118-20 this is a standard feature which does not need special support on the EVSE. + WriteLoadControlLimits( + entity spineapi.EntityRemoteInterface, + limits []LoadLimitsPhase, + resultCB func(result model.ResultDataType), + ) (*model.MsgCounterType, error) + + // Scenario 2 + + // this is automatically covered by the SPINE implementation + + // Scenario 3 + + // this is covered by the central CEM interface implementation + // use that one to set the CEM's operation state which will inform all remote devices +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_oscev.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_oscev.go new file mode 100644 index 0000000..c9cabd6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_oscev.go @@ -0,0 +1,62 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Customer Energy Management +// UseCase: Optimization of Self-Consumption During EV Charging +type CemOSCEVInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the min, max, default limits for each phase of the connected EV + // + // parameters: + // - entity: the entity of the EV + CurrentLimits(entity spineapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) + + // return the current loadcontrol recommendation limits + // + // parameters: + // - entity: the entity of the EV + // + // return values: + // - limits: per phase data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + LoadControlLimits(entity spineapi.EntityRemoteInterface) (limits []LoadLimitsPhase, resultErr error) + + // send new LoadControlLimits to the remote EV + // + // parameters: + // - entity: the entity of the EV + // - limits: a set of limits containing phase specific limit data + // - resultCB: callback function for handling the result response + // + // recommendations: + // Sets a recommended charge power in A for each phase. This is mainly + // used if the EV and EVSE communicate via ISO15118 to support charging excess solar power. + // The EV either needs to support the Optimization of Self Consumption usecase or + // the EVSE needs to be able map the recommendations into oligation limits which then + // works for all EVs communication either via IEC61851 or ISO15118. + WriteLoadControlLimits( + entity spineapi.EntityRemoteInterface, + limits []LoadLimitsPhase, + resultCB func(result model.ResultDataType), + ) (*model.MsgCounterType, error) + + // Scenario 2 + + // this is automatically covered by the SPINE implementation + + // Scenario 3 + + // this is covered by the central CEM interface implementation + // use that one to set the CEM's operation state which will inform all remote devices +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vabd.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vabd.go new file mode 100644 index 0000000..41d44b6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vabd.go @@ -0,0 +1,44 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Customer Energy Management +// UseCase: Visualization of Aggregated Battery Data +type CemVABDInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current (dis)charging power + // + // parameters: + // - entity: the entity of the inverter + Power(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 2 + + // return the cumulated battery system charge energy + // + // parameters: + // - entity: the entity of the inverter + EnergyCharged(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 3 + + // return the cumulated battery system discharge energy + // + // parameters: + // - entity: the entity of the inverter + EnergyDischarged(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 4 + + // return the current state of charge of the battery system + // + // parameters: + // - entity: the entity of the inverter + StateOfCharge(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vapd.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vapd.go new file mode 100644 index 0000000..841615c --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cem_vapd.go @@ -0,0 +1,36 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Customer Energy Management +// UseCase: Visualization of Aggregated Photovoltaic Data +type CemVAPDInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current production power + // + // parameters: + // - entity: the entity of the inverter + Power(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 2 + + // return the nominal peak power + // + // parameters: + // - entity: the entity of the inverter + PowerNominalPeak(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 3 + + // return total PV yield + // + // parameters: + // - entity: the entity of the inverter + PVYieldTotal(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpc.go new file mode 100644 index 0000000..9374133 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpc.go @@ -0,0 +1,98 @@ +package api + +import ( + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Controllable System +// UseCase: Limitation of Power Consumption +type CsLPCInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current consumption limit data + // + // return values: + // - limit: load limit data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + ConsumptionLimit() (LoadLimit, error) + + // set the current loadcontrol limit data + SetConsumptionLimit(limit LoadLimit) (resultErr error) + + // return the currently pending incoming consumption write limits + PendingConsumptionLimits() map[model.MsgCounterType]LoadLimit + + // accept or deny an incoming consumption write limit + // + // parameters: + // - msg: the incoming write message + // - approve: if the write limit for msg should be approved or not + // - reason: the reason why the approval is denied, otherwise an empty string + ApproveOrDenyConsumptionLimit(msgCounter model.MsgCounterType, approve bool, reason string) + + // Scenario 2 + + // return Failsafe limit for the consumed active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // return values: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + FailsafeConsumptionActivePowerLimit() (value float64, isChangeable bool, resultErr error) + + // set Failsafe limit for the consumed active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // parameters: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + SetFailsafeConsumptionActivePowerLimit(value float64, changeable bool) (resultErr error) + + // return minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // return values: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + FailsafeDurationMinimum() (duration time.Duration, isChangeable bool, resultErr error) + + // set minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // parameters: + // - duration: has to be >= 2h and <= 24h + // - changeable: boolean if the client service can change this value + SetFailsafeDurationMinimum(duration time.Duration, changeable bool) (resultErr error) + + // Scenario 3 + + // this is automatically covered by the SPINE implementation + // + // returns true, if the last heartbeat is within 2 minutes, otherwise false + IsHeartbeatWithinDuration() bool + + // Scenario 4 + + // return nominal maximum active (real) power the Controllable System is allowed to consume. + // + // If the local device type is an EnergyManagementSystem, the contractual consumption + // nominal max is returned, otherwise the power consumption nominal max is returned. + ConsumptionNominalMax() (float64, error) + + // set power nominal maximum active (real) power the Controllable System is allowed to consume. + // + // If the local device type is an EnergyManagementSystem, the contractual consumption + // nominal max is set, otherwise the power consumption nominal max is set. + // + // parameters: + // - value: nominal max power consumption in W + SetConsumptionNominalMax(value float64) (resultErr error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpp.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpp.go new file mode 100644 index 0000000..3759ff3 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/cs_lpp.go @@ -0,0 +1,98 @@ +package api + +import ( + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Controllable System +// UseCase: Limitation of Power Production +type CsLPPInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current loadcontrol limit data + // + // return values: + // - limit: load limit data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + ProductionLimit() (LoadLimit, error) + + // set the current loadcontrol limit data + SetProductionLimit(limit LoadLimit) (resultErr error) + + // return the currently pending incoming production write limits + PendingProductionLimits() map[model.MsgCounterType]LoadLimit + + // accept or deny an incoming production write limit + // + // parameters: + // - msg: the incoming write message + // - approve: if the write limit for msg should be approved or not + // - reason: the reason why the approval is denied, otherwise an empty string + ApproveOrDenyProductionLimit(msgCounter model.MsgCounterType, approve bool, reason string) + + // Scenario 2 + + // return Failsafe limit for the produced active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // return values: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + FailsafeProductionActivePowerLimit() (value float64, isChangeable bool, resultErr error) + + // set Failsafe limit for the produced active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // parameters: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + SetFailsafeProductionActivePowerLimit(value float64, changeable bool) (resultErr error) + + // return minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // return values: + // - value: the power limit in W + // - changeable: boolean if the client service can change the limit + FailsafeDurationMinimum() (duration time.Duration, isChangeable bool, resultErr error) + + // set minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // parameters: + // - duration: has to be >= 2h and <= 24h + // - changeable: boolean if the client service can change this value + SetFailsafeDurationMinimum(duration time.Duration, changeable bool) (resultErr error) + + // Scenario 3 + + // this is automatically covered by the SPINE implementation + // + // returns true, if the last heartbeat is within 2 minutes, otherwise false + IsHeartbeatWithinDuration() bool + + // Scenario 4 + + // return nominal maximum active (real) power the Controllable System is allowed to produce. + // + // If the local device type is an EnergyManagementSystem, the contractual production + // nominal max is returned, otherwise the power production nominal max is returned. + ProductionNominalMax() (float64, error) + + // set power nominal maximum active (real) power the Controllable System is allowed to produce. + // + // If the local device type is an EnergyManagementSystem, the contractual production + // nominal max is set, otherwise the power production nominal max is set. + // + // parameters: + // - value: nominal max power production in W + SetProductionNominalMax(value float64) (resultErr error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpc.go new file mode 100644 index 0000000..cf4b834 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpc.go @@ -0,0 +1,91 @@ +package api + +import ( + "time" + + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Energy Guard +// UseCase: Limitation of Power Consumption +type EgLPCInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current consumption limit data + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - limit: load limit data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + ConsumptionLimit(entity spineapi.EntityRemoteInterface) (limit LoadLimit, resultErr error) + + // send new LoadControlLimits + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - limit: load limit data + // - resultCB: callback function for handling the result response + WriteConsumptionLimit( + entity spineapi.EntityRemoteInterface, + limit LoadLimit, + resultCB func(result model.ResultDataType), + ) (*model.MsgCounterType, error) + + // Scenario 2 + + // return Failsafe limit for the consumed active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - positive values are used for consumption + FailsafeConsumptionActivePowerLimit(entity spineapi.EntityRemoteInterface) (float64, error) + + // send new Failsafe Consumption Active Power Limit + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - value: the new limit in W + WriteFailsafeConsumptionActivePowerLimit(entity spineapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) + + // return minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - negative values are used for production + FailsafeDurationMinimum(entity spineapi.EntityRemoteInterface) (time.Duration, error) + + // send new Failsafe Duration Minimum + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - duration: the duration, between 2h and 24h + WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) + + // Scenario 3 + + // this is automatically covered by the SPINE implementation + + // Scenario 4 + + // return nominal maximum active (real) power the Controllable System is + // able to consume according to the contract (EMS), device label or data sheet. + // + // parameters: + // - entity: the entity of the e.g. EVSE + ConsumptionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpp.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpp.go new file mode 100644 index 0000000..89dd89b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/eg_lpp.go @@ -0,0 +1,91 @@ +package api + +import ( + "time" + + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// Actor: Energy Guard +// UseCase: Limitation of Power Production +type EgLPPInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current production limit data + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - limit: load limit data + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + ProductionLimit(entity spineapi.EntityRemoteInterface) (limit LoadLimit, resultErr error) + + // send new LoadControlLimits + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - limit: load limit data + // - resultCB: callback function for handling the result response + WriteProductionLimit( + entity spineapi.EntityRemoteInterface, + limit LoadLimit, + resultCB func(result model.ResultDataType), + ) (*model.MsgCounterType, error) + + // Scenario 2 + + // return Failsafe limit for the produced active (real) power of the + // Controllable System. This limit becomes activated in "init" state or "failsafe state". + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - positive values are used for production + FailsafeProductionActivePowerLimit(entity spineapi.EntityRemoteInterface) (float64, error) + + // send new Failsafe Production Active Power Limit + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - value: the new limit in W + WriteFailsafeProductionActivePowerLimit(entity spineapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) + + // return minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" + // + // parameters: + // - entity: the entity of the e.g. EVSE + // + // return values: + // - negative values are used for production + FailsafeDurationMinimum(entity spineapi.EntityRemoteInterface) (time.Duration, error) + + // send new Failsafe Duration Minimum + // + // parameters: + // - entity: the entity of the e.g. EVSE + // - duration: the duration, between 2h and 24h + WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) + + // Scenario 3 + + // this is automatically covered by the SPINE implementation + + // Scenario 4 + + // return nominal maximum active (real) power the Controllable System is + // able to produce according to the contract (EMS), device label or data sheet. + // + // parameters: + // - entity: the entity of the e.g. EVSE + ProductionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mgcp.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mgcp.go new file mode 100644 index 0000000..4387db4 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mgcp.go @@ -0,0 +1,86 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Monitoring Appliance +// UseCase: Monitoring of Grid Connection Point +type MaMGCPInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the current power limitation factor + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + PowerLimitationFactor(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 2 + + // return the momentary power consumption or production at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + // + // return values: + // - positive values are used for consumption + // - negative values are used for production + Power(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 3 + + // return the total feed in energy at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + // + // return values: + // - negative values are used for production + EnergyFeedIn(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 4 + + // return the total consumption energy at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + // + // return values: + // - positive values are used for consumption + EnergyConsumed(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 5 + + // return the momentary current consumption or production at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + // + // return values: + // - positive values are used for consumption + // - negative values are used for production + CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 6 + + // return the voltage phase details at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + VoltagePerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 7 + + // return frequency at the grid connection point + // + // parameters: + // - entity: the entity of the device (e.g. SMGW) + Frequency(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mpc.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mpc.go new file mode 100644 index 0000000..57402cb --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/ma_mpc.go @@ -0,0 +1,81 @@ +package api + +import ( + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" +) + +// Actor: Monitoring Appliance +// UseCase: Monitoring of Power Consumption +type MaMPCInterface interface { + api.UseCaseInterface + + // Scenario 1 + + // return the momentary active power consumption or production + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + Power(entity spineapi.EntityRemoteInterface) (float64, error) + + // return the momentary active phase specific power consumption or production per phase + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + // + // possible errors: + // - ErrDataNotAvailable if no such limit is (yet) available + // - and others + PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 2 + + // return the total consumption energy + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + // + // - positive values are used for consumption + EnergyConsumed(entity spineapi.EntityRemoteInterface) (float64, error) + + // return the total feed in energy + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + // + // return values: + // - negative values are used for production + EnergyProduced(entity spineapi.EntityRemoteInterface) (float64, error) + + // Scenario 3 + + // return the momentary phase specific current consumption or production + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + // + // return values + // - positive values are used for consumption + // - negative values are used for production + CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 4 + + // return the phase specific voltage details + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + VoltagePerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) + + // Scenario 5 + + // return frequency + // + // parameters: + // - entity: the entity of the device (e.g. EVSE) + Frequency(entity spineapi.EntityRemoteInterface) (float64, error) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/api/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/api/types.go new file mode 100644 index 0000000..7d6524e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/api/types.go @@ -0,0 +1,151 @@ +package api + +import ( + "time" + + "github.com/enbility/spine-go/model" +) + +type EVChargeStateType string + +const ( + EVChargeStateTypeUnknown EVChargeStateType = "Unknown" + EVChargeStateTypeUnplugged EVChargeStateType = "unplugged" + EVChargeStateTypeError EVChargeStateType = "error" + EVChargeStateTypePaused EVChargeStateType = "paused" + EVChargeStateTypeActive EVChargeStateType = "active" + EVChargeStateTypeFinished EVChargeStateType = "finished" +) + +// Defines a phase specific limit data set +type LoadLimitsPhase struct { + Phase model.ElectricalConnectionPhaseNameType // the phase + IsChangeable bool // if the value can be changed via write, ignored when writing data + IsActive bool // if the limit is active + Value float64 // the limit +} + +// Defines a limit data set +type LoadLimit struct { + Duration time.Duration // the duration of the limit, + IsChangeable bool // if the value can be changed via write, ignored when writing data + IsActive bool // if the limit is active + Value float64 // the limit +} + +// identification +type IdentificationItem struct { + // the identification value + Value string + + // the type of the identification value, e.g. + ValueType model.IdentificationTypeType +} + +type EVChargeStrategyType string + +const ( + EVChargeStrategyTypeUnknown EVChargeStrategyType = "unknown" + EVChargeStrategyTypeNoDemand EVChargeStrategyType = "nodemand" + EVChargeStrategyTypeDirectCharging EVChargeStrategyType = "directcharging" + EVChargeStrategyTypeMinSoC EVChargeStrategyType = "minsoc" + EVChargeStrategyTypeTimedCharging EVChargeStrategyType = "timedcharging" +) + +// Contains details about the actual demands from the EV +// +// General: +// - If duration and energy is 0, charge mode is EVChargeStrategyTypeNoDemand +// - If duration is 0, charge mode is EVChargeStrategyTypeDirectCharging and the slots should cover at least 48h +// - If both are != 0, charge mode is EVChargeStrategyTypeTimedCharging and the slots should cover at least the duration, but at max 168h (7d) +type Demand struct { + MinDemand float64 // minimum demand in Wh to reach the minSoC setting, 0 if not set + OptDemand float64 // demand in Wh to reach the timer SoC setting + MaxDemand float64 // the maximum possible demand until the battery is full + DurationUntilStart float64 // the duration in s from now until charging will start, this could be in the future but usualy is now + DurationUntilEnd float64 // the duration in s from now until minDemand or optDemand has to be reached, 0 if direct charge strategy is active +} + +// Contains details about an EV generated charging plan +type ChargePlan struct { + Slots []ChargePlanSlotValue // Individual charging slot details +} + +// Contains details about a charging plan slot +type ChargePlanSlotValue struct { + Start time.Time // The start time of the slot + End time.Time // The duration of the slot + Value float64 // planned power value + MinValue float64 // minimum power value + MaxValue float64 // maximum power value +} + +// Details about the time slot constraints +type TimeSlotConstraints struct { + MinSlots uint // the minimum number of slots, no minimum if 0 + MaxSlots uint // the maximum number of slots, unlimited if 0 + MinSlotDuration time.Duration // the minimum duration of a slot, no minimum if 0 + MaxSlotDuration time.Duration // the maximum duration of a slot, unlimited if 0 + SlotDurationStepSize time.Duration // the duration has to be a multiple of this value if != 0 +} + +// Details about the incentive slot constraints +type IncentiveSlotConstraints struct { + MinSlots uint // the minimum number of slots, no minimum if 0 + MaxSlots uint // the maximum number of slots, unlimited if 0 +} + +// details about the boundary +type TierBoundaryDescription struct { + // the id of the boundary + Id uint + + // the type of the boundary + Type model.TierBoundaryTypeType + + // the unit of the boundary + Unit model.UnitOfMeasurementType +} + +// details about incentive +type IncentiveDescription struct { + // the id of the incentive + Id uint + + // the type of the incentive + Type model.IncentiveTypeType + + // the currency of the incentive, if it is price based + Currency model.CurrencyType +} + +// Contains about one tier in a tariff +type IncentiveTableDescriptionTier struct { + // the id of the tier + Id uint + + // the tiers type + Type model.TierTypeType + + // each tear has 1 to 3 boundaries + // used for different power limits, e.g. 0-1kW x€, 1-3kW y€, ... + Boundaries []TierBoundaryDescription + + // each tier has 1 to 3 incentives + // - price/costs (absolute or relative) + // - renewable energy percentage + // - CO2 emissions + Incentives []IncentiveDescription +} + +// Contains details about a tariff +type IncentiveTariffDescription struct { + // each tariff can have 1 to 3 tiers + Tiers []IncentiveTableDescriptionTier +} + +// Contains details about power limits or incentives for a defined timeframe +type DurationSlotValue struct { + Duration time.Duration // Duration of this slot + Value float64 // Energy Cost or Power Limit +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/events.go new file mode 100644 index 0000000..c47e31f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/events.go @@ -0,0 +1,236 @@ +package cevc + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *CEVC) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EV entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.TimeSeriesDescriptionListDataType: + e.evTimeSeriesDescriptionDataUpdate(payload) + + case *model.TimeSeriesListDataType: + e.evTimeSeriesDataUpdate(payload) + + case *model.IncentiveTableDescriptionDataType: + e.evIncentiveTableDescriptionDataUpdate(payload) + + case *model.IncentiveTableConstraintsDataType: + e.evIncentiveTableConstraintsDataUpdate(payload) + + case *model.IncentiveDataType: + e.evIncentiveTableDataUpdate(payload) + } +} + +// an EV was connected +func (e *CEVC) evConnected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + if evDeviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + if !evDeviceConfiguration.HasSubscription() { + if _, err := evDeviceConfiguration.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get device configuration descriptions + if _, err := evDeviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity); err == nil { + if !evTimeSeries.HasSubscription() { + if _, err := evTimeSeries.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !evTimeSeries.HasBinding() { + if _, err := evTimeSeries.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get time series descriptions + if _, err := evTimeSeries.RequestDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get time series constraints + if _, err := evTimeSeries.RequestConstraints(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, entity); err == nil { + if !evIncentiveTable.HasSubscription() { + if _, err := evIncentiveTable.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !evIncentiveTable.HasBinding() { + if _, err := evIncentiveTable.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get incentivetable descriptions + if _, err := evIncentiveTable.RequestDescriptions(); err != nil { + logging.Log().Debug(err) + } + } +} + +// the time series description data of an EV was updated +func (e *CEVC) evTimeSeriesDescriptionDataUpdate(payload spineapi.EventPayload) { + if evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, payload.Entity); err == nil { + // get time series values + if _, err := evTimeSeries.RequestData(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + // check if we are required to update the plan + if !e.evCheckTimeSeriesDescriptionConstraintsUpdateRequired(payload.Entity) { + return + } + + _, err := e.EnergyDemand(payload.Entity) + if err != nil { + return + } + + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyDemand) + } + + _, err = e.TimeSlotConstraints(payload.Entity) + if err != nil { + logging.Log().Error("Error getting timeseries constraints:", err) + return + } + + _, err = e.IncentiveConstraints(payload.Entity) + if err != nil { + logging.Log().Error("Error getting incentive constraints:", err) + return + } + + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataRequestedPowerLimitsAndIncentives) + } +} + +// the load control limit data of an EV was updated +func (e *CEVC) evTimeSeriesDataUpdate(payload spineapi.EventPayload) { + if _, err := e.ChargePlan(payload.Entity); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateChargePlan) + } + + if _, err := e.ChargePlanConstraints(payload.Entity); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateTimeSlotConstraints) + } +} + +// the incentive table description data of an EV was updated +func (e *CEVC) evIncentiveTableDescriptionDataUpdate(payload spineapi.EventPayload) { + if evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, payload.Entity); err == nil { + // get time series values + if _, err := evIncentiveTable.RequestValues(); err != nil { + logging.Log().Debug(err) + } + } + + // check if we are required to update the plan + if e.evCheckIncentiveTableDescriptionUpdateRequired(payload.Entity) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataRequestedIncentiveTableDescription) + } +} + +// the incentive table constraint data of an EV was updated +func (e *CEVC) evIncentiveTableConstraintsDataUpdate(payload spineapi.EventPayload) { + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateIncentiveTable) + } +} + +// the incentive table data of an EV was updated +func (e *CEVC) evIncentiveTableDataUpdate(payload spineapi.EventPayload) { + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateIncentiveTable) + } +} + +// check timeSeries descriptions if constraints element has updateRequired set to true +// as this triggers the CEM to send power tables within 20s +func (e *CEVC) evCheckTimeSeriesDescriptionConstraintsUpdateRequired(entity spineapi.EntityRemoteInterface) bool { + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + logging.Log().Error("timeseries feature not found") + return false + } + + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypeConstraints), + } + data, err := evTimeSeries.GetDescriptionsForFilter(filter) + if err != nil || len(data) == 0 { + return false + } + + if data[0].UpdateRequired != nil { + return *data[0].UpdateRequired + } + + return false +} + +// check incentibeTable descriptions if the tariff description has updateRequired set to true +// as this triggers the CEM to send incentive tables within 20s +func (e *CEVC) evCheckIncentiveTableDescriptionUpdateRequired(entity spineapi.EntityRemoteInterface) bool { + evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, entity) + if err != nil { + logging.Log().Error("incentivetable feature not found") + return false + } + + filter := model.TariffDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeSimpleIncentiveTable), + } + data, err := evIncentiveTable.GetDescriptionsForFilter(filter) + if err != nil || len(data) == 0 { + return false + } + + // only use the first description and therein the first tariff + item := data[0].TariffDescription + if item != nil && item.UpdateRequired != nil { + return *item.UpdateRequired + } + + return false +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen1.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen1.go new file mode 100644 index 0000000..f45b262 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen1.go @@ -0,0 +1,141 @@ +package cevc + +import ( + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// returns the current charging strategy +func (e *CEVC) ChargeStrategy(entity spineapi.EntityRemoteInterface) ucapi.EVChargeStrategyType { + if !e.IsCompatibleEntityType(entity) { + return ucapi.EVChargeStrategyTypeUnknown + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return ucapi.EVChargeStrategyTypeUnknown + } + + // only the time series data for singledemand is relevant for detecting the charging strategy + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypeSingleDemand), + } + data, err := evTimeSeries.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return ucapi.EVChargeStrategyTypeUnknown + } + + // without time series slots, there is no known strategy + if len(data[0].TimeSeriesSlot) == 0 { + return ucapi.EVChargeStrategyTypeUnknown + } + + // get the value for the first slot + firstSlot := data[0].TimeSeriesSlot[0] + + switch { + case firstSlot.Duration == nil: + // if value is > 0 and duration does not exist, the EV is direct charging + if firstSlot.Value != nil && firstSlot.Value.GetValue() > 0 { + return ucapi.EVChargeStrategyTypeDirectCharging + } + + // maxValue will show the maximum amount the battery could take + return ucapi.EVChargeStrategyTypeNoDemand + + case firstSlot.Duration != nil: + if _, err := firstSlot.Duration.GetTimeDuration(); err != nil { + // we got an invalid duration + return ucapi.EVChargeStrategyTypeUnknown + } + + if firstSlot.MinValue != nil && firstSlot.MinValue.GetValue() > 0 { + return ucapi.EVChargeStrategyTypeMinSoC + } + + if firstSlot.Value != nil { + if firstSlot.Value.GetValue() > 0 { + // there is demand and a duration + return ucapi.EVChargeStrategyTypeTimedCharging + } + + return ucapi.EVChargeStrategyTypeNoDemand + } + } + + return ucapi.EVChargeStrategyTypeUnknown +} + +// returns the current energy demand in Wh and the duration +func (e *CEVC) EnergyDemand(entity spineapi.EntityRemoteInterface) (ucapi.Demand, error) { + demand := ucapi.Demand{} + + if !e.IsCompatibleEntityType(entity) { + return demand, api.ErrNoCompatibleEntity + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return demand, api.ErrDataNotAvailable + } + + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypeSingleDemand), + } + data, err := evTimeSeries.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return demand, api.ErrDataNotAvailable + } + + // we need at least a time series slot + if data[0].TimeSeriesSlot == nil { + return demand, api.ErrDataNotAvailable + } + + // get the value for the first slot, ignore all others, which + // in the tests so far always have min/max/value 0 + firstSlot := data[0].TimeSeriesSlot[0] + if firstSlot.MinValue != nil { + demand.MinDemand = firstSlot.MinValue.GetValue() + } + if firstSlot.Value != nil { + demand.OptDemand = firstSlot.Value.GetValue() + } + if firstSlot.MaxValue != nil { + demand.MaxDemand = firstSlot.MaxValue.GetValue() + } + if firstSlot.Duration != nil { + if tempDuration, err := firstSlot.Duration.GetTimeDuration(); err == nil { + demand.DurationUntilEnd = tempDuration.Seconds() + } + } + + // start time has to be defined either in TimePeriod or the first slot + relStartTime := time.Duration(0) + + startTimeSet := false + if data[0].TimePeriod != nil && data[0].TimePeriod.StartTime != nil { + if temp, err := data[0].TimePeriod.StartTime.GetTimeDuration(); err == nil { + relStartTime = temp + startTimeSet = true + } + } + + if !startTimeSet { + if firstSlot.TimePeriod != nil && firstSlot.TimePeriod.StartTime != nil { + if temp, err := firstSlot.TimePeriod.StartTime.GetTimeDuration(); err == nil { + relStartTime = temp + } + } + } + + demand.DurationUntilStart = relStartTime.Seconds() + + return demand, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen2.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen2.go new file mode 100644 index 0000000..566c7fd --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen2.go @@ -0,0 +1,181 @@ +package cevc + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// returns the constraints for the time slots +func (e *CEVC) TimeSlotConstraints(entity spineapi.EntityRemoteInterface) (ucapi.TimeSlotConstraints, error) { + result := ucapi.TimeSlotConstraints{} + + if !e.IsCompatibleEntityType(entity) { + return result, api.ErrNoCompatibleEntity + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return result, api.ErrDataNotAvailable + } + + constraints, err := evTimeSeries.GetConstraints() + if err != nil { + return result, err + } + + // only use the first constraint + constraint := constraints[0] + + if constraint.SlotCountMin != nil { + result.MinSlots = uint(*constraint.SlotCountMin) + } + if constraint.SlotCountMax != nil { + result.MaxSlots = uint(*constraint.SlotCountMax) + } + if constraint.SlotDurationMin != nil { + if duration, err := constraint.SlotDurationMin.GetTimeDuration(); err == nil { + result.MinSlotDuration = duration + } + } + if constraint.SlotDurationMax != nil { + if duration, err := constraint.SlotDurationMax.GetTimeDuration(); err == nil { + result.MaxSlotDuration = duration + } + } + if constraint.SlotDurationStepSize != nil { + if duration, err := constraint.SlotDurationStepSize.GetTimeDuration(); err == nil { + result.SlotDurationStepSize = duration + } + } + + return result, nil +} + +// send power limits to the EV +// if no data is provided, default power limits with the max possible value for 7 days will be sent +func (e *CEVC) WritePowerLimits(entity spineapi.EntityRemoteInterface, data []ucapi.DurationSlotValue) error { + if !e.IsCompatibleEntityType(entity) { + return api.ErrNoCompatibleEntity + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return api.ErrDataNotAvailable + } + + if len(data) == 0 { + data, err = e.defaultPowerLimits(entity) + if err != nil { + return err + } + } + + constraints, err := e.TimeSlotConstraints(entity) + if err != nil { + return err + } + + if constraints.MinSlots != 0 && constraints.MinSlots > uint(len(data)) { + return errors.New("too few charge slots provided") + } + + if constraints.MaxSlots != 0 && constraints.MaxSlots < uint(len(data)) { + return errors.New("too many charge slots provided") + } + + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypeConstraints), + } + desc, err := evTimeSeries.GetDescriptionsForFilter(filter) + if err != nil || len(desc) == 0 { + return api.ErrDataNotAvailable + } + + timeSeriesSlots := []model.TimeSeriesSlotType{} + var totalDuration time.Duration + for index, slot := range data { + relativeStart := totalDuration + + timeSeriesSlot := model.TimeSeriesSlotType{ + TimeSeriesSlotId: util.Ptr(model.TimeSeriesSlotIdType(index)), + TimePeriod: &model.TimePeriodType{ + StartTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(relativeStart), + }, + MaxValue: model.NewScaledNumberType(slot.Value), + } + + // the last slot also needs an End Time + if index == len(data)-1 { + relativeEndTime := relativeStart + slot.Duration + timeSeriesSlot.TimePeriod.EndTime = model.NewAbsoluteOrRelativeTimeTypeFromDuration(relativeEndTime) + } + timeSeriesSlots = append(timeSeriesSlots, timeSeriesSlot) + + totalDuration += slot.Duration + } + + timeSeriesData := model.TimeSeriesDataType{ + TimeSeriesId: desc[0].TimeSeriesId, + TimePeriod: &model.TimePeriodType{ + StartTime: model.NewAbsoluteOrRelativeTimeType("PT0S"), + EndTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(totalDuration), + }, + TimeSeriesSlot: timeSeriesSlots, + } + + _, err = evTimeSeries.WriteData([]model.TimeSeriesDataType{timeSeriesData}) + + return err +} + +func (e *CEVC) defaultPowerLimits(entity spineapi.EntityRemoteInterface) ([]ucapi.DurationSlotValue, error) { + // send default power limits for the maximum timeframe + // to fullfill spec, as there is no data provided + logging.Log().Info("Fallback sending default power limits") + + evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil { + logging.Log().Error("electrical connection feature not found") + return nil, err + } + + filter := model.ElectricalConnectionParameterDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + paramDesc, err := evElectricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(paramDesc) == 0 || paramDesc[0].ParameterId == nil { + logging.Log().Error("Error getting parameter descriptions:", err) + return nil, err + } + + filter2 := model.ElectricalConnectionPermittedValueSetDataType{ + ParameterId: paramDesc[0].ParameterId, + } + permitted, err := evElectricalConnection.GetPermittedValueSetForFilter(filter2) + if err != nil || len(permitted) == 0 { + logging.Log().Error("Error getting permitted values:", err) + return nil, err + } + + if len(permitted[0].PermittedValueSet) == 0 || len(permitted[0].PermittedValueSet[0].Range) == 0 { + text := "No permitted value set available" + logging.Log().Error(text) + return nil, errors.New(text) + } + + data := []ucapi.DurationSlotValue{ + { + Duration: 7 * time.Hour * 24, + Value: permitted[0].PermittedValueSet[0].Range[0].Max.GetValue(), + }, + } + return data, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen3.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen3.go new file mode 100644 index 0000000..d99d772 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen3.go @@ -0,0 +1,279 @@ +package cevc + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// returns the minimum and maximum number of incentive slots allowed +func (e *CEVC) IncentiveConstraints(entity spineapi.EntityRemoteInterface) (ucapi.IncentiveSlotConstraints, error) { + result := ucapi.IncentiveSlotConstraints{} + + if !e.IsCompatibleEntityType(entity) { + return result, api.ErrNoCompatibleEntity + } + + evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, entity) + if err != nil { + return result, api.ErrDataNotAvailable + } + + constraints, err := evIncentiveTable.GetConstraints() + if err != nil { + return result, err + } + + // only use the first constraint + constraint := constraints[0] + + if constraint.IncentiveSlotConstraints.SlotCountMin != nil { + result.MinSlots = uint(*constraint.IncentiveSlotConstraints.SlotCountMin) + } + if constraint.IncentiveSlotConstraints.SlotCountMax != nil { + result.MaxSlots = uint(*constraint.IncentiveSlotConstraints.SlotCountMax) + } + + return result, nil +} + +// inform the EVSE about used currency and boundary units +// +// SPINE UC CoordinatedEVCharging 2.4.3 +func (e *CEVC) WriteIncentiveTableDescriptions(entity spineapi.EntityRemoteInterface, data []ucapi.IncentiveTariffDescription) error { + if !e.IsCompatibleEntityType(entity) { + return api.ErrNoCompatibleEntity + } + + evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, entity) + if err != nil { + logging.Log().Error("incentivetable feature not found") + return err + } + + filter := model.TariffDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeSimpleIncentiveTable), + } + descriptions, err := evIncentiveTable.GetDescriptionsForFilter(filter) + if err != nil { + logging.Log().Error(err) + return err + } + + // default tariff + // + // - tariff, min 1 + // each tariff has + // - tiers: min 1, max 3 + // each tier has: + // - boundaries: min 1, used for different power limits, e.g. 0-1kW x€, 1-3kW y€, ... + // - incentives: min 1, max 3 + // - price/costs (absolute or relative) + // - renewable energy percentage + // - CO2 emissions + // + // limit this to + // - 1 tariff + // - 1 tier + // - 1 boundary + // - 1 incentive (price) + // incentive type has to be the same for all sent power limits! + descData := []model.IncentiveTableDescriptionType{ + { + TariffDescription: descriptions[0].TariffDescription, + Tier: []model.IncentiveTableDescriptionTierType{ + { + TierDescription: &model.TierDescriptionDataType{ + TierId: util.Ptr(model.TierIdType(0)), + TierType: util.Ptr(model.TierTypeTypeDynamicCost), + }, + BoundaryDescription: []model.TierBoundaryDescriptionDataType{ + { + BoundaryId: util.Ptr(model.TierBoundaryIdType(0)), + BoundaryType: util.Ptr(model.TierBoundaryTypeTypePowerBoundary), + BoundaryUnit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + }, + IncentiveDescription: []model.IncentiveDescriptionDataType{ + { + IncentiveId: util.Ptr(model.IncentiveIdType(0)), + IncentiveType: util.Ptr(model.IncentiveTypeTypeAbsoluteCost), + Currency: util.Ptr(model.CurrencyTypeEur), + }, + }, + }, + }, + }, + } + + if len(data) > 0 && len(data[0].Tiers) > 0 { + newDescData := []model.IncentiveTableDescriptionType{} + allDataPresent := false + + for index, tariff := range data { + tariffDesc := descriptions[0].TariffDescription + if len(descriptions) > index { + tariffDesc = descriptions[index].TariffDescription + } + + newTariff := model.IncentiveTableDescriptionType{ + TariffDescription: tariffDesc, + } + + tierData := []model.IncentiveTableDescriptionTierType{} + for _, tier := range tariff.Tiers { + newTier := model.IncentiveTableDescriptionTierType{} + + newTier.TierDescription = &model.TierDescriptionDataType{ + TierId: util.Ptr(model.TierIdType(tier.Id)), + TierType: util.Ptr(tier.Type), + } + + boundaryDescription := []model.TierBoundaryDescriptionDataType{} + for _, boundary := range tier.Boundaries { + newBoundary := model.TierBoundaryDescriptionDataType{ + BoundaryId: util.Ptr(model.TierBoundaryIdType(boundary.Id)), + BoundaryType: util.Ptr(boundary.Type), + BoundaryUnit: util.Ptr(boundary.Unit), + } + boundaryDescription = append(boundaryDescription, newBoundary) + } + newTier.BoundaryDescription = boundaryDescription + + incentiveDescription := []model.IncentiveDescriptionDataType{} + for _, incentive := range tier.Incentives { + newIncentive := model.IncentiveDescriptionDataType{ + IncentiveId: util.Ptr(model.IncentiveIdType(incentive.Id)), + IncentiveType: util.Ptr(incentive.Type), + } + if incentive.Currency != "" { + newIncentive.Currency = util.Ptr(incentive.Currency) + } + incentiveDescription = append(incentiveDescription, newIncentive) + } + newTier.IncentiveDescription = incentiveDescription + + if len(newTier.BoundaryDescription) > 0 && + len(newTier.IncentiveDescription) > 0 { + allDataPresent = true + } + tierData = append(tierData, newTier) + } + + newTariff.Tier = tierData + + newDescData = append(newDescData, newTariff) + } + + if allDataPresent { + descData = newDescData + } + } + + _, err = evIncentiveTable.WriteDescriptions(descData) + if err != nil { + logging.Log().Error(err) + return err + } + + return nil +} + +// send incentives to the EV +// if no data is provided, default incentives with the same price for 7 days will be sent +func (e *CEVC) WriteIncentives(entity spineapi.EntityRemoteInterface, data []ucapi.DurationSlotValue) error { + if !e.IsCompatibleEntityType(entity) { + return api.ErrNoCompatibleEntity + } + + evIncentiveTable, err := client.NewIncentiveTable(e.LocalEntity, entity) + if err != nil { + return api.ErrDataNotAvailable + } + + if len(data) == 0 { + // send default incentives for the maximum timeframe + // to fullfill spec, as there is no data provided + logging.Log().Info("Fallback sending default incentives") + data = []ucapi.DurationSlotValue{ + {Duration: 7 * time.Hour * 24, Value: 0.30}, + } + } + + constraints, err := e.IncentiveConstraints(entity) + if err != nil { + return err + } + + if constraints.MinSlots != 0 && constraints.MinSlots > uint(len(data)) { + return errors.New("too few charge slots provided") + } + + if constraints.MaxSlots != 0 && constraints.MaxSlots < uint(len(data)) { + return errors.New("too many charge slots provided") + } + + incentiveSlots := []model.IncentiveTableIncentiveSlotType{} + var totalDuration time.Duration + for index, slot := range data { + relativeStart := totalDuration + + timeInterval := &model.TimeTableDataType{ + StartTime: &model.AbsoluteOrRecurringTimeType{ + Relative: model.NewDurationType(relativeStart), + }, + } + + // the last slot also needs an End Time + if index == len(data)-1 { + relativeEndTime := relativeStart + slot.Duration + timeInterval.EndTime = &model.AbsoluteOrRecurringTimeType{ + Relative: model.NewDurationType(relativeEndTime), + } + } + + incentiveSlot := model.IncentiveTableIncentiveSlotType{ + TimeInterval: timeInterval, + Tier: []model.IncentiveTableTierType{ + { + Tier: &model.TierDataType{ + TierId: util.Ptr(model.TierIdType(0)), + }, + Boundary: []model.TierBoundaryDataType{ + { + BoundaryId: util.Ptr(model.TierBoundaryIdType(0)), // only 1 boundary exists + LowerBoundaryValue: model.NewScaledNumberType(0), + }, + }, + Incentive: []model.IncentiveDataType{ + { + IncentiveId: util.Ptr(model.IncentiveIdType(0)), // always use price + Value: model.NewScaledNumberType(slot.Value), + }, + }, + }, + }, + } + incentiveSlots = append(incentiveSlots, incentiveSlot) + + totalDuration += slot.Duration + } + + incentiveData := model.IncentiveTableType{ + Tariff: &model.TariffDataType{ + TariffId: util.Ptr(model.TariffIdType(0)), + }, + IncentiveSlot: incentiveSlots, + } + + _, err = evIncentiveTable.WriteValues([]model.IncentiveTableType{incentiveData}) + + return err +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen4.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen4.go new file mode 100644 index 0000000..1f22f9f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/public_scen4.go @@ -0,0 +1,153 @@ +package cevc + +import ( + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +func (e *CEVC) ChargePlanConstraints(entity spineapi.EntityRemoteInterface) ([]ucapi.DurationSlotValue, error) { + constraints := []ucapi.DurationSlotValue{} + + if !e.IsCompatibleEntityType(entity) { + return constraints, api.ErrNoCompatibleEntity + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return constraints, api.ErrDataNotAvailable + } + + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypeConstraints), + } + data, err := evTimeSeries.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return constraints, api.ErrDataNotAvailable + } + + // we need at least a time series slot + if data[0].TimeSeriesSlot == nil { + return constraints, api.ErrDataNotAvailable + } + + // get the values for all slots + for _, slot := range data[0].TimeSeriesSlot { + newSlot := ucapi.DurationSlotValue{} + + if slot.Duration != nil { + if duration, err := slot.Duration.GetTimeDuration(); err == nil { + newSlot.Duration = duration + } + } else if slot.TimePeriod != nil { + var slotStart, slotEnd time.Time + if slot.TimePeriod.StartTime != nil { + if time, err := slot.TimePeriod.StartTime.GetTime(); err == nil { + slotStart = time + } + } + if slot.TimePeriod.EndTime != nil { + if time, err := slot.TimePeriod.EndTime.GetTime(); err == nil { + slotEnd = time + } + } + newSlot.Duration = slotEnd.Sub(slotStart) + } + + if slot.MaxValue != nil { + newSlot.Value = slot.MaxValue.GetValue() + } + + constraints = append(constraints, newSlot) + } + + return constraints, nil +} + +func (e *CEVC) ChargePlan(entity spineapi.EntityRemoteInterface) (ucapi.ChargePlan, error) { + plan := ucapi.ChargePlan{} + + if !e.IsCompatibleEntityType(entity) { + return plan, api.ErrNoCompatibleEntity + } + + evTimeSeries, err := client.NewTimeSeries(e.LocalEntity, entity) + if err != nil { + return plan, api.ErrDataNotAvailable + } + + filter := model.TimeSeriesDescriptionDataType{ + TimeSeriesType: util.Ptr(model.TimeSeriesTypeTypePlan), + } + data, err := evTimeSeries.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return plan, api.ErrDataNotAvailable + } + + // we need at least a time series slot + if data[0].TimeSeriesSlot == nil { + return plan, api.ErrDataNotAvailable + } + + startAvailable := false + // check the start time relative to now of the plan, default is now + currentStart := time.Now() + currentEnd := currentStart + if data[0].TimePeriod != nil && data[0].TimePeriod.StartTime != nil { + if start, err := data[0].TimePeriod.StartTime.GetTimeDuration(); err == nil { + currentStart = currentStart.Add(start) + startAvailable = true + } + } + + // get the values for all slots + for index, slot := range data[0].TimeSeriesSlot { + newSlot := ucapi.ChargePlanSlotValue{} + + slotStartDefined := false + if index == 0 && startAvailable && (slot.TimePeriod == nil || slot.TimePeriod.StartTime == nil) { + newSlot.Start = currentStart + slotStartDefined = true + } + if slot.TimePeriod != nil && slot.TimePeriod.StartTime != nil { + if time, err := slot.TimePeriod.StartTime.GetTime(); err == nil { + newSlot.Start = time + slotStartDefined = true + } + } + if !slotStartDefined { + newSlot.Start = currentEnd + } + + if slot.Duration != nil { + if duration, err := slot.Duration.GetTimeDuration(); err == nil { + newSlot.End = newSlot.Start.Add(duration) + currentEnd = newSlot.End + } + } else if slot.TimePeriod != nil && slot.TimePeriod.EndTime != nil { + if time, err := slot.TimePeriod.StartTime.GetTime(); err == nil { + newSlot.End = time + currentEnd = newSlot.End + } + } + + if slot.Value != nil { + newSlot.Value = slot.Value.GetValue() + } + if slot.MinValue != nil { + newSlot.MinValue = slot.MinValue.GetValue() + } + if slot.MaxValue != nil { + newSlot.MaxValue = slot.MaxValue.GetValue() + } + + plan.Slots = append(plan.Slots, newSlot) + } + + return plan, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/types.go new file mode 100644 index 0000000..3adf187 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/types.go @@ -0,0 +1,51 @@ +package cevc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-cevc-UseCaseSupportUpdate" + + // Scenario 1 + + // EV provided an energy demand + // + // Use `EnergyDemand` to get the current data + DataUpdateEnergyDemand api.EventType = "cem-cevc-DataUpdateEnergyDemand" + + // Scenario 2 + + // EV provided a charge plan constraints + // + // Use `TimeSlotConstraints` to get the current data + DataUpdateTimeSlotConstraints api.EventType = "cem-cevc-DataUpdateTimeSlotConstraints" + + // Scenario 3 + + // EV incentive table data updated + // + // Use `IncentiveConstraints` to get the current data + DataUpdateIncentiveTable api.EventType = "cem-cevc-DataUpdateIncentiveTable" + + // EV requested an incentive table, call to WriteIncentiveTableDescriptions required + DataRequestedIncentiveTableDescription api.EventType = "cem-cevc-DataRequestedIncentiveTableDescription" + + // Scenario 2 & 3 + + // EV requested power limits, call to WritePowerLimits and WriteIncentives required + DataRequestedPowerLimitsAndIncentives api.EventType = "cem-cevc-DataRequestedPowerLimitsAndIncentives" + + // Scenario 4 + + // EV provided a charge plan + // + // Use `ChargePlanConstraints` to get the current data + DataUpdateChargePlanConstraints api.EventType = "cem-cevc-DataUpdateChargePlanConstraints" + + // EV provided a charge plan + // + // Use `ChargePlan` to get the current data + DataUpdateChargePlan api.EventType = "cem-cevc-DataUpdateChargePlan" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/usecase.go new file mode 100644 index 0000000..b3efc6e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/cevc/usecase.go @@ -0,0 +1,89 @@ +package cevc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type CEVC struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemCEVCInterface = (*CEVC)(nil) + +func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *CEVC { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeTimeSeries}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeTimeSeries}, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeIncentiveTable}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeTimeSeries}, + }, + { + Scenario: model.UseCaseScenarioSupportType(6), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(8), + Mandatory: true, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeEnergyBroker, + model.UseCaseNameTypeCoordinatedEVCharging, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &CEVC{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *CEVC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeTimeSeries, + model.FeatureTypeTypeIncentiveTable, + model.FeatureTypeTypeElectricalConnection, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/events.go new file mode 100644 index 0000000..0c78982 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/events.go @@ -0,0 +1,220 @@ +package evcc + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *EVCC) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EV entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evConnected(payload) + return + } else if internal.IsEntityDisconnected(payload) { + e.evDisconnected(payload) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.DeviceConfigurationKeyValueDescriptionListDataType: + e.evConfigurationDescriptionDataUpdate(payload.Entity) + + case *model.DeviceConfigurationKeyValueListDataType: + e.evConfigurationDataUpdate(payload) + + case *model.DeviceDiagnosisOperatingStateType: + e.evOperatingStateDataUpdate(payload) + + case *model.DeviceClassificationManufacturerDataType: + e.evManufacturerDataUpdate(payload) + + case *model.ElectricalConnectionParameterDescriptionListDataType: + e.evElectricalParamerDescriptionUpdate(payload.Entity) + + case *model.ElectricalConnectionPermittedValueSetListDataType: + e.evElectricalPermittedValuesUpdate(payload) + + case *model.IdentificationListDataType: + e.evIdentificationDataUpdate(payload) + } +} + +// an EV was connected +func (e *EVCC) evConnected(payload spineapi.EventPayload) { + // initialise features, e.g. subscriptions, descriptions + if evDeviceClassification, err := client.NewDeviceClassification(e.LocalEntity, payload.Entity); err == nil { + if !evDeviceClassification.HasSubscription() { + if _, err := evDeviceClassification.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get manufacturer details + if _, err := evDeviceClassification.RequestManufacturerDetails(); err != nil { + logging.Log().Debug(err) + } + } + + if evDeviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + if !evDeviceConfiguration.HasSubscription() { + if _, err := evDeviceConfiguration.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get ev configuration data + if _, err := evDeviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if evDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + if !evDeviceDiagnosis.HasSubscription() { + if _, err := evDeviceDiagnosis.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get device diagnosis state + if _, err := evDeviceDiagnosis.RequestState(); err != nil { + logging.Log().Debug(err) + } + } + + if evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, payload.Entity); err == nil { + if !evElectricalConnection.HasSubscription() { + if _, err := evElectricalConnection.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get electrical connection parameter descriptions + if _, err := evElectricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get electrical permitted values descriptions + if _, err := evElectricalConnection.RequestPermittedValueSets(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if evIdentification, err := client.NewIdentification(e.LocalEntity, payload.Entity); err == nil { + if !evIdentification.HasSubscription() { + if _, err := evIdentification.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get identification + if _, err := evIdentification.RequestValues(); err != nil { + logging.Log().Debug(err) + } + } + + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, EvConnected) + } +} + +// an EV was disconnected +func (e *EVCC) evDisconnected(payload spineapi.EventPayload) { + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, EvDisconnected) + } +} + +// the configuration key description data of an EV was updated +func (e *EVCC) evConfigurationDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if evDeviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + // key value descriptions received, now get the data + if _, err := evDeviceConfiguration.RequestKeyValues(nil, nil); err != nil { + logging.Log().Error("Error getting configuration key values:", err) + } + } +} + +// the configuration key data of an EV was updated +func (e *EVCC) evConfigurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + // Scenario 2 + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeCommunicationsStandard), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCommunicationStandard) + } + + // Scenario 3 + filter.KeyName = util.Ptr(model.DeviceConfigurationKeyNameTypeAsymmetricChargingSupported) + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateAsymmetricChargingSupport) + } + } +} + +// the operating state of an EV was updated +func (e *EVCC) evOperatingStateDataUpdate(payload spineapi.EventPayload) { + if deviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + if _, err := deviceDiagnosis.GetState(); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateIdentifications) + } + } +} + +// the identification data of an EV was updated +func (e *EVCC) evIdentificationDataUpdate(payload spineapi.EventPayload) { + if evIdentification, err := client.NewIdentification(e.LocalEntity, payload.Entity); err == nil { + // Scenario 4 + if evIdentification.CheckEventPayloadDataForFilter(payload.Data) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateIdentifications) + } + } +} + +// the manufacturer data of an EV was updated +func (e *EVCC) evManufacturerDataUpdate(payload spineapi.EventPayload) { + if evDeviceClassification, err := client.NewDeviceClassification(e.LocalEntity, payload.Entity); err == nil { + // Scenario 5 + if _, err := evDeviceClassification.GetManufacturerDetails(); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateManufacturerData) + } + } +} + +// the electrical connection parameter description data of an EV was updated +func (e *EVCC) evElectricalParamerDescriptionUpdate(entity spineapi.EntityRemoteInterface) { + if evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if _, err := evElectricalConnection.RequestPermittedValueSets(nil, nil); err != nil { + logging.Log().Error("Error getting electrical permitted values:", err) + } + } +} + +// the electrical connection permitted value sets data of an EV was updated +func (e *EVCC) evElectricalPermittedValuesUpdate(payload spineapi.EventPayload) { + if evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, payload.Entity); err == nil { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + if evElectricalConnection.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + // Scenario 6 + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentLimits) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/public.go new file mode 100644 index 0000000..bee47fc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/public.go @@ -0,0 +1,280 @@ +package evcc + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the current charge state of the EV +func (e *EVCC) ChargeState(entity spineapi.EntityRemoteInterface) (ucapi.EVChargeStateType, error) { + if entity == nil || entity.EntityType() != model.EntityTypeTypeEV { + return ucapi.EVChargeStateTypeUnplugged, nil + } + + evDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, entity) + if err != nil { + return ucapi.EVChargeStateTypeUnplugged, err + } + + diagnosisState, err := evDeviceDiagnosis.GetState() + if err != nil { + return ucapi.EVChargeStateTypeUnknown, err + } + + operatingState := diagnosisState.OperatingState + if operatingState == nil { + return ucapi.EVChargeStateTypeUnknown, api.ErrDataNotAvailable + } + + switch *operatingState { + case model.DeviceDiagnosisOperatingStateTypeNormalOperation: + return ucapi.EVChargeStateTypeActive, nil + case model.DeviceDiagnosisOperatingStateTypeStandby: + return ucapi.EVChargeStateTypePaused, nil + case model.DeviceDiagnosisOperatingStateTypeFailure: + return ucapi.EVChargeStateTypeError, nil + case model.DeviceDiagnosisOperatingStateTypeFinished: + return ucapi.EVChargeStateTypeFinished, nil + } + + return ucapi.EVChargeStateTypeUnknown, nil +} + +// return if an EV is connected +// +// this includes all required features and +// minimal data being available +func (e *EVCC) EVConnected(entity spineapi.EntityRemoteInterface) bool { + if entity == nil || entity.Device() == nil { + return false + } + + // getting current charge state should work + if _, err := e.ChargeState(entity); err != nil { + return false + } + + remoteDevice := e.LocalEntity.Device().RemoteDeviceForSki(entity.Device().Ski()) + if remoteDevice == nil { + return false + } + + // check if the device still has an entity assigned with the provided entities address + return remoteDevice.Entity(entity.Address().Entity) == entity +} + +func (e *EVCC) deviceConfigurationValueForKeyName( + entity spineapi.EntityRemoteInterface, + keyname model.DeviceConfigurationKeyNameType, + valueType model.DeviceConfigurationKeyValueTypeType) (*model.DeviceConfigurationKeyValueDataType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + evDeviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil { + return nil, api.ErrDataNotAvailable + } + + // check if device configuration descriptions has an communication standard key name + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + if _, err = evDeviceConfiguration.GetKeyValueDescriptionsForFilter(filter); err != nil { + return nil, err + } + + filter.ValueType = &valueType + data, err := evDeviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil { + return nil, err + } + + if data == nil { + return nil, api.ErrDataNotAvailable + } + + return data, nil +} + +// return the current communication standard type used to communicate between EVSE and EV +// +// if an EV is connected via IEC61851, no ISO15118 specific data can be provided! +// sometimes the connection starts with IEC61851 before it switches +// to ISO15118, and sometimes it falls back again. so the error return is +// never absolut for the whole connection time, except if the use case +// is not supported +// +// the values are not constant and can change due to communication problems, bugs, and +// sometimes communication starts with IEC61851 before it switches to ISO +// +// possible errors: +// - ErrDataNotAvailable if that information is not (yet) available +// - and others +func (e *EVCC) CommunicationStandard(entity spineapi.EntityRemoteInterface) (model.DeviceConfigurationKeyValueStringType, error) { + unknown := EVCCCommunicationStandardUnknown + + if !e.IsCompatibleEntityType(entity) { + return unknown, api.ErrNoCompatibleEntity + } + + data, err := e.deviceConfigurationValueForKeyName(entity, model.DeviceConfigurationKeyNameTypeCommunicationsStandard, model.DeviceConfigurationKeyValueTypeTypeString) + if err != nil || data == nil || data.Value == nil || data.Value.String == nil { + return unknown, api.ErrDataNotAvailable + } + + return *data.Value.String, nil +} + +// return if the EV supports asymmetric charging +// +// possible errors: +// - ErrDataNotAvailable if that information is not (yet) available +func (e *EVCC) AsymmetricChargingSupport(entity spineapi.EntityRemoteInterface) (bool, error) { + if !e.IsCompatibleEntityType(entity) { + return false, api.ErrNoCompatibleEntity + } + + data, err := e.deviceConfigurationValueForKeyName(entity, model.DeviceConfigurationKeyNameTypeAsymmetricChargingSupported, model.DeviceConfigurationKeyValueTypeTypeBoolean) + if err != nil || data == nil || data.Value == nil || data.Value.Boolean == nil { + return false, api.ErrDataNotAvailable + } + + return *data.Value.Boolean, nil +} + +// return the identifications of the currently connected EV or nil if not available +// +// possible errors: +// - ErrDataNotAvailable if that information is not (yet) available +// - and others +func (e *EVCC) Identifications(entity spineapi.EntityRemoteInterface) ([]ucapi.IdentificationItem, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + evIdentification, err := client.NewIdentification(e.LocalEntity, entity) + if err != nil { + return nil, api.ErrDataNotAvailable + } + + identifications, err := evIdentification.GetDataForFilter(model.IdentificationDataType{}) + if err != nil { + return nil, err + } + + var ids []ucapi.IdentificationItem + for _, identification := range identifications { + item := ucapi.IdentificationItem{} + + typ := identification.IdentificationType + if typ != nil { + item.ValueType = *typ + } + + value := identification.IdentificationValue + if value != nil { + item.Value = string(*value) + } + + ids = append(ids, item) + } + + return ids, nil +} + +// the manufacturer data of an EVSE +// returns deviceName, serialNumber, error +func (e *EVCC) ManufacturerData( + entity spineapi.EntityRemoteInterface, +) ( + api.ManufacturerData, + error, +) { + if !e.IsCompatibleEntityType(entity) { + return api.ManufacturerData{}, api.ErrNoCompatibleEntity + } + + return internal.ManufacturerData(e.LocalEntity, entity) +} + +// return the minimum, maximum charging and, standby power of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *EVCC) ChargingPowerLimits(entity spineapi.EntityRemoteInterface) (float64, float64, float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0.0, 0.0, 0.0, api.ErrNoCompatibleEntity + } + + evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil { + return 0.0, 0.0, 0.0, api.ErrDataNotAvailable + } + + filter := model.ElectricalConnectionParameterDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + elParamDesc, err := evElectricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(elParamDesc) == 0 || elParamDesc[0].ParameterId == nil { + return 0.0, 0.0, 0.0, api.ErrDataNotAvailable + } + + filter2 := model.ElectricalConnectionPermittedValueSetDataType{ + ParameterId: elParamDesc[0].ParameterId, + } + dataSet, err := evElectricalConnection.GetPermittedValueSetForFilter(filter2) + if err != nil || len(dataSet) == 0 || + dataSet[0].PermittedValueSet == nil || + len(dataSet[0].PermittedValueSet) != 1 || + dataSet[0].PermittedValueSet[0].Range == nil || + len(dataSet[0].PermittedValueSet[0].Range) != 1 { + return 0.0, 0.0, 0.0, api.ErrDataNotAvailable + } + + var minValue, maxValue, standByValue float64 + if dataSet[0].PermittedValueSet[0].Range[0].Min != nil { + minValue = dataSet[0].PermittedValueSet[0].Range[0].Min.GetValue() + } + if dataSet[0].PermittedValueSet[0].Range[0].Max != nil { + maxValue = dataSet[0].PermittedValueSet[0].Range[0].Max.GetValue() + } + if len(dataSet[0].PermittedValueSet[0].Value) > 0 { + standByValue = dataSet[0].PermittedValueSet[0].Value[0].GetValue() + } + + return minValue, maxValue, standByValue, nil +} + +// is the EV in sleep mode +// returns operatingState, lastErrorCode, error +func (e *EVCC) IsInSleepMode( + entity spineapi.EntityRemoteInterface, +) (bool, error) { + if !e.IsCompatibleEntityType(entity) { + return false, api.ErrNoCompatibleEntity + } + + evseDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, entity) + if err != nil { + return false, err + } + + data, err := evseDeviceDiagnosis.GetState() + if err != nil { + return false, err + } + + if data.OperatingState != nil && + *data.OperatingState == model.DeviceDiagnosisOperatingStateTypeStandby { + return true, nil + } + + return false, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/results.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/results.go new file mode 100644 index 0000000..bff5581 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/results.go @@ -0,0 +1,57 @@ +package evcc + +import ( + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +func (e *EVCC) HandleResponse(responseMsg api.ResponseMessage) { + // before SPINE 1.3 the heartbeats are on the EVSE entity + if responseMsg.EntityRemote == nil || + (responseMsg.EntityRemote.EntityType() != model.EntityTypeTypeEV && + responseMsg.EntityRemote.EntityType() != model.EntityTypeTypeEVSE) { + return + } + + // handle errors coming from the remote EVSE entity + if responseMsg.FeatureLocal.Type() == model.FeatureTypeTypeDeviceDiagnosis { + e.handleResultDeviceDiagnosis(responseMsg) + } +} + +// Handle DeviceDiagnosis Results +func (e *EVCC) handleResultDeviceDiagnosis(responseMsg api.ResponseMessage) { + // is this an error for a heartbeat message? + if responseMsg.DeviceRemote == nil || + responseMsg.Data == nil { + return + } + + result, ok := responseMsg.Data.(*model.ResultDataType) + if !ok { + return + } + + if result.ErrorNumber == nil || + *result.ErrorNumber == model.ErrorNumberTypeNoError { + return + } + + // check if this is for a cached notify message + datagram, err := responseMsg.DeviceRemote.Sender().DatagramForMsgCounter(responseMsg.MsgCounterReference) + if err != nil { + return + } + + if len(datagram.Payload.Cmd) > 0 && + datagram.Payload.Cmd[0].DeviceDiagnosisHeartbeatData != nil { + // something is horribly wrong, disconnect and hope a new connection will fix it + errorText := fmt.Sprintf("Error Code: %d", result.ErrorNumber) + if result.Description != nil { + errorText = fmt.Sprintf("%s - %s", errorText, string(*result.Description)) + } + e.service.DisconnectSKI(responseMsg.DeviceRemote.Ski(), errorText) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/types.go new file mode 100644 index 0000000..b9c5e46 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/types.go @@ -0,0 +1,75 @@ +package evcc + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/spine-go/model" +) + +// value if the UCEVCC communication standard is unknown +const ( + EVCCCommunicationStandardUnknown model.DeviceConfigurationKeyValueStringType = "unknown" +) + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-evcc-UseCaseSupportUpdate" + + // An EV was connected + // + // Use Case EVCC, Scenario 1 + EvConnected api.EventType = "cem-evcc-EvConnected" + + // An EV was disconnected + // + // Note: The ev entity is no longer connected to the device! + // + // Use Case EVCC, Scenario 8 + EvDisconnected api.EventType = "cem-evcc-EvDisconnected" + + // EV charge state data was updated + // + // Use `ChargeState` to get the current data + DataUpdateChargeState api.EventType = "cem-evcc-DataUpdateChargeState" + + // EV communication standard data was updated + // + // Use `CommunicationStandard` to get the current data + // + // Use Case EVCC, Scenario 2 + DataUpdateCommunicationStandard api.EventType = "cem-evcc-DataUpdateCommunicationStandard" + + // EV asymmetric charging data was updated + // + // Use `AsymmetricChargingSupport` to get the current data + DataUpdateAsymmetricChargingSupport api.EventType = "cem-evcc-DataUpdateAsymmetricChargingSupport" + + // EV identificationdata was updated + // + // Use `Identifications` to get the current data + // + // Use Case EVCC, Scenario 4 + DataUpdateIdentifications api.EventType = "cem-evcc-DataUpdateIdentifications" + + // EV manufacturer data was updated + // + // Use `ManufacturerData` to get the current data + // + // Use Case EVCC, Scenario 5 + DataUpdateManufacturerData api.EventType = "cem-evcc-DataUpdateManufacturerData" + + // EV charging power limits + // + // Use `ChargingPowerLimits` to get the current data + // + // Use Case EVCC, Scenario 6 + DataUpdateCurrentLimits api.EventType = "cem-evcc-DataUpdateCurrentLimits" + + // EV permitted power limits updated + // + // Use `IsInSleepMode` to get the current data + // + // Use Case EVCC, Scenario 7 + DataUpdateIsInSleepMode api.EventType = "cem-evcc-DataUpdateIsInSleepMode" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/usecase.go new file mode 100644 index 0000000..0fcdbad --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcc/usecase.go @@ -0,0 +1,104 @@ +package evcc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type EVCC struct { + *usecase.UseCaseBase + + service api.ServiceInterface +} + +var _ ucapi.CemEVCCInterface = (*EVCC)(nil) + +func NewEVCC( + service api.ServiceInterface, + localEntity spineapi.EntityLocalInterface, + eventCB api.EntityEventCallback, +) *EVCC { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeIdentification}, + }, + { + Scenario: model.UseCaseScenarioSupportType(5), + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceClassification}, + }, + { + Scenario: model.UseCaseScenarioSupportType(6), + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeElectricalConnection}, + }, + { + Scenario: model.UseCaseScenarioSupportType(7), + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + { + Scenario: model.UseCaseScenarioSupportType(8), + Mandatory: true, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeEVCommissioningAndConfiguration, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &EVCC{ + UseCaseBase: usecase, + service: service, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *EVCC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeIdentification, + model.FeatureTypeTypeDeviceClassification, + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeDeviceDiagnosis, + } + for _, feature := range clientFeatures { + f := e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + f.AddResultCallback(e.HandleResponse) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/events.go new file mode 100644 index 0000000..e26e655 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/events.go @@ -0,0 +1,134 @@ +package evcem + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *EVCEM) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EV entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + switch payload.Data.(type) { + case *model.ElectricalConnectionDescriptionListDataType: + e.evElectricalConnectionDescriptionDataUpdate(payload) + + case *model.MeasurementDescriptionListDataType: + e.evMeasurementDescriptionDataUpdate(payload.Entity) + + case *model.MeasurementListDataType: + e.evMeasurementDataUpdate(payload) + } +} + +// an EV was connected +func (e *EVCEM) evConnected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + + if evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if !evElectricalConnection.HasSubscription() { + if _, err := evElectricalConnection.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get electrical connection descriptions + if _, err := evElectricalConnection.RequestDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get electrical connection parameter descriptions + if _, err := evElectricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if !evMeasurement.HasSubscription() { + if _, err := evMeasurement.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + // get measurement descriptions + if _, err := evMeasurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get measurement constraints + if _, err := evMeasurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the electrical connection description data of an EV was updated +func (e *EVCEM) evElectricalConnectionDescriptionDataUpdate(payload spineapi.EventPayload) { + if payload.Data == nil { + return + } + + data, ok := payload.Data.(*model.ElectricalConnectionDescriptionListDataType) + if !ok { + return + } + + for _, item := range data.ElectricalConnectionDescriptionData { + if item.ElectricalConnectionId != nil && item.AcConnectedPhases != nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePhasesConnected) + return + } + } +} + +// the measurement description data of an EV was updated +func (e *EVCEM) evMeasurementDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + // get measurement values + if _, err := evMeasurement.RequestData(nil, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the measurement data of an EV was updated +func (e *EVCEM) evMeasurementDataUpdate(payload spineapi.EventPayload) { + if evMeasurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + // Scenario 1 + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + if evMeasurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentPerPhase) + } + + // Scenario 2 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACPower) + if evMeasurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePowerPerPhase) + } + + // Scenario 3 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeCharge) + if evMeasurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyCharged) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/public.go new file mode 100644 index 0000000..ff1a905 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/public.go @@ -0,0 +1,175 @@ +package evcem + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the number of ac connected phases of the EV or 0 if it is unknown +func (e *EVCEM) PhasesConnected(entity spineapi.EntityRemoteInterface) (uint, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + evElectricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil { + return 0, api.ErrDataNotAvailable + } + + data, err := evElectricalConnection.GetDescriptionsForFilter(model.ElectricalConnectionDescriptionDataType{}) + if err != nil || len(data) == 0 { + return 0, api.ErrDataNotAvailable + } + + for _, item := range data { + if item.ElectricalConnectionId != nil && item.AcConnectedPhases != nil { + return *item.AcConnectedPhases, nil + } + } + + // default to 0 if the value is not available + return 0, nil +} + +// return the last current measurement for each phase of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *EVCEM) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity) + evElectricalConnection, err2 := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil || err2 != nil { + return nil, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + data, err := evMeasurement.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return nil, api.ErrDataNotAvailable + } + + var result []float64 + + for _, phase := range ucapi.PhaseNameMapping { + for _, item := range data { + if item.Value == nil { + continue + } + + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + elParam, err := evElectricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(elParam) == 0 || + elParam[0].AcMeasuredPhases == nil || *elParam[0].AcMeasuredPhases != phase { + continue + } + + phaseValue := item.Value.GetValue() + result = append(result, phaseValue) + } + } + + return result, nil +} + +// return the last power measurement for each phase of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity) + evElectricalConnection, err2 := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil || err2 != nil { + return nil, err + } + + var data []model.MeasurementDataType + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + data, err = evMeasurement.GetDataForFilter(filter) + // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test case Test_EVPowerPerPhase_Current + if err != nil || len(data) == 0 || data[0].Value == nil { + return nil, api.ErrDataNotAvailable + } + + var result []float64 + + for _, phase := range ucapi.PhaseNameMapping { + for _, item := range data { + if item.Value == nil { + continue + } + + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + elParam, err := evElectricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(elParam) == 0 || + *elParam[0].AcMeasuredPhases != phase { + continue + } + + phaseValue := item.Value.GetValue() + result = append(result, phaseValue) + } + } + + return result, nil +} + +// return the charged energy measurement in Wh of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *EVCEM) EnergyCharged(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + } + data, err := evMeasurement.GetDataForFilter(filter) + if err != nil || len(data) == 0 { + return 0, api.ErrDataNotAvailable + } + + // we assume there is only one result + value := data[0].Value + if value == nil { + return 0, api.ErrDataNotAvailable + } + + return value.GetValue(), err +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/types.go new file mode 100644 index 0000000..7a7b991 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/types.go @@ -0,0 +1,38 @@ +package evcem + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-evcem-UseCaseSupportUpdate" + + // EV number of connected phases data updated + // + // Use `PhasesConnected` to get the current data + // + // Use Case EVCEM, Scenario 1 + DataUpdatePhasesConnected api.EventType = "cem-evcem-DataUpdatePhasesConnected" + + // EV current measurement data updated + // + // Use `CurrentPerPhase` to get the current data + // + // Use Case EVCEM, Scenario 1 + DataUpdateCurrentPerPhase api.EventType = "cem-evcem-DataUpdateCurrentPerPhase" + + // EV power measurement data updated + // + // Use `PowerPerPhase` to get the current data + // + // Use Case EVCEM, Scenario 2 + DataUpdatePowerPerPhase api.EventType = "cem-evcem-DataUpdatePowerPerPhase" + + // EV charging energy measurement data updated + // + // Use `EnergyCharged` to get the current data + // + // Use Case EVCEM, Scenario 3 + DataUpdateEnergyCharged api.EventType = "cem-evcem-DataUpdateEnergyCharged" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/usecase.go new file mode 100644 index 0000000..c87a943 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evcem/usecase.go @@ -0,0 +1,82 @@ +package evcem + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + usecase "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type EVCEM struct { + *usecase.UseCaseBase + + service api.ServiceInterface +} + +var _ ucapi.CemEVCEMInterface = (*EVCEM)(nil) + +func NewEVCEM(service api.ServiceInterface, localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVCEM { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeMeasurementOfElectricityDuringEVCharging, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes) + + uc := &EVCEM{ + UseCaseBase: usecase, + service: service, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *EVCEM) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/events.go new file mode 100644 index 0000000..6b8a1e7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/events.go @@ -0,0 +1,78 @@ +package evsecc + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// handle SPINE events +func (e *EVSECC) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EVSE entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evseConnected(payload) + return + } else if internal.IsEntityDisconnected(payload) { + e.evseDisconnected(payload) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.DeviceClassificationManufacturerDataType: + e.evseManufacturerDataUpdate(payload) + + case *model.DeviceDiagnosisStateDataType: + e.evseStateUpdate(payload) + } +} + +// an EVSE was connected +func (e *EVSECC) evseConnected(payload spineapi.EventPayload) { + if evseDeviceClassification, err := client.NewDeviceClassification(e.LocalEntity, payload.Entity); err == nil { + _, _ = evseDeviceClassification.RequestManufacturerDetails() + } + + if evseDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + _, _ = evseDeviceDiagnosis.RequestState() + } + + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, EvseConnected) + } +} + +// an EVSE was disconnected +func (e *EVSECC) evseDisconnected(payload spineapi.EventPayload) { + if e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, EvseDisconnected) + } +} + +// the manufacturer Data of an EVSE was updated +func (e *EVSECC) evseManufacturerDataUpdate(payload spineapi.EventPayload) { + if evDeviceClassification, err := client.NewDeviceClassification(e.LocalEntity, payload.Entity); err == nil { + if _, err := evDeviceClassification.GetManufacturerDetails(); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateManufacturerData) + } + } +} + +// the operating State of an EVSE was updated +func (e *EVSECC) evseStateUpdate(payload spineapi.EventPayload) { + if evDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + if _, err := evDeviceDiagnosis.GetState(); err == nil && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateOperatingState) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/public.go new file mode 100644 index 0000000..1a76c6a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/public.go @@ -0,0 +1,58 @@ +package evsecc + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// the manufacturer data of an EVSE +// returns deviceName, serialNumber, error +func (e *EVSECC) ManufacturerData( + entity spineapi.EntityRemoteInterface, +) ( + api.ManufacturerData, + error, +) { + if !e.IsCompatibleEntityType(entity) { + return api.ManufacturerData{}, api.ErrNoCompatibleEntity + } + + return internal.ManufacturerData(e.LocalEntity, entity) +} + +// the operating state data of an EVSE +// returns operatingState, lastErrorCode, error +func (e *EVSECC) OperatingState( + entity spineapi.EntityRemoteInterface, +) ( + model.DeviceDiagnosisOperatingStateType, string, error, +) { + operatingState := model.DeviceDiagnosisOperatingStateTypeNormalOperation + lastErrorCode := "" + + if !e.IsCompatibleEntityType(entity) { + return operatingState, lastErrorCode, api.ErrNoCompatibleEntity + } + + evseDeviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, entity) + if err != nil { + return operatingState, lastErrorCode, err + } + + data, err := evseDeviceDiagnosis.GetState() + if err != nil { + return operatingState, lastErrorCode, err + } + + if data.OperatingState != nil { + operatingState = *data.OperatingState + } + if data.LastErrorCode != nil { + lastErrorCode = string(*data.LastErrorCode) + } + + return operatingState, lastErrorCode, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/types.go new file mode 100644 index 0000000..c83350d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/types.go @@ -0,0 +1,34 @@ +package evsecc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remotei entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-evsecc-UseCaseSupportUpdate" + + // An EVSE was connected + EvseConnected api.EventType = "cem-evsecc-EvseConnected" + + // An EVSE was disconnected + EvseDisconnected api.EventType = "cem-evsecc-EvseDisconnected" + + // EVSE manufacturer data was updated + // + // Use `ManufacturerData` to get the current data + // + // Use Case EVSECC, Scenario 1 + // + // The entity of the message is the entity of the EVSE + DataUpdateManufacturerData api.EventType = "cem-evsecc-DataUpdateManufacturerData" + + // EVSE operation state was updated + // + // Use `OperatingState` to get the current data + // + // Use Case EVSECC, Scenario 2 + // + // The entity of the message is the entity of the EVSE + DataUpdateOperatingState api.EventType = "cem-evsecc-DataUpdateOperatingState" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/usecase.go new file mode 100644 index 0000000..9a5423a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsecc/usecase.go @@ -0,0 +1,69 @@ +package evsecc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type EVSECC struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemEVSECCInterface = (*EVSECC)(nil) + +func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVSECC { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEVSE, + model.UseCaseActorTypeEV, // The Porsche PMCC devices use this actor for this use case incorrectly + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEVSE, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceClassification}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeEVSECommissioningAndConfiguration, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes) + + uc := &EVSECC{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *EVSECC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceClassification, + model.FeatureTypeTypeDeviceDiagnosis, + } + + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/events.go new file mode 100644 index 0000000..21d5910 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/events.go @@ -0,0 +1,72 @@ +package evsoc + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *EVSOC) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EV entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.MeasurementListDataType: + e.evMeasurementDataUpdate(payload) + default: + return + } +} + +// an EV was connected +func (e *EVSOC) evConnected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + // TODO: Don't do these requests for now, only add it once SPINE supports handling filtering identical pending subscription requests + // Also: these are covered by EVCEM anyway, which is required + /* + if evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if _, err := evMeasurement.Subscribe(); err != nil { + logging.Log().Debug(err) + } + + // get measurement descriptions + if _, err := evMeasurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get measurement constraints + if _, err := evMeasurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + */ +} + +// the measurement data of an EV was updated +func (e *EVSOC) evMeasurementDataUpdate(payload spineapi.EventPayload) { + // Scenario 1 + if evMeasurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeStateOfCharge), + } + if evMeasurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateStateOfCharge) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/public.go new file mode 100644 index 0000000..77f8086 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/public.go @@ -0,0 +1,39 @@ +package evsoc + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the last known SoC of the connected EV +// +// only works with a current ISO15118-2 with VAS or ISO15118-20 +// communication between EVSE and EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *EVSOC) StateOfCharge(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + evMeasurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil || evMeasurement == nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePercentage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeStateOfCharge), + } + result, err := evMeasurement.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/types.go new file mode 100644 index 0000000..66c4ee9 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/types.go @@ -0,0 +1,17 @@ +package evsoc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-evsoc-UseCaseSupportUpdate" + + // EV state of charge data was updated + // + // Use `StateOfCharge` to get the current data + // + // Use Case EVSOC, Scenario 1 + DataUpdateStateOfCharge api.EventType = "cem-evsoc-DataUpdateStateOfCharge" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/usecase.go new file mode 100644 index 0000000..996c440 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/evsoc/usecase.go @@ -0,0 +1,68 @@ +package evsoc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + usecase "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type EVSOC struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemEVSOCInterface = (*EVSOC)(nil) + +func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVSOC { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeMeasurement}, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeEVStateOfCharge, + "1.0.0", + "RC1", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &EVSOC{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *EVSOC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} + +func (e *EVSOC) UpdateUseCaseAvailability(available bool) { + e.LocalEntity.SetUseCaseAvailability(model.UseCaseActorTypeCEM, e.UseCaseName, available) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/events.go new file mode 100644 index 0000000..05a3340 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/events.go @@ -0,0 +1,125 @@ +package opev + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *OPEV) HandleEvent(payload spineapi.EventPayload) { + // only about events from an EV entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.evConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.ElectricalConnectionPermittedValueSetListDataType: + e.evElectricalPermittedValuesUpdate(payload) + + case *model.LoadControlLimitDescriptionListDataType: + e.evLoadControlLimitDescriptionDataUpdate(payload.Entity) + + case *model.LoadControlLimitListDataType: + e.evLoadControlLimitDataUpdate(payload) + } +} + +// an EV was connected +func (e *OPEV) evConnected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + if evLoadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + if !evLoadControl.HasSubscription() { + if _, err := evLoadControl.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !evLoadControl.HasBinding() { + if _, err := evLoadControl.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get descriptions + if _, err := evLoadControl.RequestLimitDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + + // get constraints + if _, err := evLoadControl.RequestLimitConstraints(nil, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit description data of an EV was updated +func (e *OPEV) evLoadControlLimitDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if evLoadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + // get values + if _, err := evLoadControl.RequestLimitData(nil, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit data of an EV was updated +func (e *OPEV) evLoadControlLimitDataUpdate(payload spineapi.EventPayload) { + lc, err := client.NewLoadControl(e.LocalEntity, payload.Entity) + if err != nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection), + } + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } +} + +// the electrical connection permitted value sets data of an EV was updated +func (e *OPEV) evElectricalPermittedValuesUpdate(payload spineapi.EventPayload) { + if ec, err := client.NewElectricalConnection(e.LocalEntity, payload.Entity); err == nil { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + } + data, err := ec.GetParameterDescriptionsForFilter(filter) + if err != nil || len(data) == 0 || data[0].ParameterId == nil { + return + } + + filter = model.ElectricalConnectionParameterDescriptionDataType{ + ParameterId: data[0].ParameterId, + } + values, err := ec.GetParameterDescriptionsForFilter(filter) + if err != nil || values == nil { + return + } + + // Scenario 6 + filter1 := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: values[0].ElectricalConnectionId, + ParameterId: values[0].ParameterId, + } + if ec.CheckEventPayloadDataForFilter(payload.Data, filter1) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentLimits) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/public.go new file mode 100644 index 0000000..53732d6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/public.go @@ -0,0 +1,108 @@ +package opev + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the min, max, default limits for each phase of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *OPEV) CurrentLimits(entity spineapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, nil, nil, api.ErrNoCompatibleEntity + } + + ec, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil { + return nil, nil, nil, err + } + + meas, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return nil, nil, nil, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + measDesc, err := meas.GetDescriptionsForFilter(filter) + if err != nil { + return nil, nil, nil, err + } + + return ec.GetPhaseCurrentLimits(measDesc) +} + +// return the current loadcontrol obligation limits +// +// parameters: +// - entity: the entity of the EV +// +// return values: +// - limits: per phase data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *OPEV) LoadControlLimits(entity spineapi.EntityRemoteInterface) ( + limits []ucapi.LoadLimitsPhase, resultErr error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection), + } + return internal.LoadControlLimits(e.LocalEntity, entity, filter) +} + +// send new LoadControlLimits to the remote EV +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - limits: a set of limits containing phase specific limit data +// - resultCB: callback function for handling the result response +// +// Sets a maximum A limit for each phase that the EV may not exceed. +// Mainly used for implementing overload protection of the site or limiting the +// maximum charge power of EVs when the EV and EVSE communicate via IEC61851 +// and with ISO15118 if the EV does not support the Optimization of Self Consumption +// usecase. +// +// note: +// For obligations to work for optimizing solar excess power, the EV needs to +// have an energy demand. Recommendations work even if the EV does not have an active +// energy demand, given it communicated with the EVSE via ISO15118 and supports the usecase. +// In ISO15118-2 the usecase is only supported via VAS extensions which are vendor specific +// and needs to have specific EVSE support for the specific EV brand. +// In ISO15118-20 this is a standard feature which does not need special support on the EVSE. +func (e *OPEV) WriteLoadControlLimits( + entity spineapi.EntityRemoteInterface, + limits []ucapi.LoadLimitsPhase, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + ScopeType: util.Ptr(model.ScopeTypeTypeOverloadProtection), + } + return internal.WriteLoadControlPhaseLimits(e.LocalEntity, entity, filter, limits, resultCB) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/types.go new file mode 100644 index 0000000..72641f2 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/types.go @@ -0,0 +1,20 @@ +package opev + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-opev-UseCaseSupportUpdate" + + // EV current limits + // + // Use `CurrentLimits` to get the current data + DataUpdateCurrentLimits api.EventType = "cem-opev-DataUpdateCurrentLimits" + + // EV load control obligation limit data updated + // + // Use `LoadControlLimits` to get the current data + DataUpdateLimit api.EventType = "cem-opev-DataUpdateLimit" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/usecase.go new file mode 100644 index 0000000..2ad79d9 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/opev/usecase.go @@ -0,0 +1,80 @@ +package opev + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type OPEV struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemOPEVInterface = (*OPEV)(nil) + +func NewOPEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *OPEV { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeOverloadProtectionByEVChargingCurrentCurtailment, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &OPEV{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *OPEV) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeElectricalConnection, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/events.go new file mode 100644 index 0000000..9a1d75c --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/events.go @@ -0,0 +1,79 @@ +package oscev + +import ( + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *OSCEV) HandleEvent(payload spineapi.EventPayload) { + // most of the events are identical to OPEV, and OPEV is required to be used, + // we don't handle the same events in here + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.ElectricalConnectionPermittedValueSetListDataType: + e.evElectricalPermittedValuesUpdate(payload) + + case *model.LoadControlLimitListDataType: + e.evLoadControlLimitDataUpdate(payload) + } +} + +// the load control limit data of an EV was updated +func (e *OSCEV) evLoadControlLimitDataUpdate(payload spineapi.EventPayload) { + lc, err := client.NewLoadControl(e.LocalEntity, payload.Entity) + if err != nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation), + ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption), + } + + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } +} + +// the electrical connection permitted value sets data of an EV was updated +func (e *OSCEV) evElectricalPermittedValuesUpdate(payload spineapi.EventPayload) { + if ec, err := client.NewElectricalConnection(e.LocalEntity, payload.Entity); err == nil { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + } + data, err := ec.GetParameterDescriptionsForFilter(filter) + if err != nil || len(data) == 0 || data[0].ParameterId == nil { + return + } + + filter = model.ElectricalConnectionParameterDescriptionDataType{ + ParameterId: data[0].ParameterId, + } + values, err := ec.GetParameterDescriptionsForFilter(filter) + if err != nil || values == nil { + return + } + + // Scenario 6 + filter1 := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: values[0].ElectricalConnectionId, + ParameterId: values[0].ParameterId, + } + if ec.CheckEventPayloadDataForFilter(payload.Data, filter1) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentLimits) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/public.go new file mode 100644 index 0000000..02a4976 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/public.go @@ -0,0 +1,101 @@ +package oscev + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the min, max, default limits for each phase of the connected EV +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *OSCEV) CurrentLimits(entity spineapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, nil, nil, api.ErrNoCompatibleEntity + } + + ec, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil { + return nil, nil, nil, err + } + + meas, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return nil, nil, nil, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + measDesc, err := meas.GetDescriptionsForFilter(filter) + if err != nil { + return nil, nil, nil, err + } + + return ec.GetPhaseCurrentLimits(measDesc) +} + +// return the current loadcontrol recommendation limits +// +// parameters: +// - entity: the entity of the EV +// +// return values: +// - limits: per phase data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *OSCEV) LoadControlLimits(entity spineapi.EntityRemoteInterface) ( + limits []ucapi.LoadLimitsPhase, resultErr error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation), + ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption), + } + return internal.LoadControlLimits(e.LocalEntity, entity, filter) +} + +// send new LoadControlLimits to the remote EV +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - limits: a set of limits containing phase specific limit data +// - resultCB: callback function for handling the result response +// +// recommendations: +// Sets a recommended charge power in A for each phase. This is mainly +// used if the EV and EVSE communicate via ISO15118 to support charging excess solar power. +// The EV either needs to support the Optimization of Self Consumption usecase or +// the EVSE needs to be able map the recommendations into oligation limits which then +// works for all EVs communication either via IEC61851 or ISO15118. +func (e *OSCEV) WriteLoadControlLimits( + entity spineapi.EntityRemoteInterface, + limits []ucapi.LoadLimitsPhase, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeMaxValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeRecommendation), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + ScopeType: util.Ptr(model.ScopeTypeTypeSelfConsumption), + } + return internal.WriteLoadControlPhaseLimits(e.LocalEntity, entity, filter, limits, resultCB) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/types.go new file mode 100644 index 0000000..aeefbc7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/types.go @@ -0,0 +1,22 @@ +package oscev + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-oscev-UseCaseSupportUpdate" + + // EV current limits + // + // Use `CurrentLimits` to get the current data + DataUpdateCurrentLimits api.EventType = "cem-oscev-DataUpdateCurrentLimits" + + // EV load control recommendation limit data updated + // + // Use `LoadControlLimits` to get the current data + // + // Use Case OSCEV, Scenario 1 + DataUpdateLimit api.EventType = "cem-oscev-DataUpdateLimit" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/usecase.go new file mode 100644 index 0000000..c74a588 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/oscev/usecase.go @@ -0,0 +1,80 @@ +package oscev + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type OSCEV struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemOSCEVInterface = (*OSCEV)(nil) + +func NewOSCEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *OSCEV { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeEV, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeEV, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeOptimizationOfSelfConsumptionDuringEVCharging, + "1.0.1", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &OSCEV{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *OSCEV) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeElectricalConnection, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/events.go new file mode 100644 index 0000000..fa8f9ab --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/events.go @@ -0,0 +1,115 @@ +package vabd + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *VABD) HandleEvent(payload spineapi.EventPayload) { + // only about events from an SGMW entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.inverterConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.MeasurementDescriptionListDataType: + e.inverterMeasurementDescriptionDataUpdate(payload.Entity) + + case *model.MeasurementListDataType: + e.inverterMeasurementDataUpdate(payload) + } +} + +// process required steps when a grid device is connected +func (e *VABD) inverterConnected(entity spineapi.EntityRemoteInterface) { + if electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if !electricalConnection.HasSubscription() { + if _, err := electricalConnection.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get electrical connection parameter + if _, err := electricalConnection.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := electricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if !measurement.HasSubscription() { + if _, err := measurement.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get measurement parameters + if _, err := measurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := measurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Error(err) + } + } +} + +// the measurement descriptiondata of an SMGW was updated +func (e *VABD) inverterMeasurementDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + // measurement descriptions received, now get the data + if _, err := measurement.RequestData(nil, nil); err != nil { + logging.Log().Error("Error getting measurement list values:", err) + } + } +} + +// the measurement data of an SMGW was updated +func (e *VABD) inverterMeasurementDataUpdate(payload spineapi.EventPayload) { + if measurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + // Scenario 1 + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePower) + } + + // Scenario 2 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeCharge) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyCharged) + } + + // Scenario 3 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeDischarge) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyDischarged) + } + + // Scenario 4 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeStateOfCharge) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateStateOfCharge) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/public.go new file mode 100644 index 0000000..413569e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/public.go @@ -0,0 +1,106 @@ +package vabd + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the current battery (dis-)charge power (W) +// +// - positive values charge power +// - negative values discharge power +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VABD) Power(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + return e.getValuesFoFilter(entity, filter) +} + +// return the total charge energy (Wh) +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VABD) EnergyCharged(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + } + return e.getValuesFoFilter(entity, filter) +} + +// return the total discharge energy (Wh) +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VABD) EnergyDischarged(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeDischarge), + } + return e.getValuesFoFilter(entity, filter) +} + +// return the current state of charge in % +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VABD) StateOfCharge(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePercentage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeStateOfCharge), + } + return e.getValuesFoFilter(entity, filter) +} + +// helper + +func (e *VABD) getValuesFoFilter( + entity spineapi.EntityRemoteInterface, + filter model.MeasurementDescriptionDataType, +) (float64, error) { + if entity == nil { + return 0, api.ErrDeviceDisconnected + } + + measurementF, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, api.ErrFunctionNotSupported + } + + result, err := measurementF.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/types.go new file mode 100644 index 0000000..f847257 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/types.go @@ -0,0 +1,38 @@ +package vabd + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-vabd-UseCaseSupportUpdate" + + // Battery System (dis)charge power data updated + // + // Use `Power` to get the current data + // + // Use Case VABD, Scenario 1 + DataUpdatePower api.EventType = "cem-vabd-DataUpdatePower" + + // Battery System cumulated charge energy data updated + // + // Use `EnergyCharged` to get the current data + // + // Use Case VABD, Scenario 2 + DataUpdateEnergyCharged api.EventType = "cem-vabd-DataUpdateEnergyCharged" + + // Battery System cumulated discharge energy data updated + // + // Use `EnergyDischarged` to get the current data + // + // Use Case VABD, Scenario 3 + DataUpdateEnergyDischarged api.EventType = "cem-vabd-DataUpdateEnergyDischarged" + + // Battery System state of charge data updated + // + // Use `StateOfCharge` to get the current data + // + // Use Case VABD, Scenario 4 + DataUpdateStateOfCharge api.EventType = "cem-vabd-DataUpdateStateOfCharge" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/usecase.go new file mode 100644 index 0000000..f996bec --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vabd/usecase.go @@ -0,0 +1,90 @@ +package vabd + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type VABD struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemVABDInterface = (*VABD)(nil) + +func NewVABD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *VABD { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypeBatterySystem, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeElectricityStorageSystem, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeVisualizationOfAggregatedBatteryData, + "1.0.1", + "RC1", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &VABD{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *VABD) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/events.go new file mode 100644 index 0000000..30f94a6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/events.go @@ -0,0 +1,146 @@ +package vapd + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *VAPD) HandleEvent(payload spineapi.EventPayload) { + // only about events from an SGMW entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.inverterConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.DeviceConfigurationKeyValueDescriptionListDataType: + e.inverterConfigurationDescriptionDataUpdate(payload.Entity) + + case *model.DeviceConfigurationKeyValueListDataType: + e.inverterConfigurationDataUpdate(payload) + + case *model.MeasurementDescriptionListDataType: + e.inverterMeasurementDescriptionDataUpdate(payload.Entity) + + case *model.MeasurementListDataType: + e.inverterMeasurementDataUpdate(payload) + } +} + +// process required steps when a grid device is connected +func (e *VAPD) inverterConnected(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + if !deviceConfiguration.HasSubscription() { + if _, err := deviceConfiguration.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get configuration data + if _, err := deviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if !electricalConnection.HasSubscription() { + if _, err := electricalConnection.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get electrical connection parameter + if _, err := electricalConnection.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := electricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if !measurement.HasSubscription() { + if _, err := measurement.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get measurement parameters + if _, err := measurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := measurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Error(err) + } + } +} + +// the configuration key description data of an SMGW was updated +func (e *VAPD) inverterConfigurationDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + // key value descriptions received, now get the data + if _, err := deviceConfiguration.RequestKeyValues(nil, nil); err != nil { + logging.Log().Error("Error getting configuration key values:", err) + } + } +} + +// the measurement data of an SMGW was updated +func (e *VAPD) inverterConfigurationDataUpdate(payload spineapi.EventPayload) { + // Scenario 1 + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypePeakPowerOfPVSystem), + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + } + if deviceConfiguration.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePowerNominalPeak) + } + } +} + +// the measurement descriptiondata of an SMGW was updated +func (e *VAPD) inverterMeasurementDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + // measurement descriptions received, now get the data + if _, err := measurement.RequestData(nil, nil); err != nil { + logging.Log().Error("Error getting measurement list values:", err) + } + } +} + +// the measurement data of an SMGW was updated +func (e *VAPD) inverterMeasurementDataUpdate(payload spineapi.EventPayload) { + if measurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + // Scenario 2 + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePower) + } + + // Scenario 3 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACYieldTotal) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePVYieldTotal) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/public.go new file mode 100644 index 0000000..0821406 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/public.go @@ -0,0 +1,102 @@ +package vapd + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the current photovoltaic production power (W) +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VAPD) Power(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + return e.getValuesFoFilter(entity, filter) +} + +// return the nominal photovoltaic peak power (W) +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VAPD) PowerNominalPeak(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil { + return 0, api.ErrFunctionNotSupported + } + + keyName := model.DeviceConfigurationKeyNameTypePeakPowerOfPVSystem + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyName, + } + if _, err := deviceConfiguration.GetKeyValueDescriptionsForFilter(filter); err != nil { + return 0, err + } + + filter = model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyName, + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.ScaledNumber == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.ScaledNumber.GetValue(), nil +} + +// return the total photovoltaic yield (Wh) +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func (e *VAPD) PVYieldTotal(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACYieldTotal), + } + return e.getValuesFoFilter(entity, filter) +} + +// helper + +func (e *VAPD) getValuesFoFilter( + entity spineapi.EntityRemoteInterface, + filter model.MeasurementDescriptionDataType, +) (float64, error) { + if entity == nil { + return 0, api.ErrDeviceDisconnected + } + + measurementF, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, api.ErrFunctionNotSupported + } + + result, err := measurementF.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/types.go new file mode 100644 index 0000000..637c738 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/types.go @@ -0,0 +1,31 @@ +package vapd + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cem-vapd-UseCaseSupportUpdate" + + // PV System total power data updated + // + // Use `Power` to get the current data + // + // Use Case VAPD, Scenario 1 + DataUpdatePower api.EventType = "cem-vapd-DataUpdatePower" + + // PV System nominal peak power data updated + // + // Use `PowerNominalPeak` to get the current data + // + // Use Case VAPD, Scenario 2 + DataUpdatePowerNominalPeak api.EventType = "cem-vapd-DataUpdatePowerNominalPeak" + + // PV System total yield data updated + // + // Use `PVYieldTotal` to get the current data + // + // Use Case VAPD, Scenario 3 + DataUpdatePVYieldTotal api.EventType = "cem-vapd-DataUpdatePVYieldTotal" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/usecase.go new file mode 100644 index 0000000..5e901a7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cem/vapd/usecase.go @@ -0,0 +1,81 @@ +package vapd + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type VAPD struct { + *usecase.UseCaseBase +} + +var _ ucapi.CemVAPDInterface = (*VAPD)(nil) + +func NewVAPD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *VAPD { + validActorTypes := []model.UseCaseActorType{ + model.UseCaseActorTypePVSystem, + } + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypePVSystem, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeCEM, + model.UseCaseNameTypeVisualizationOfAggregatedPhotovoltaicData, + "1.0.1", + "RC1", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &VAPD{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *VAPD) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/events.go new file mode 100644 index 0000000..acf1d68 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/events.go @@ -0,0 +1,180 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpc + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *LPC) HandleEvent(payload spineapi.EventPayload) { + if internal.IsDeviceConnected(payload) { + e.deviceConnected(payload) + return + } + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + // did we receive a binding to the loadControl server and the + // heartbeatWorkaround is required? + if payload.EventType == spineapi.EventTypeBindingChange && + payload.ChangeType == spineapi.ElementChangeAdd && + payload.LocalFeature != nil && + payload.LocalFeature.Type() == model.FeatureTypeTypeLoadControl && + payload.LocalFeature.Role() == model.RoleTypeServer { + e.subscribeHeartbeatWorkaround(payload) + return + } + + if internal.IsHeartbeat(payload) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateHeartbeat) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate || + payload.CmdClassifier == nil || + *payload.CmdClassifier != model.CmdClassifierTypeWrite { + return + } + + switch payload.Data.(type) { + case *model.LoadControlLimitListDataType: + serverF := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + + if payload.Function != model.FunctionTypeLoadControlLimitListData || + payload.LocalFeature != serverF { + return + } + + e.loadControlLimitDataUpdate(payload) + case *model.DeviceConfigurationKeyValueListDataType: + serverF := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) + + if payload.Function != model.FunctionTypeDeviceConfigurationKeyValueListData || + payload.LocalFeature != serverF { + return + } + + e.configurationDataUpdate(payload) + } +} + +// a remote device was connected and we know its entities +func (e *LPC) deviceConnected(payload spineapi.EventPayload) { + if payload.Device == nil { + return + } + + // check if there is a DeviceDiagnosis server on one or more entities + remoteDevice := payload.Device + + var deviceDiagEntities []spineapi.EntityRemoteInterface + + entities := remoteDevice.Entities() + for _, entity := range entities { + if !e.IsCompatibleEntityType(entity) { + continue + } + + deviceDiagF := entity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + if deviceDiagF == nil { + continue + } + + deviceDiagEntities = append(deviceDiagEntities, entity) + } + + logging.Log().Debug("cs-lpc:", len(deviceDiagEntities), "DeviceDiagnosis Server found") + + // the remote device does not have a DeviceDiagnosis Server, which it should + if len(deviceDiagEntities) == 0 { + return + } + + // we only found one matching entity, as it should be, subscribe + if len(deviceDiagEntities) == 1 { + if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, deviceDiagEntities[0]); err == nil { + e.setHeartbeatDiag(localDeviceDiag) + if !localDeviceDiag.HasSubscription() { + if _, err := localDeviceDiag.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := localDeviceDiag.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } + + return + } + + // we found more than one matching entity, this is not good + // according to KEO the subscription should be done on the entity that requests a binding to + // the local loadControlLimit server feature + e.setHeartbeatKeoWorkaround() +} + +// subscribe to the DeviceDiagnosis Server of the entity that created a binding +func (e *LPC) subscribeHeartbeatWorkaround(payload spineapi.EventPayload) { + // is the workaround is needed? + if e.isHeartbeatKeoWorkaround() { + if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + e.setHeartbeatDiag(localDeviceDiag) + if !localDeviceDiag.HasSubscription() { + if _, err := localDeviceDiag.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := localDeviceDiag.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } + } +} + +// the load control limit data was updated +func (e *LPC) loadControlLimitDataUpdate(payload spineapi.EventPayload) { + if lc, err := server.NewLoadControl(e.LocalEntity); err == nil { + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } + } +} + +// the configuration key data of an SMGW was updated +func (e *LPC) configurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := server.NewDeviceConfiguration(e.LocalEntity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeConsumptionActivePowerLimit) + } + filter = model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeDurationMinimum) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/heartbeat_race_test.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/heartbeat_race_test.go new file mode 100644 index 0000000..99f401e --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/heartbeat_race_test.go @@ -0,0 +1,33 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// eebus-go (see LICENSE). + +package lpc + +import ( + "sync" + "testing" +) + +// SPINE delivers a device's connect events on their own goroutines while +// the application asks for the heartbeat: run with -race (before, the +// fields were written and read without a lock). +func TestHeartbeatFieldsUnderLock(t *testing.T) { + e := &LPC{} + var wg sync.WaitGroup + for g := 0; g < 4; g++ { + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < 1000; i++ { + e.setHeartbeatDiag(nil) + e.setHeartbeatKeoWorkaround() + _ = e.IsHeartbeatWithinDuration() + _ = e.isHeartbeatKeoWorkaround() + } + }() + } + wg.Wait() + if !e.isHeartbeatKeoWorkaround() || e.IsHeartbeatWithinDuration() { + t.Fatal("state after the writes") + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/public.go new file mode 100644 index 0000000..df15b6a --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/public.go @@ -0,0 +1,354 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpc + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the current loadcontrol limit data +// +// return values: +// - limit: load limit data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *LPC) ConsumptionLimit() (limit ucapi.LoadLimit, resultErr error) { + limit = ucapi.LoadLimit{ + Value: 0.0, + IsChangeable: false, + IsActive: false, + Duration: 0, + } + resultErr = api.ErrDataNotAvailable + + lc, limidId, err := e.loadControlServerAndLimitId() + if err != nil { + return limit, err + } + + value, err := lc.GetLimitDataForId(limidId) + if err != nil || value == nil || value.LimitId == nil || value.Value == nil { + return + } + + limit.Value = value.Value.GetValue() + limit.IsChangeable = (value.IsLimitChangeable != nil && *value.IsLimitChangeable) + limit.IsActive = (value.IsLimitActive != nil && *value.IsLimitActive) + if value.TimePeriod != nil && value.TimePeriod.EndTime != nil { + if duration, err := value.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + return limit, nil +} + +// set the current loadcontrol limit data +func (e *LPC) SetConsumptionLimit(limit ucapi.LoadLimit) (resultErr error) { + loadControlf, limidId, err := e.loadControlServerAndLimitId() + if err != nil { + return err + } + + limitData := model.LoadControlLimitDataType{ + LimitId: util.Ptr(limidId), + IsLimitChangeable: util.Ptr(limit.IsChangeable), + IsLimitActive: util.Ptr(limit.IsActive), + Value: model.NewScaledNumberType(limit.Value), + } + if limit.Duration > 0 { + limitData.TimePeriod = &model.TimePeriodType{ + EndTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(limit.Duration), + } + } + + deleteTimePeriod := &model.LoadControlLimitDataElementsType{ + TimePeriod: util.Ptr(model.TimePeriodElementsType{}), + } + + return loadControlf.UpdateLimitDataForId(limitData, deleteTimePeriod, limidId) +} + +// return the currently pending incoming consumption write limits +func (e *LPC) PendingConsumptionLimits() map[model.MsgCounterType]ucapi.LoadLimit { + result := make(map[model.MsgCounterType]ucapi.LoadLimit) + + _, limitId, err := e.loadControlServerAndLimitId() + if err != nil { + return result + } + + e.pendingMux.Lock() + defer e.pendingMux.Unlock() + + for key, msg := range e.pendingLimits { + data := msg.Cmd.LoadControlLimitListData + + // elements are only added to the map if all required fields exist + // therefor no checks for these are needed here + + // find the item which contains the limit for this usecase + for _, item := range data.LoadControlLimitData { + if item.LimitId == nil || + limitId != *item.LimitId { + continue + } + + limit := ucapi.LoadLimit{} + + if item.TimePeriod != nil { + if duration, err := item.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + if item.IsLimitActive != nil { + limit.IsActive = *item.IsLimitActive + } + + if item.Value != nil { + limit.Value = item.Value.GetValue() + } + + result[key] = limit + } + } + + return result +} + +// accept or deny an incoming consumption write limit +// +// use PendingConsumptionLimits to get the list of currently pending requests +func (e *LPC) ApproveOrDenyConsumptionLimit(msgCounter model.MsgCounterType, approve bool, reason string) { + e.pendingMux.Lock() + defer e.pendingMux.Unlock() + + msg, ok := e.pendingLimits[msgCounter] + if !ok { + // no pending limit for this msgCounter, this is a caller error + return + } + + e.approveOrDenyConsumptionLimit(msg, approve, reason) + + delete(e.pendingLimits, msgCounter) +} + +// Scenario 2 + +// return Failsafe limit for the consumed active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPC) FailsafeConsumptionActivePowerLimit() (limit float64, isChangeable bool, resultErr error) { + limit = 0 + isChangeable = false + resultErr = api.ErrDataNotAvailable + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), + } + keyData, err := dc.GetKeyValueDataForFilter(filter) + if err != nil || keyData == nil || keyData.KeyId == nil || keyData.Value == nil || keyData.Value.ScaledNumber == nil { + return + } + + limit = keyData.Value.ScaledNumber.GetValue() + isChangeable = (keyData.IsValueChangeable != nil && *keyData.IsValueChangeable) + resultErr = nil + return +} + +// set Failsafe limit for the consumed active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPC) SetFailsafeConsumptionActivePowerLimit(value float64, changeable bool) error { + keyName := model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit + keyValue := model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(value), + } + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return err + } + + data := model.DeviceConfigurationKeyValueDataType{ + Value: &keyValue, + IsValueChangeable: &changeable, + } + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(keyName), + } + return dc.UpdateKeyValueDataForFilter(data, nil, filter) +} + +// return minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +func (e *LPC) FailsafeDurationMinimum() (duration time.Duration, isChangeable bool, resultErr error) { + duration = 0 + isChangeable = false + resultErr = api.ErrDataNotAvailable + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + keyData, err := dc.GetKeyValueDataForFilter(filter) + if err != nil || keyData == nil || keyData.KeyId == nil || keyData.Value == nil || keyData.Value.Duration == nil { + return + } + + durationValue, err := keyData.Value.Duration.GetTimeDuration() + if err != nil { + return + } + + duration = durationValue + isChangeable = (keyData.IsValueChangeable != nil && *keyData.IsValueChangeable) + resultErr = nil + return +} + +// set minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +// +// parameters: +// - duration: has to be >= 2h and <= 24h +// - changeable: boolean if the client service can change this value +func (e *LPC) SetFailsafeDurationMinimum(duration time.Duration, changeable bool) error { + if duration < time.Duration(time.Hour*2) || duration > time.Duration(time.Hour*24) { + return errors.New("duration outside of allowed range") + } + keyName := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + keyValue := model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(duration), + } + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return err + } + + data := model.DeviceConfigurationKeyValueDataType{ + Value: &keyValue, + IsValueChangeable: &changeable, + } + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(keyName), + } + return dc.UpdateKeyValueDataForFilter(data, nil, filter) +} + +// Scenario 3 + +func (e *LPC) IsHeartbeatWithinDuration() bool { + diag := e.getHeartbeatDiag() + if diag == nil { + return false + } + + return diag.IsHeartbeatWithinDuration(2 * time.Minute) +} + +// Scenario 4 + +// return nominal maximum active (real) power the Controllable System is allowed to consume. +// +// If the local device type is an EnergyManagementSystem, the contractual consumption +// nominal max is returned, otherwise the power consumption nominal max is returned. +func (e *LPC) ConsumptionNominalMax() (value float64, resultErr error) { + value = 0 + resultErr = api.ErrDataNotAvailable + + ec, err := server.NewElectricalConnection(e.LocalEntity) + if err != nil { + resultErr = err + return + } + + filter := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + } + charData, err := ec.GetCharacteristicsForFilter(filter) + if err != nil || len(charData) == 0 || + charData[0].CharacteristicId == nil || + charData[0].Value == nil { + return + } + + return charData[0].Value.GetValue(), nil +} + +// set nominal maximum active (real) power the Controllable System is allowed to consume. +// +// If the local device type is an EnergyManagementSystem, the contractual consumption +// nominal max is set, otherwise the power consumption nominal max is set. +// +// parameters: +// - value: nominal max power consumption in W +func (e *LPC) SetConsumptionNominalMax(value float64) error { + ec, err := server.NewElectricalConnection(e.LocalEntity) + if err != nil { + return err + } + + electricalConnectionid := util.Ptr(model.ElectricalConnectionIdType(0)) + parameterId := util.Ptr(model.ElectricalConnectionParameterIdType(0)) + charList, err := ec.GetCharacteristicsForFilter(model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: electricalConnectionid, + ParameterId: parameterId, + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + }) + if err != nil || len(charList) == 0 { + return api.ErrDataNotAvailable + } + + data := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: electricalConnectionid, + ParameterId: parameterId, + CharacteristicId: charList[0].CharacteristicId, + Value: model.NewScaledNumberType(value), + } + return ec.UpdateCharacteristic(data, nil) +} + +// returns the characteristictype depending on the local entities device devicetype +func (e *LPC) characteristicType() model.ElectricalConnectionCharacteristicTypeType { + deviceType := e.LocalEntity.Device().DeviceType() + + // According to LPC V1.0 2.2, lines 400ff: + // - a HEMS provides contractual consumption nominal max + // - any other devices provides power consupmtion nominal max + characteristic := model.ElectricalConnectionCharacteristicTypeTypePowerConsumptionNominalMax + if deviceType == nil || *deviceType == model.DeviceTypeTypeEnergyManagementSystem { + characteristic = model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax + } + + return characteristic +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/types.go new file mode 100644 index 0000000..0f828a7 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/types.go @@ -0,0 +1,47 @@ +package lpc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cs-lpc-UseCaseSupportUpdate" + + // Load control obligation limit data update received + // + // Use `ConsumptionLimit` to get the current data + // + // Use Case LPC, Scenario 1 + DataUpdateLimit api.EventType = "cs-lpc-DataUpdateLimit" + + // An incoming load control obligation limit needs to be approved or denied + // + // Use `PendingConsumptionLimits` to get the currently pending write approval requests + // and invoke `ApproveOrDenyConsumptionLimit` for each + // + // Use Case LPC, Scenario 1 + WriteApprovalRequired api.EventType = "cs-lpc-WriteApprovalRequired" + + // Failsafe limit for the consumed active (real) power of the + // Controllable System data update received + // + // Use `FailsafeConsumptionActivePowerLimit` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeConsumptionActivePowerLimit api.EventType = "cs-lpc-DataUpdateFailsafeConsumptionActivePowerLimit" + + // Minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" data update received + // + // Use `FailsafeDurationMinimum` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeDurationMinimum api.EventType = "cs-lpc-DataUpdateFailsafeDurationMinimum" + + // Indicates a notify heartbeat event the application should care of. + // E.g. going into or out of the Failsafe state + // + // Use Case LPC, Scenario 3 + DataUpdateHeartbeat api.EventType = "cs-lpc-DataUpdateHeartbeat" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/usecase.go new file mode 100644 index 0000000..e9f3077 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpc/usecase.go @@ -0,0 +1,308 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpc + +import ( + "sync" + + "github.com/enbility/eebus-go/api" + features "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" + "github.com/enbility/spine-go/util" +) + +type LPC struct { + *usecase.UseCaseBase + + pendingMux sync.Mutex + pendingLimits map[model.MsgCounterType]*spineapi.Message + + heartbeatDiag *features.DeviceDiagnosis + + // heartbeatDiag and heartbeatKeoWorkaround: set by SPINE events, which + // arrive on their own goroutines, read by IsHeartbeatWithinDuration + heartbeatMux sync.Mutex + + heartbeatKeoWorkaround bool // required because KEO Stack uses multiple identical entities for the same functionality, and it is not clear which to use +} + +var _ ucapi.CsLPCInterface = (*LPC)(nil) + +func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *LPC { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeEnergyGuard} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeGridGuard, + model.EntityTypeTypeCEM, // KEO uses this entity type for an SMGW whysoever + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: true, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeControllableSystem, + model.UseCaseNameTypeLimitationOfPowerConsumption, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &LPC{ + UseCaseBase: usecase, + pendingLimits: make(map[model.MsgCounterType]*spineapi.Message), + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *LPC) loadControlServerAndLimitId() (lc *server.LoadControl, limitid model.LoadControlLimitIdType, err error) { + limitid = model.LoadControlLimitIdType(0) + + lc, err = server.NewLoadControl(e.LocalEntity) + if err != nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + descriptions, err := lc.GetLimitDescriptionsForFilter(filter) + if err != nil || len(descriptions) != 1 || descriptions[0].LimitId == nil { + return + } + description := descriptions[0] + + if description.LimitId == nil { + return + } + + return lc, *description.LimitId, nil +} + +func (e *LPC) approveOrDenyConsumptionLimit(msg *spineapi.Message, approve bool, reason string) { + f := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + + result := model.ErrorType{ + ErrorNumber: model.ErrorNumberType(0), + } + + if !approve { + result.ErrorNumber = model.ErrorNumberType(7) + result.Description = util.Ptr(model.DescriptionType(reason)) + } + f.ApproveOrDenyWrite(msg, result) +} + +// callback invoked on incoming write messages to this +// loadcontrol server feature. +// the implementation only considers write messages for this use case and +// approves all others +func (e *LPC) loadControlWriteCB(msg *spineapi.Message) { + if msg.RequestHeader == nil || msg.RequestHeader.MsgCounter == nil || + msg.Cmd.LoadControlLimitListData == nil { + logging.Log().Debug("LPC loadControlWriteCB: invalid message") + return + } + + _, limitId, err := e.loadControlServerAndLimitId() + if err != nil { + logging.Log().Debug("LPC loadControlWriteCB: error getting limit id") + return + } + + data := msg.Cmd.LoadControlLimitListData + + // we assume there is always only one limit + if data == nil || data.LoadControlLimitData == nil || + len(data.LoadControlLimitData) == 0 { + logging.Log().Debug("LPC loadControlWriteCB: no data") + return + } + + e.pendingMux.Lock() + + // check if there is a matching limitId in the data + for _, item := range data.LoadControlLimitData { + if item.LimitId == nil || + limitId != *item.LimitId { + continue + } + + if _, ok := e.pendingLimits[*msg.RequestHeader.MsgCounter]; !ok { + e.pendingLimits[*msg.RequestHeader.MsgCounter] = msg + e.pendingMux.Unlock() + e.EventCB(msg.DeviceRemote.Ski(), msg.DeviceRemote, msg.EntityRemote, WriteApprovalRequired) + return + } + } + e.pendingMux.Unlock() + + // approve, because this is no request for this usecase + go e.approveOrDenyConsumptionLimit(msg, true, "") +} + +func (e *LPC) AddFeatures() { + // client features + _ = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeClient) + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeLoadControlLimitDescriptionListData, true, false) + f.AddFunctionType(model.FunctionTypeLoadControlLimitListData, true, true) + _ = f.AddWriteApprovalCallback(e.loadControlWriteCB) + + newLimitDesc := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + MeasurementId: util.Ptr(model.MeasurementIdType(0)), // This is a fake Measurement ID, as there is no Electrical Connection server defined, it can't provide any meaningful. But KEO requires this to be set :( + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if lc, err := server.NewLoadControl(e.LocalEntity); err == nil { + limitId := lc.AddLimitDescription(newLimitDesc) + + newLimiData := model.LoadControlLimitDataType{ + Value: model.NewScaledNumberType(0), + IsLimitChangeable: util.Ptr(true), + IsLimitActive: util.Ptr(false), + } + _ = lc.UpdateLimitDataForId(newLimiData, nil, *limitId) + } + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceConfigurationKeyValueListData, true, true) + + if dcs, err := server.NewDeviceConfiguration(e.LocalEntity); err == nil { + dcs.AddKeyValueDescription( + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + ) + + // only add if it doesn't exist yet + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + if data, err := dcs.GetKeyValueDescriptionsForFilter(filter); err == nil && len(data) == 0 { + dcs.AddKeyValueDescription( + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration), + }, + ) + } + + value := &model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(0), + } + _ = dcs.UpdateKeyValueDataForFilter( + model.DeviceConfigurationKeyValueDataType{ + Value: value, + IsValueChangeable: util.Ptr(true), + }, + nil, + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), + }, + ) + + value = &model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(0), + } + _ = dcs.UpdateKeyValueDataForFilter( + model.DeviceConfigurationKeyValueDataType{ + Value: value, + IsValueChangeable: util.Ptr(true), + }, + nil, + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + }, + ) + } + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeElectricalConnection, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeElectricalConnectionCharacteristicListData, true, false) + + if ec, err := server.NewElectricalConnection(e.LocalEntity); err == nil { + // ElectricalConnectionId and ParameterId should be identical to the ones used + // in a MPC Server role implementation, which is not done here (yet) + newCharData := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + } + _, _ = ec.AddCharacteristic(newCharData) + } +} + +func (e *LPC) setHeartbeatDiag(diag *features.DeviceDiagnosis) { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + e.heartbeatDiag = diag +} + +func (e *LPC) getHeartbeatDiag() *features.DeviceDiagnosis { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + return e.heartbeatDiag +} + +func (e *LPC) setHeartbeatKeoWorkaround() { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + e.heartbeatKeoWorkaround = true +} + +func (e *LPC) isHeartbeatKeoWorkaround() bool { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + return e.heartbeatKeoWorkaround +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/events.go new file mode 100644 index 0000000..587cc2f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/events.go @@ -0,0 +1,180 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpp + +import ( + "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *LPP) HandleEvent(payload spineapi.EventPayload) { + if internal.IsDeviceConnected(payload) { + e.deviceConnected(payload) + return + } + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + // did we receive a binding to the loadControl server and the + // heartbeatWorkaround is required? + if payload.EventType == spineapi.EventTypeBindingChange && + payload.ChangeType == spineapi.ElementChangeAdd && + payload.LocalFeature != nil && + payload.LocalFeature.Type() == model.FeatureTypeTypeLoadControl && + payload.LocalFeature.Role() == model.RoleTypeServer { + e.subscribeHeartbeatWorkaround(payload) + return + } + + if internal.IsHeartbeat(payload) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateHeartbeat) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate || + payload.CmdClassifier == nil || + *payload.CmdClassifier != model.CmdClassifierTypeWrite { + return + } + + switch payload.Data.(type) { + case *model.LoadControlLimitListDataType: + serverF := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + + if payload.Function != model.FunctionTypeLoadControlLimitListData || + payload.LocalFeature != serverF { + return + } + + e.loadControlLimitDataUpdate(payload) + case *model.DeviceConfigurationKeyValueListDataType: + serverF := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) + + if payload.Function != model.FunctionTypeDeviceConfigurationKeyValueListData || + payload.LocalFeature != serverF { + return + } + + e.configurationDataUpdate(payload) + } +} + +// a remote device was connected and we know its entities +func (e *LPP) deviceConnected(payload spineapi.EventPayload) { + if payload.Device == nil { + return + } + + // check if there is a DeviceDiagnosis server on one or more entities + remoteDevice := payload.Device + + var deviceDiagEntities []spineapi.EntityRemoteInterface + + entities := remoteDevice.Entities() + for _, entity := range entities { + if !e.IsCompatibleEntityType(entity) { + continue + } + + deviceDiagF := entity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + if deviceDiagF == nil { + continue + } + + deviceDiagEntities = append(deviceDiagEntities, entity) + } + + logging.Log().Debug("cs-lpp:", len(deviceDiagEntities), "DeviceDiagnosis Server found") + + // the remote device does not have a DeviceDiagnosis Server, which it should + if len(deviceDiagEntities) == 0 { + return + } + + // we only found one matching entity, as it should be, subscribe + if len(deviceDiagEntities) == 1 { + if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, deviceDiagEntities[0]); err == nil { + e.setHeartbeatDiag(localDeviceDiag) + if !localDeviceDiag.HasSubscription() { + if _, err := localDeviceDiag.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := localDeviceDiag.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } + + return + } + + // we found more than one matching entity, this is not good + // according to KEO the subscription should be done on the entity that requests a binding to + // the local loadControlLimit server feature + e.setHeartbeatKeoWorkaround() +} + +// subscribe to the DeviceDiagnosis Server of the entity that created a binding +func (e *LPP) subscribeHeartbeatWorkaround(payload spineapi.EventPayload) { + // is the workaround is needed? + if e.isHeartbeatKeoWorkaround() { + if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, payload.Entity); err == nil { + e.setHeartbeatDiag(localDeviceDiag) + if !localDeviceDiag.HasSubscription() { + if _, err := localDeviceDiag.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := localDeviceDiag.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } + } +} + +// the load control limit data was updated +func (e *LPP) loadControlLimitDataUpdate(payload spineapi.EventPayload) { + if lc, err := server.NewLoadControl(e.LocalEntity); err == nil { + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + } + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } + } +} + +// the configuration key data was updated +func (e *LPP) configurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := server.NewDeviceConfiguration(e.LocalEntity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeProductionActivePowerLimit) + } + filter = model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeDurationMinimum) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/heartbeat_race_test.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/heartbeat_race_test.go new file mode 100644 index 0000000..f314eca --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/heartbeat_race_test.go @@ -0,0 +1,33 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// eebus-go (see LICENSE). + +package lpp + +import ( + "sync" + "testing" +) + +// SPINE delivers a device's connect events on their own goroutines while +// the application asks for the heartbeat: run with -race (before, the +// fields were written and read without a lock). +func TestHeartbeatFieldsUnderLock(t *testing.T) { + e := &LPP{} + var wg sync.WaitGroup + for g := 0; g < 4; g++ { + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < 1000; i++ { + e.setHeartbeatDiag(nil) + e.setHeartbeatKeoWorkaround() + _ = e.IsHeartbeatWithinDuration() + _ = e.isHeartbeatKeoWorkaround() + } + }() + } + wg.Wait() + if !e.isHeartbeatKeoWorkaround() || e.IsHeartbeatWithinDuration() { + t.Fatal("state after the writes") + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/public.go new file mode 100644 index 0000000..1e22cc3 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/public.go @@ -0,0 +1,354 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpp + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the current production limit data +// +// return values: +// - limit: load limit data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *LPP) ProductionLimit() (limit ucapi.LoadLimit, resultErr error) { + limit = ucapi.LoadLimit{ + Value: 0.0, + IsChangeable: false, + IsActive: false, + Duration: 0, + } + resultErr = api.ErrDataNotAvailable + + lc, limidId, err := e.loadControlServerAndLimitId() + if err != nil { + return limit, err + } + + value, err := lc.GetLimitDataForId(limidId) + if err != nil || value == nil || value.LimitId == nil || value.Value == nil { + return + } + + limit.Value = value.Value.GetValue() + limit.IsChangeable = (value.IsLimitChangeable != nil && *value.IsLimitChangeable) + limit.IsActive = (value.IsLimitActive != nil && *value.IsLimitActive) + if value.TimePeriod != nil && value.TimePeriod.EndTime != nil { + if duration, err := value.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + return limit, nil +} + +// set the current production limit data +func (e *LPP) SetProductionLimit(limit ucapi.LoadLimit) (resultErr error) { + loadControlf, limidId, err := e.loadControlServerAndLimitId() + if err != nil { + return err + } + + limitData := model.LoadControlLimitDataType{ + LimitId: util.Ptr(limidId), + IsLimitChangeable: util.Ptr(limit.IsChangeable), + IsLimitActive: util.Ptr(limit.IsActive), + Value: model.NewScaledNumberType(limit.Value), + } + if limit.Duration > 0 { + limitData.TimePeriod = &model.TimePeriodType{ + EndTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(limit.Duration), + } + } + + deleteTimePeriod := &model.LoadControlLimitDataElementsType{ + TimePeriod: util.Ptr(model.TimePeriodElementsType{}), + } + + return loadControlf.UpdateLimitDataForId(limitData, deleteTimePeriod, limidId) +} + +// return the currently pending incoming production write limits +func (e *LPP) PendingProductionLimits() map[model.MsgCounterType]ucapi.LoadLimit { + result := make(map[model.MsgCounterType]ucapi.LoadLimit) + + _, limitId, err := e.loadControlServerAndLimitId() + if err != nil { + return result + } + + e.pendingMux.Lock() + defer e.pendingMux.Unlock() + + for key, msg := range e.pendingLimits { + data := msg.Cmd.LoadControlLimitListData + + // elements are only added to the map if all required fields exist + // therefor no checks for these are needed here + + // find the item which contains the limit for this usecase + for _, item := range data.LoadControlLimitData { + if item.LimitId == nil || + limitId != *item.LimitId { + continue + } + + limit := ucapi.LoadLimit{} + + if item.TimePeriod != nil { + if duration, err := item.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + if item.IsLimitActive != nil { + limit.IsActive = *item.IsLimitActive + } + + if item.Value != nil { + limit.Value = item.Value.GetValue() + } + + result[key] = limit + } + } + + return result +} + +// accept or deny an incoming production write limit +// +// use PendingProductionLimits to get the list of currently pending requests +func (e *LPP) ApproveOrDenyProductionLimit(msgCounter model.MsgCounterType, approve bool, reason string) { + e.pendingMux.Lock() + defer e.pendingMux.Unlock() + + msg, ok := e.pendingLimits[msgCounter] + if !ok { + // no pending limit for this msgCounter, this is a caller error + return + } + + e.approveOrDenyProductionLimit(msg, approve, reason) + + delete(e.pendingLimits, msgCounter) +} + +// Scenario 2 + +// return Failsafe limit for the produced active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPP) FailsafeProductionActivePowerLimit() (limit float64, isChangeable bool, resultErr error) { + limit = 0 + isChangeable = false + resultErr = api.ErrDataNotAvailable + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), + } + keyData, err := dc.GetKeyValueDataForFilter(filter) + if err != nil || keyData == nil || keyData.KeyId == nil || keyData.Value == nil || keyData.Value.ScaledNumber == nil { + return + } + + limit = keyData.Value.ScaledNumber.GetValue() + isChangeable = (keyData.IsValueChangeable != nil && *keyData.IsValueChangeable) + resultErr = nil + return +} + +// set Failsafe limit for the produced active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPP) SetFailsafeProductionActivePowerLimit(value float64, changeable bool) error { + keyName := model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit + keyValue := model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(value), + } + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return err + } + + data := model.DeviceConfigurationKeyValueDataType{ + Value: &keyValue, + IsValueChangeable: &changeable, + } + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(keyName), + } + return dc.UpdateKeyValueDataForFilter(data, nil, filter) +} + +// return minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +func (e *LPP) FailsafeDurationMinimum() (duration time.Duration, isChangeable bool, resultErr error) { + duration = 0 + isChangeable = false + resultErr = api.ErrDataNotAvailable + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + keyData, err := dc.GetKeyValueDataForFilter(filter) + if err != nil || keyData == nil || keyData.KeyId == nil || keyData.Value == nil || keyData.Value.Duration == nil { + return + } + + durationValue, err := keyData.Value.Duration.GetTimeDuration() + if err != nil { + return + } + + duration = durationValue + isChangeable = (keyData.IsValueChangeable != nil && *keyData.IsValueChangeable) + resultErr = nil + return +} + +// set minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +// +// parameters: +// - duration: has to be >= 2h and <= 24h +// - changeable: boolean if the client service can change this value +func (e *LPP) SetFailsafeDurationMinimum(duration time.Duration, changeable bool) error { + if duration < time.Duration(time.Hour*2) || duration > time.Duration(time.Hour*24) { + return errors.New("duration outside of allowed range") + } + keyName := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + keyValue := model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(duration), + } + + dc, err := server.NewDeviceConfiguration(e.LocalEntity) + if err != nil { + return err + } + + data := model.DeviceConfigurationKeyValueDataType{ + Value: &keyValue, + IsValueChangeable: &changeable, + } + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(keyName), + } + return dc.UpdateKeyValueDataForFilter(data, nil, filter) +} + +// Scenario 3 + +func (e *LPP) IsHeartbeatWithinDuration() bool { + diag := e.getHeartbeatDiag() + if diag == nil { + return false + } + + return diag.IsHeartbeatWithinDuration(2 * time.Minute) +} + +// Scenario 4 + +// return nominal maximum active (real) power the Controllable System is allowed to produce. +// +// If the local device type is an EnergyManagementSystem, the contractual production +// nominal max is returned, otherwise the power production nominal max is returned. +func (e *LPP) ProductionNominalMax() (value float64, resultErr error) { + value = 0 + resultErr = api.ErrDataNotAvailable + + ec, err := server.NewElectricalConnection(e.LocalEntity) + if err != nil { + resultErr = err + return + } + + filter := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + } + charData, err := ec.GetCharacteristicsForFilter(filter) + if err != nil || len(charData) == 0 || + charData[0].CharacteristicId == nil || + charData[0].Value == nil { + return + } + + return charData[0].Value.GetValue(), nil +} + +// set nominal maximum active (real) power the Controllable System is allowed to produce. +// +// If the local device type is an EnergyManagementSystem, the contractual production +// nominal max is set, otherwise the power production nominal max is set. +// +// parameters: +// - value: nominal max power production in W +func (e *LPP) SetProductionNominalMax(value float64) error { + ec, err := server.NewElectricalConnection(e.LocalEntity) + if err != nil { + return err + } + + electricalConnectionid := util.Ptr(model.ElectricalConnectionIdType(0)) + parameterId := util.Ptr(model.ElectricalConnectionParameterIdType(0)) + charList, err := ec.GetCharacteristicsForFilter(model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: electricalConnectionid, + ParameterId: parameterId, + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + }) + if err != nil || len(charList) == 0 { + return api.ErrDataNotAvailable + } + + data := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: electricalConnectionid, + ParameterId: parameterId, + CharacteristicId: charList[0].CharacteristicId, + Value: model.NewScaledNumberType(value), + } + return ec.UpdateCharacteristic(data, nil) +} + +// returns the characteristictype depending on the local entities device devicetype +func (e *LPP) characteristicType() model.ElectricalConnectionCharacteristicTypeType { + deviceType := e.LocalEntity.Device().DeviceType() + + // According to LPP V1.0 2.2, lines 420ff: + // - a HEMS provides contractual production nominal max + // - any other devices provides power production nominal max + characteristic := model.ElectricalConnectionCharacteristicTypeTypePowerProductionNominalMax + if deviceType == nil || *deviceType == model.DeviceTypeTypeEnergyManagementSystem { + characteristic = model.ElectricalConnectionCharacteristicTypeTypeContractualProductionNominalMax + } + + return characteristic +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/types.go new file mode 100644 index 0000000..697641d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/types.go @@ -0,0 +1,47 @@ +package lpp + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "cs-lpp-UseCaseSupportUpdate" + + // Load control obligation limit data update received + // + // Use `ProductionLimit` to get the current data + // + // Use Case LPC, Scenario 1 + DataUpdateLimit api.EventType = "cs-lpp-DataUpdateLimit" + + // An incoming load control obligation limit needs to be approved or denied + // + // Use `PendingProductionLimits` to get the currently pending write approval requests + // and invoke `ApproveOrDenyProductionLimit` for each + // + // Use Case LPC, Scenario 1 + WriteApprovalRequired api.EventType = "cs-lpp-WriteApprovalRequired" + + // Failsafe limit for the produced active (real) power of the + // Controllable System data update received + // + // Use `FailsafeProductionActivePowerLimit` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeProductionActivePowerLimit api.EventType = "cs-lpp-DataUpdateFailsafeProductionActivePowerLimit" + + // Minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" data update received + // + // Use `FailsafeDurationMinimum` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeDurationMinimum api.EventType = "cs-lpp-DataUpdateFailsafeDurationMinimum" + + // Indicates a notify heartbeat event the application should care of. + // E.g. going into or out of the Failsafe state + // + // Use Case LPP, Scenario 3 + DataUpdateHeartbeat api.EventType = "uclpcserver-DataUpdateHeartbeat" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/usecase.go new file mode 100644 index 0000000..62dd3f8 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/cs/lpp/usecase.go @@ -0,0 +1,308 @@ +// Modified from eebus-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the heartbeat's DeviceDiagnosis and the KEO workaround flag under +// a lock (SPINE delivers events to use cases on their own goroutines). + +package lpp + +import ( + "sync" + + "github.com/enbility/eebus-go/api" + features "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" + "github.com/enbility/spine-go/util" +) + +type LPP struct { + *usecase.UseCaseBase + + pendingMux sync.Mutex + pendingLimits map[model.MsgCounterType]*spineapi.Message + + heartbeatDiag *features.DeviceDiagnosis + + // heartbeatDiag and heartbeatKeoWorkaround: set by SPINE events, which + // arrive on their own goroutines, read by IsHeartbeatWithinDuration + heartbeatMux sync.Mutex + + heartbeatKeoWorkaround bool // required because KEO Stack uses multiple identical entities for the same functionality, and it is not clear which to use +} + +var _ ucapi.CsLPPInterface = (*LPP)(nil) + +func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *LPP { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeEnergyGuard} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeGridGuard, + model.EntityTypeTypeCEM, // KEO uses this entity type for an SMGW whysoever + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: true, + }, + } + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeControllableSystem, + model.UseCaseNameTypeLimitationOfPowerProduction, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &LPP{ + UseCaseBase: usecase, + pendingLimits: make(map[model.MsgCounterType]*spineapi.Message), + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *LPP) loadControlServerAndLimitId() (lc *server.LoadControl, limitid model.LoadControlLimitIdType, err error) { + limitid = model.LoadControlLimitIdType(0) + + lc, err = server.NewLoadControl(e.LocalEntity) + if err != nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + descriptions, err := lc.GetLimitDescriptionsForFilter(filter) + if err != nil || len(descriptions) != 1 || descriptions[0].LimitId == nil { + return + } + description := descriptions[0] + + if description.LimitId == nil { + return + } + + return lc, *description.LimitId, nil +} + +func (e *LPP) approveOrDenyProductionLimit(msg *spineapi.Message, approve bool, reason string) { + f := e.LocalEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + + result := model.ErrorType{ + ErrorNumber: model.ErrorNumberType(0), + } + + if !approve { + result.ErrorNumber = model.ErrorNumberType(7) + result.Description = util.Ptr(model.DescriptionType(reason)) + } + f.ApproveOrDenyWrite(msg, result) +} + +// callback invoked on incoming write messages to this +// loadcontrol server feature. +// the implementation only considers write messages for this use case and +// approves all others +func (e *LPP) loadControlWriteCB(msg *spineapi.Message) { + if msg.RequestHeader == nil || msg.RequestHeader.MsgCounter == nil || + msg.Cmd.LoadControlLimitListData == nil { + logging.Log().Debug("LPP loadControlWriteCB: invalid message") + return + } + + _, limitId, err := e.loadControlServerAndLimitId() + if err != nil { + logging.Log().Debug("LPP loadControlWriteCB: error getting limit id") + return + } + + data := msg.Cmd.LoadControlLimitListData + + // we assume there is always only one limit + if data == nil || data.LoadControlLimitData == nil || + len(data.LoadControlLimitData) == 0 { + logging.Log().Debug("LPP loadControlWriteCB: no data") + return + } + + e.pendingMux.Lock() + + // check if there is a matching limitId in the data + for _, item := range data.LoadControlLimitData { + if item.LimitId == nil || + limitId != *item.LimitId { + continue + } + + if _, ok := e.pendingLimits[*msg.RequestHeader.MsgCounter]; !ok { + e.pendingLimits[*msg.RequestHeader.MsgCounter] = msg + e.pendingMux.Unlock() + e.EventCB(msg.DeviceRemote.Ski(), msg.DeviceRemote, msg.EntityRemote, WriteApprovalRequired) + return + } + } + + e.pendingMux.Unlock() + + // approve, because this is no request for this usecase + go e.approveOrDenyProductionLimit(msg, true, "") +} + +func (e *LPP) AddFeatures() { + // client features + _ = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeClient) + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeLoadControlLimitDescriptionListData, true, false) + f.AddFunctionType(model.FunctionTypeLoadControlLimitListData, true, true) + _ = f.AddWriteApprovalCallback(e.loadControlWriteCB) + + newLimitDesc := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitCategory: util.Ptr(model.LoadControlCategoryTypeObligation), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + MeasurementId: util.Ptr(model.MeasurementIdType(0)), // This is a fake Measurement ID, as there is no Electrical Connection server defined, it can't provide any meaningful. But KEO requires this to be set :( + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if lc, err := server.NewLoadControl(e.LocalEntity); err == nil { + limitId := lc.AddLimitDescription(newLimitDesc) + + newLimiData := model.LoadControlLimitDataType{ + Value: model.NewScaledNumberType(0), + IsLimitChangeable: util.Ptr(true), + IsLimitActive: util.Ptr(false), + } + _ = lc.UpdateLimitDataForId(newLimiData, nil, *limitId) + } + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceConfigurationKeyValueListData, true, true) + + if dcs, err := server.NewDeviceConfiguration(e.LocalEntity); err == nil { + dcs.AddKeyValueDescription( + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + ) + + // only add if it doesn't exist yet + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + } + if data, err := dcs.GetKeyValueDescriptionsForFilter(filter); err == nil && len(data) == 0 { + dcs.AddKeyValueDescription( + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration), + }, + ) + } + + value := &model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(0), + } + _ = dcs.UpdateKeyValueDataForFilter( + model.DeviceConfigurationKeyValueDataType{ + Value: value, + IsValueChangeable: util.Ptr(true), + }, + nil, + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), + }, + ) + + value = &model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(0), + } + _ = dcs.UpdateKeyValueDataForFilter( + model.DeviceConfigurationKeyValueDataType{ + Value: value, + IsValueChangeable: util.Ptr(true), + }, + nil, + model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), + }, + ) + } + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeElectricalConnection, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeElectricalConnectionCharacteristicListData, true, false) + + if ec, err := server.NewElectricalConnection(e.LocalEntity); err == nil { + // ElectricalConnectionId and ParameterId should be identical to the ones used + // in a MPC Server role implementation, which is not done here (yet) + newCharData := model.ElectricalConnectionCharacteristicDataType{ + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType()), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + } + _, _ = ec.AddCharacteristic(newCharData) + } +} + +func (e *LPP) setHeartbeatDiag(diag *features.DeviceDiagnosis) { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + e.heartbeatDiag = diag +} + +func (e *LPP) getHeartbeatDiag() *features.DeviceDiagnosis { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + return e.heartbeatDiag +} + +func (e *LPP) setHeartbeatKeoWorkaround() { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + e.heartbeatKeoWorkaround = true +} + +func (e *LPP) isHeartbeatKeoWorkaround() bool { + e.heartbeatMux.Lock() + defer e.heartbeatMux.Unlock() + + return e.heartbeatKeoWorkaround +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/events.go new file mode 100644 index 0000000..5d92c4b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/events.go @@ -0,0 +1,161 @@ +package lpc + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *LPC) HandleEvent(payload spineapi.EventPayload) { + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + if internal.IsEntityConnected(payload) { + e.connected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.LoadControlLimitDescriptionListDataType: + e.loadControlLimitDescriptionDataUpdate(payload.Entity) + + case *model.LoadControlLimitListDataType: + e.loadControlLimitDataUpdate(payload) + + case *model.DeviceConfigurationKeyValueDescriptionListDataType: + e.configurationDescriptionDataUpdate(payload.Entity) + + case *model.DeviceConfigurationKeyValueListDataType: + e.configurationDataUpdate(payload) + } +} + +// the remote entity was connected +func (e *LPC) connected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + if loadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + if !loadControl.HasSubscription() { + if _, err := loadControl.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !loadControl.HasBinding() { + if _, err := loadControl.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get descriptions + selector := &model.LoadControlLimitDescriptionListDataSelectorsType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if _, err := loadControl.RequestLimitDescriptions(selector, nil); err != nil { + logging.Log().Debug(err) + } + } + + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + if !deviceConfiguration.HasSubscription() { + if _, err := deviceConfiguration.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !deviceConfiguration.HasBinding() { + if _, err := deviceConfiguration.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get descriptions + // don't use selectors yet, as we would have to query 2 which could result in 2 full reads + if _, err := deviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if deviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, entity); err == nil { + if !deviceDiagnosis.HasSubscription() { + if _, err := deviceDiagnosis.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := deviceDiagnosis.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit description data was updated +func (e *LPC) loadControlLimitDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if loadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + // get values + var selector *model.LoadControlLimitListDataSelectorsType + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if descs, err := loadControl.GetLimitDescriptionsForFilter(filter); err == nil && len(descs) > 0 { + selector = &model.LoadControlLimitListDataSelectorsType{ + LimitId: descs[0].LimitId, + } + } + if _, err := loadControl.RequestLimitData(selector, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit data was updated +func (e *LPC) loadControlLimitDataUpdate(payload spineapi.EventPayload) { + if lc, err := client.NewLoadControl(e.LocalEntity, payload.Entity); err == nil { + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } + } +} + +// the configuration key description data was updated +func (e *LPC) configurationDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + // key value descriptions received, now get the data + if _, err := deviceConfiguration.RequestKeyValues(nil, nil); err != nil { + logging.Log().Error("Error getting configuration key values:", err) + } + } +} + +// the configuration key data was updated +func (e *LPC) configurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeConsumptionActivePowerLimit) + } + filter.KeyName = util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum) + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeDurationMinimum) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/public.go new file mode 100644 index 0000000..0a33f71 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/public.go @@ -0,0 +1,282 @@ +package lpc + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + internal "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the current loadcontrol limit data +// +// parameters: +// - entity: the entity of the e.g. EVSE +// +// return values: +// - limit: load limit data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *LPC) ConsumptionLimit(entity spineapi.EntityRemoteInterface) ( + limit ucapi.LoadLimit, resultErr error) { + limit = ucapi.LoadLimit{ + Value: 0.0, + IsChangeable: false, + IsActive: false, + } + + resultErr = api.ErrNoCompatibleEntity + if !e.IsCompatibleEntityType(entity) { + return + } + + resultErr = api.ErrDataNotAvailable + loadControl, err := client.NewLoadControl(e.LocalEntity, entity) + if err != nil || loadControl == nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + limitDescriptions, err := loadControl.GetLimitDescriptionsForFilter(filter) + if err != nil || len(limitDescriptions) != 1 { + return + } + + value, err := loadControl.GetLimitDataForId(*limitDescriptions[0].LimitId) + if err != nil || value.Value == nil { + return + } + + limit.Value = value.Value.GetValue() + limit.IsChangeable = (value.IsLimitChangeable != nil && *value.IsLimitChangeable) + limit.IsActive = (value.IsLimitActive != nil && *value.IsLimitActive) + if value.TimePeriod != nil && value.TimePeriod.EndTime != nil { + if duration, err := value.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + resultErr = nil + + return +} + +// send new LoadControlLimits +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - limit: load limit data +// - resultCB: callback function for handling the result response +func (e *LPC) WriteConsumptionLimit( + entity spineapi.EntityRemoteInterface, + limit ucapi.LoadLimit, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeConsume), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + + return internal.WriteLoadControlLimit(e.LocalEntity, entity, filter, limit, resultCB) +} + +// Scenario 2 + +// return Failsafe limit for the consumed active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPC) FailsafeConsumptionActivePowerLimit(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return 0, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.ScaledNumber == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.ScaledNumber.GetValue(), nil +} + +// send new Failsafe Consumption Active Power Limit +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - value: the new limit in W +func (e *LPC) WriteFailsafeConsumptionActivePowerLimit(entity spineapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return nil, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + data, err := deviceConfiguration.GetKeyValueDescriptionsForFilter(filter) + if err != nil || data == nil || len(data) != 1 { + return nil, api.ErrDataNotAvailable + } + + keyData := []model.DeviceConfigurationKeyValueDataType{ + { + KeyId: data[0].KeyId, + Value: &model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(value), + }, + }, + } + + msgCounter, err := deviceConfiguration.WriteKeyValues(keyData) + + return msgCounter, err +} + +// return minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +func (e *LPC) FailsafeDurationMinimum(entity spineapi.EntityRemoteInterface) (time.Duration, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return 0, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration), + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.Duration == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.Duration.GetTimeDuration() +} + +// send new Failsafe Duration Minimum +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - duration: the duration, between 2h and 24h +func (e *LPC) WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + if duration < time.Duration(time.Hour*2) || duration > time.Duration(time.Hour*24) { + return nil, errors.New("duration outside of allowed range") + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return nil, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil { + return nil, api.ErrDataNotAvailable + } + + keyData := []model.DeviceConfigurationKeyValueDataType{ + { + KeyId: data.KeyId, + Value: &model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(duration), + }, + }, + } + + msgCounter, err := deviceConfiguration.WriteKeyValues(keyData) + + return msgCounter, err +} + +// Scenario 4 + +// return nominal maximum active (real) power the Controllable System is +// able to consume according to the contract (EMS), device label or data sheet. +func (e *LPC) ConsumptionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil || electricalConnection == nil { + return 0, err + } + + filter := model.ElectricalConnectionCharacteristicDataType{ + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType(entity)), + } + data, err := electricalConnection.GetCharacteristicsForFilter(filter) + if err != nil { + return 0, err + } else if len(data) == 0 || data[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + + return data[0].Value.GetValue(), nil +} + +// returns the characteristictype depending on the remote entities device devicetype +func (e *LPC) characteristicType(entity spineapi.EntityRemoteInterface) model.ElectricalConnectionCharacteristicTypeType { + // According to LPC V1.0 2.2, lines 400ff: + // - a HEMS provides contractual consumption nominal max + // - any other devices provides power consupmtion nominal max + characteristic := model.ElectricalConnectionCharacteristicTypeTypePowerConsumptionNominalMax + + if entity == nil || entity.Device() == nil { + return characteristic + } + + deviceType := entity.Device().DeviceType() + if deviceType == nil || *deviceType == model.DeviceTypeTypeEnergyManagementSystem { + characteristic = model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax + } + + return characteristic +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/types.go new file mode 100644 index 0000000..a350538 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/types.go @@ -0,0 +1,33 @@ +package lpc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "eg-lpc-UseCaseSupportUpdate" + + // Load control obligation limit data updated + // + // Use `ConsumptionLimit` to get the current data + // + // Use Case LPC, Scenario 1 + DataUpdateLimit api.EventType = "eg-lpc-DataUpdateLimit" + + // Failsafe limit for the consumed active (real) power of the + // Controllable System data updated + // + // Use `FailsafeConsumptionActivePowerLimit` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeConsumptionActivePowerLimit api.EventType = "eg-lpc-DataUpdateFailsafeConsumptionActivePowerLimit" + + // Minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" data updated + // + // Use `FailsafeDurationMinimum` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeDurationMinimum api.EventType = "eg-lpc-DataUpdateFailsafeDurationMinimum" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/usecase.go new file mode 100644 index 0000000..b272762 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpc/usecase.go @@ -0,0 +1,89 @@ +package lpc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + usecase "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type LPC struct { + *usecase.UseCaseBase +} + +var _ ucapi.EgLPCInterface = (*LPC)(nil) + +func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *LPC { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeControllableSystem} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeCEM, + model.EntityTypeTypeCompressor, + model.EntityTypeTypeEVSE, + model.EntityTypeTypeHeatPumpAppliance, + model.EntityTypeTypeInverter, + model.EntityTypeTypeSmartEnergyAppliance, + model.EntityTypeTypeSubMeterElectricity, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeLoadControl}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeElectricalConnection}, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeEnergyGuard, + model.UseCaseNameTypeLimitationOfPowerConsumption, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes, + ) + + uc := &LPC{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *LPC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceDiagnosis, + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeElectricalConnection, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/events.go new file mode 100644 index 0000000..38798f0 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/events.go @@ -0,0 +1,162 @@ +package lpp + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *LPP) HandleEvent(payload spineapi.EventPayload) { + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.connected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.LoadControlLimitDescriptionListDataType: + e.loadControlLimitDescriptionDataUpdate(payload.Entity) + + case *model.LoadControlLimitListDataType: + e.loadControlLimitDataUpdate(payload) + + case *model.DeviceConfigurationKeyValueDescriptionListDataType: + e.configurationDescriptionDataUpdate(payload.Entity) + + case *model.DeviceConfigurationKeyValueListDataType: + e.configurationDataUpdate(payload) + } +} + +// the remote entity was connected +func (e *LPP) connected(entity spineapi.EntityRemoteInterface) { + // initialise features, e.g. subscriptions, descriptions + if loadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + if !loadControl.HasSubscription() { + if _, err := loadControl.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !loadControl.HasBinding() { + if _, err := loadControl.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get descriptions + selector := &model.LoadControlLimitDescriptionListDataSelectorsType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if _, err := loadControl.RequestLimitDescriptions(selector, nil); err != nil { + logging.Log().Debug(err) + } + } + + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + if !deviceConfiguration.HasSubscription() { + if _, err := deviceConfiguration.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if !deviceConfiguration.HasBinding() { + if _, err := deviceConfiguration.Bind(); err != nil { + logging.Log().Debug(err) + } + } + + // get descriptions + // don't use selectors yet, as we would have to query 2 which could result in 2 full reads + if _, err := deviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Debug(err) + } + } + + if deviceDiagnosis, err := client.NewDeviceDiagnosis(e.LocalEntity, entity); err == nil { + if !deviceDiagnosis.HasSubscription() { + if _, err := deviceDiagnosis.Subscribe(); err != nil { + logging.Log().Debug(err) + } + } + + if _, err := deviceDiagnosis.RequestHeartbeat(); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit description data was updated +func (e *LPP) loadControlLimitDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if loadControl, err := client.NewLoadControl(e.LocalEntity, entity); err == nil { + // get values + var selector *model.LoadControlLimitListDataSelectorsType + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if descs, err := loadControl.GetLimitDescriptionsForFilter(filter); err == nil && len(descs) > 0 { + selector = &model.LoadControlLimitListDataSelectorsType{ + LimitId: descs[0].LimitId, + } + } + if _, err := loadControl.RequestLimitData(selector, nil); err != nil { + logging.Log().Debug(err) + } + } +} + +// the load control limit data was updated +func (e *LPP) loadControlLimitDataUpdate(payload spineapi.EventPayload) { + if lc, err := client.NewLoadControl(e.LocalEntity, payload.Entity); err == nil { + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + if lc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateLimit) + } + } +} + +// the configuration key description data was updated +func (e *LPP) configurationDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + // key value descriptions received, now get the data + if _, err := deviceConfiguration.RequestKeyValues(nil, nil); err != nil { + logging.Log().Error("Error getting configuration key values:", err) + } + } +} + +// the configuration key data was updated +func (e *LPP) configurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeProductionActivePowerLimit) + } + filter.KeyName = util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum) + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFailsafeDurationMinimum) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/public.go new file mode 100644 index 0000000..437ee00 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/public.go @@ -0,0 +1,281 @@ +package lpp + +import ( + "errors" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + internal "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the current loadcontrol limit data +// +// parameters: +// - entity: the entity of the e.g. EVSE +// +// return values: +// - limit: load limit data +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *LPP) ProductionLimit(entity spineapi.EntityRemoteInterface) ( + limit ucapi.LoadLimit, resultErr error) { + limit = ucapi.LoadLimit{ + Value: 0.0, + IsChangeable: false, + IsActive: false, + } + + resultErr = api.ErrNoCompatibleEntity + if !e.IsCompatibleEntityType(entity) { + return + } + + resultErr = api.ErrDataNotAvailable + loadControl, err := client.NewLoadControl(e.LocalEntity, entity) + if err != nil || loadControl == nil { + return + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + limitDescriptions, err := loadControl.GetLimitDescriptionsForFilter(filter) + if err != nil || len(limitDescriptions) != 1 { + return + } + + value, err := loadControl.GetLimitDataForId(*limitDescriptions[0].LimitId) + if err != nil || value.Value == nil { + return + } + + limit.Value = value.Value.GetValue() + limit.IsChangeable = (value.IsLimitChangeable != nil && *value.IsLimitChangeable) + limit.IsActive = (value.IsLimitActive != nil && *value.IsLimitActive) + if value.TimePeriod != nil && value.TimePeriod.EndTime != nil { + if duration, err := value.TimePeriod.GetDuration(); err == nil { + limit.Duration = duration + } + } + + resultErr = nil + + return +} + +// send new LoadControlLimits +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - limit: load limit data +// - resultCB: callback function for handling the result response +func (e *LPP) WriteProductionLimit( + entity spineapi.EntityRemoteInterface, + limit ucapi.LoadLimit, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.LoadControlLimitDescriptionDataType{ + LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), + LimitDirection: util.Ptr(model.EnergyDirectionTypeProduce), + ScopeType: util.Ptr(model.ScopeTypeTypeActivePowerLimit), + } + return internal.WriteLoadControlLimit(e.LocalEntity, entity, filter, limit, resultCB) +} + +// Scenario 2 + +// return Failsafe limit for the produced active (real) power of the +// Controllable System. This limit becomes activated in "init" state or "failsafe state". +func (e *LPP) FailsafeProductionActivePowerLimit(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return 0, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber), + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.ScaledNumber == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.ScaledNumber.GetValue(), nil +} + +// send new Failsafe Production Active Power Limit +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - value: the new limit in W +func (e *LPP) WriteFailsafeProductionActivePowerLimit(entity spineapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return nil, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + data, err := deviceConfiguration.GetKeyValueDescriptionsForFilter(filter) + if err != nil || data == nil || len(data) != 1 { + return nil, api.ErrDataNotAvailable + } + + keyData := []model.DeviceConfigurationKeyValueDataType{ + { + KeyId: data[0].KeyId, + Value: &model.DeviceConfigurationKeyValueValueType{ + ScaledNumber: model.NewScaledNumberType(value), + }, + }, + } + + msgCounter, err := deviceConfiguration.WriteKeyValues(keyData) + + return msgCounter, err +} + +// return minimum time the Controllable System remains in "failsafe state" unless conditions +// specified in this Use Case permit leaving the "failsafe state" +func (e *LPP) FailsafeDurationMinimum(entity spineapi.EntityRemoteInterface) (time.Duration, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return 0, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration), + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.Duration == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.Duration.GetTimeDuration() +} + +// send new Failsafe Duration Minimum +// +// parameters: +// - entity: the entity of the e.g. EVSE +// - duration: the duration, between 2h and 24h +func (e *LPP) WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + if duration < time.Duration(time.Hour*2) || duration > time.Duration(time.Hour*24) { + return nil, errors.New("duration outside of allowed range") + } + + keyname := model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return nil, api.ErrDataNotAvailable + } + + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil { + return nil, api.ErrDataNotAvailable + } + + keyData := []model.DeviceConfigurationKeyValueDataType{ + { + KeyId: data.KeyId, + Value: &model.DeviceConfigurationKeyValueValueType{ + Duration: model.NewDurationType(duration), + }, + }, + } + + msgCounter, err := deviceConfiguration.WriteKeyValues(keyData) + + return msgCounter, err +} + +// Scenario 4 + +// return nominal maximum active (real) power the Controllable System is +// able to produce according to the contract (EMS), device label or data sheet. +func (e *LPP) ProductionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity) + if err != nil || electricalConnection == nil { + return 0, err + } + + filter := model.ElectricalConnectionCharacteristicDataType{ + CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity), + CharacteristicType: util.Ptr(e.characteristicType(entity)), + } + data, err := electricalConnection.GetCharacteristicsForFilter(filter) + if err != nil { + return 0, err + } else if len(data) == 0 || data[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + + return data[0].Value.GetValue(), nil +} + +// returns the characteristictype depending on the remote entities device devicetype +func (e *LPP) characteristicType(entity spineapi.EntityRemoteInterface) model.ElectricalConnectionCharacteristicTypeType { + // According to LPC V1.0 2.2, lines 400ff: + // - a HEMS provides contractual consumption nominal max + // - any other devices provides power consupmtion nominal max + characteristic := model.ElectricalConnectionCharacteristicTypeTypePowerProductionNominalMax + + if entity == nil || entity.Device() == nil { + return characteristic + } + + deviceType := entity.Device().DeviceType() + if deviceType == nil || *deviceType == model.DeviceTypeTypeEnergyManagementSystem { + characteristic = model.ElectricalConnectionCharacteristicTypeTypeContractualProductionNominalMax + } + + return characteristic +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/types.go new file mode 100644 index 0000000..f9cda1c --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/types.go @@ -0,0 +1,33 @@ +package lpp + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "eg-lpp-UseCaseSupportUpdate" + + // Load control obligation limit data updated + // + // Use `ProductionLimit` to get the current data + // + // Use Case LPC, Scenario 1 + DataUpdateLimit api.EventType = "eg-lpp-DataUpdateLimit" + + // Failsafe limit for the produced active (real) power of the + // Controllable System data updated + // + // Use `FailsafeProductionActivePowerLimit` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeProductionActivePowerLimit api.EventType = "eg-lpp-DataUpdateFailsafeProductionActivePowerLimit" + + // Minimum time the Controllable System remains in "failsafe state" unless conditions + // specified in this Use Case permit leaving the "failsafe state" data updated + // + // Use `FailsafeDurationMinimum` to get the current data + // + // Use Case LPC, Scenario 2 + DataUpdateFailsafeDurationMinimum api.EventType = "eg-lpp-DataUpdateFailsafeDurationMinimum" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/usecase.go new file mode 100644 index 0000000..6d7108f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/eg/lpp/usecase.go @@ -0,0 +1,90 @@ +package lpp + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type LPP struct { + *usecase.UseCaseBase +} + +var _ ucapi.EgLPPInterface = (*LPP)(nil) + +func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *LPP { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeControllableSystem} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeCEM, + model.EntityTypeTypeEVSE, + model.EntityTypeTypeInverter, + model.EntityTypeTypeSmartEnergyAppliance, + model.EntityTypeTypeSubMeterElectricity, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeLoadControl}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceDiagnosis}, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeElectricalConnection}, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeEnergyGuard, + model.UseCaseNameTypeLimitationOfPowerProduction, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes) + + uc := &LPP{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *LPP) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceDiagnosis, + model.FeatureTypeTypeLoadControl, + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeElectricalConnection, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) +} + +func (e *LPP) UpdateUseCaseAvailability(available bool) { + e.LocalEntity.SetUseCaseAvailability(model.UseCaseActorTypeEnergyGuard, e.UseCaseName, available) +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/internal/heartbeat.go b/src/eebus-bridge/third_party/eebus-go/usecases/internal/heartbeat.go new file mode 100644 index 0000000..24301e5 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/internal/heartbeat.go @@ -0,0 +1,22 @@ +package internal + +import ( + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// IsHeartbeat checks if the given payload represents a heartbeat event. +// It returns true if the payload is a heartbeat event, and false otherwise. +func IsHeartbeat(payload spineapi.EventPayload) bool { + //revive:disable-next-line + switch payload.Data.(type) { + case *model.DeviceDiagnosisHeartbeatDataType: + return payload.Function == model.FunctionTypeDeviceDiagnosisHeartbeatData && + payload.EventType == spineapi.EventTypeDataChange && + payload.ChangeType == spineapi.ElementChangeUpdate && + payload.CmdClassifier != nil && + *payload.CmdClassifier == model.CmdClassifierTypeNotify + default: + return false + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/internal/helper.go b/src/eebus-bridge/third_party/eebus-go/usecases/internal/helper.go new file mode 100644 index 0000000..78dd4d9 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/internal/helper.go @@ -0,0 +1,44 @@ +package internal + +import ( + spineapi "github.com/enbility/spine-go/api" +) + +func IsDeviceConnected(payload spineapi.EventPayload) bool { + return payload.Device != nil && + payload.EventType == spineapi.EventTypeDeviceChange && + payload.ChangeType == spineapi.ElementChangeAdd +} + +func IsDeviceDisconnected(payload spineapi.EventPayload) bool { + return payload.Device != nil && + payload.EventType == spineapi.EventTypeDeviceChange && + payload.ChangeType == spineapi.ElementChangeRemove +} + +func IsEntityConnected(payload spineapi.EventPayload) bool { + if payload.Entity != nil && + payload.EventType == spineapi.EventTypeEntityChange && + payload.ChangeType == spineapi.ElementChangeAdd { + return true + } + + return false +} + +func IsEntityDisconnected(payload spineapi.EventPayload) bool { + if payload.Entity != nil && + payload.EventType == spineapi.EventTypeEntityChange && + payload.ChangeType == spineapi.ElementChangeRemove { + return true + } + + return false +} + +func Deref(v *string) string { + if v != nil { + return string(*v) + } + return "" +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/internal/loadcontrol.go b/src/eebus-bridge/third_party/eebus-go/usecases/internal/loadcontrol.go new file mode 100644 index 0000000..a7e4917 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/internal/loadcontrol.go @@ -0,0 +1,293 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// return the current loadcontrol limits for a categoriy +// +// possible errors: +// - ErrDataNotAvailable if no such measurement is (yet) available +// - and others +func LoadControlLimits( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface, + filter model.LoadControlLimitDescriptionDataType, +) (limits []ucapi.LoadLimitsPhase, resultErr error) { + limits = nil + resultErr = api.ErrNoCompatibleEntity + + evLoadControl, err := client.NewLoadControl(localEntity, remoteEntity) + evElectricalConnection, err2 := client.NewElectricalConnection(localEntity, remoteEntity) + if err != nil || err2 != nil { + return + } + + resultErr = api.ErrDataNotAvailable + // find out the appropriate limitId for each phase value + // limitDescription contains the measurementId for each limitId + limitDescriptions, err := evLoadControl.GetLimitDescriptionsForFilter(filter) + if err != nil || limitDescriptions == nil { + return + } + + var result []ucapi.LoadLimitsPhase + + for i := 0; i < len(ucapi.PhaseNameMapping); i++ { + phaseName := ucapi.PhaseNameMapping[i] + + // electricalParameterDescription contains the measured phase for each measurementId + filter := model.ElectricalConnectionParameterDescriptionDataType{ + AcMeasuredPhases: &phaseName, + } + elParamDesc, err := evElectricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(elParamDesc) == 0 || elParamDesc[0].MeasurementId == nil { + // there is no data for this phase, the phase may not exist + // so do not add id to the result + continue + } + + var limitDesc *model.LoadControlLimitDescriptionDataType + for _, desc := range limitDescriptions { + if desc.MeasurementId != nil && + elParamDesc[0].MeasurementId != nil && + *desc.MeasurementId == *elParamDesc[0].MeasurementId { + safeDesc := desc + limitDesc = &safeDesc + break + } + } + + if limitDesc == nil || limitDesc.LimitId == nil { + return + } + + limitIdData, err := evLoadControl.GetLimitDataForId(*limitDesc.LimitId) + if err != nil { + return + } + + var limitValue float64 + if limitIdData.Value == nil || (limitIdData.IsLimitActive != nil && !*limitIdData.IsLimitActive) { + // report maximum possible if no limit is available or the limit is not active + filter := model.ElectricalConnectionPermittedValueSetDataType{ + ParameterId: elParamDesc[0].ParameterId, + } + _, dataMax, _, err := evElectricalConnection.GetPermittedValueDataForFilter(filter) + if err != nil { + // the device provides no limits for this phase (e.g. Bender 1 Phase) + // according to OpEV Spec 1.0.1b, page 30: "At least one set of permitted values SHALL be stated." + // which is not the case for all elements for this EVSE setup + // but we have to ignore this case and continue with the next phase + + // In addition Elli Conenct/Pro (Gen1) returns no or empty PermittedValueSet data + continue + } + + limitValue = dataMax + } else { + limitValue = limitIdData.Value.GetValue() + } + + newLimit := ucapi.LoadLimitsPhase{ + Phase: phaseName, + IsChangeable: (limitIdData.IsLimitChangeable != nil && *limitIdData.IsLimitChangeable), + IsActive: (limitIdData.IsLimitActive != nil && *limitIdData.IsLimitActive), + Value: limitValue, + } + + result = append(result, newLimit) + } + + return result, nil +} + +// generic helper to be used in UCLPC & UCLPP +// send new LoadControlLimit to the remote entity +// +// parameters: +// - limits: a set of limits for a given limit category containing phase specific limit data +// - resultCB: callback function for handling the result response +func WriteLoadControlLimit( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface, + filter model.LoadControlLimitDescriptionDataType, + limit ucapi.LoadLimit, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + loadControl, err := client.NewLoadControl(localEntity, remoteEntity) + if err != nil { + return nil, api.ErrNoCompatibleEntity + } + + var limitData []model.LoadControlLimitDataType + + currentLimits, err := loadControl.GetLimitDataForFilter(filter) + if err != nil || len(currentLimits) != 1 || currentLimits[0].LimitId == nil { + return nil, api.ErrDataNotAvailable + } + + item := currentLimits[0] + + // EEBus_UC_TS_LimitationOfPowerConsumption V1.0.0 3.2.2.2.2.2 + // If set to "true", the timePeriod, value and isLimitActive Elements SHALL be writeable by a client. + if item.IsLimitChangeable != nil && !*item.IsLimitChangeable { + return nil, api.ErrNotSupported + } + + newLimit := model.LoadControlLimitDataType{ + LimitId: item.LimitId, + IsLimitActive: util.Ptr(limit.IsActive), + Value: model.NewScaledNumberType(limit.Value), + } + if limit.Duration > 0 { + newLimit.TimePeriod = &model.TimePeriodType{ + EndTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(limit.Duration), + } + } + + limitData = append(limitData, newLimit) + + // always delete the timePeriod first + deleteSelectors := &model.LoadControlLimitListDataSelectorsType{ + LimitId: currentLimits[0].LimitId, + } + deleteElements := &model.LoadControlLimitDataElementsType{ + TimePeriod: &model.TimePeriodElementsType{}, + } + + msgCounter, err := loadControl.WriteLimitData(limitData, deleteSelectors, deleteElements) + + if resultCB != nil && msgCounter != nil { + cb := func(msg spineapi.ResponseMessage) { + response, ok := msg.Data.(*model.ResultDataType) + if ok { + resultCB(*response) + } + } + if errCB := loadControl.AddResponseCallback(*msgCounter, cb); errCB != nil { + logging.Log().Debug("Failed to add response callback for msgCounter %v: %v", msgCounter, errCB) + } + } + + return msgCounter, err +} + +// generic helper to be used in UCOPEV & UCOSCEV +// send new LoadControlLimits to the remote EV +// +// parameters: +// - limits: a set of limits for a given limit category containing phase specific limit data +// - resultCB: callback function for handling the result response +// +// category obligations: +// Sets a maximum A limit for each phase that the EV may not exceed. +// Mainly used for implementing overload protection of the site or limiting the +// maximum charge power of EVs when the EV and EVSE communicate via IEC61851 +// and with ISO15118 if the EV does not support the Optimization of Self Consumption +// usecase. +// +// category recommendations: +// Sets a recommended charge power in A for each phase. This is mainly +// used if the EV and EVSE communicate via ISO15118 to support charging excess solar power. +// The EV either needs to support the Optimization of Self Consumption usecase or +// the EVSE needs to be able map the recommendations into oligation limits which then +// works for all EVs communication either via IEC61851 or ISO15118. +// +// notes: +// - For obligations to work for optimizing solar excess power, the EV needs to have an energy demand. +// - Recommendations work even if the EV does not have an active energy demand, given it communicated with the EVSE via ISO15118 and supports the usecase. +// - In ISO15118-2 the usecase is only supported via VAS extensions which are vendor specific and needs to have specific EVSE support for the specific EV brand. +// - In ISO15118-20 this is a standard feature which does not need special support on the EVSE. +// - Min power data is only provided via IEC61851 or using VAS in ISO15118-2. +func WriteLoadControlPhaseLimits( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface, + filter model.LoadControlLimitDescriptionDataType, + limits []ucapi.LoadLimitsPhase, + resultCB func(result model.ResultDataType), +) (*model.MsgCounterType, error) { + loadControl, err := client.NewLoadControl(localEntity, remoteEntity) + electricalConnection, err2 := client.NewElectricalConnection(localEntity, remoteEntity) + if err != nil || err2 != nil { + return nil, api.ErrNoCompatibleEntity + } + + var limitData []model.LoadControlLimitDataType + + for _, phaseLimit := range limits { + limitDescriptions, err := loadControl.GetLimitDescriptionsForFilter(filter) + if err != nil || limitDescriptions == nil { + continue + } + + // electricalParameterDescription contains the measured phase for each measurementId + filter2 := model.ElectricalConnectionParameterDescriptionDataType{ + AcMeasuredPhases: util.Ptr(phaseLimit.Phase), + } + elParamDesc, err := electricalConnection.GetParameterDescriptionsForFilter(filter2) + if err != nil || len(elParamDesc) == 0 || elParamDesc[0].MeasurementId == nil { + continue + } + + var limitDesc *model.LoadControlLimitDescriptionDataType + for _, desc := range limitDescriptions { + if desc.MeasurementId != nil && + elParamDesc[0].MeasurementId != nil && + *desc.MeasurementId == *elParamDesc[0].MeasurementId { + safeDesc := desc + limitDesc = &safeDesc + break + } + } + + if limitDesc == nil || limitDesc.LimitId == nil { + continue + } + + limitIdData, err := loadControl.GetLimitDataForId(*limitDesc.LimitId) + if err != nil { + continue + } + + // EEBus_UC_TS_OverloadProtectionByEvChargingCurrentCurtailment V1.01b 3.2.1.2.2.2 + // If omitted or set to "true", the timePeriod, value and isLimitActive element SHALL be writeable by a client. + if limitIdData.IsLimitChangeable != nil && !*limitIdData.IsLimitChangeable { + continue + } + + // electricalPermittedValueSet contains the allowed min, max and the default values per phase + limit := electricalConnection.AdjustValueToBeWithinPermittedValuesForParameterId( + phaseLimit.Value, *elParamDesc[0].ParameterId) + + newLimit := model.LoadControlLimitDataType{ + LimitId: limitDesc.LimitId, + IsLimitActive: util.Ptr(phaseLimit.IsActive), + Value: model.NewScaledNumberType(limit), + } + limitData = append(limitData, newLimit) + } + + msgCounter, err := loadControl.WriteLimitData(limitData, nil, nil) + + if resultCB != nil && msgCounter != nil { + cb := func(msg spineapi.ResponseMessage) { + response, ok := msg.Data.(*model.ResultDataType) + if ok { + resultCB(*response) + } + } + + if errCB := loadControl.AddResponseCallback(*msgCounter, cb); errCB != nil { + logging.Log().Debug("Failed to add response callback for msgCounter %v: %v", msgCounter, errCB) + } + } + + return msgCounter, err +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/internal/manufacturerdata.go b/src/eebus-bridge/third_party/eebus-go/usecases/internal/manufacturerdata.go new file mode 100644 index 0000000..d44f380 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/internal/manufacturerdata.go @@ -0,0 +1,41 @@ +package internal + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" +) + +// return the current manufacturer data for a entity +// +// possible errors: +// - ErrNoCompatibleEntity if entity is not compatible +// - and others +func ManufacturerData(localEntity spineapi.EntityLocalInterface, entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error) { + deviceClassification, err := client.NewDeviceClassification(localEntity, entity) + if err != nil { + return api.ManufacturerData{}, err + } + + data, err := deviceClassification.GetManufacturerDetails() + if err != nil { + return api.ManufacturerData{}, err + } + + ret := api.ManufacturerData{ + DeviceName: Deref((*string)(data.DeviceName)), + DeviceCode: Deref((*string)(data.DeviceCode)), + SerialNumber: Deref((*string)(data.SerialNumber)), + SoftwareRevision: Deref((*string)(data.SoftwareRevision)), + HardwareRevision: Deref((*string)(data.HardwareRevision)), + VendorName: Deref((*string)(data.VendorName)), + VendorCode: Deref((*string)(data.VendorCode)), + BrandName: Deref((*string)(data.BrandName)), + PowerSource: Deref((*string)(data.PowerSource)), + ManufacturerNodeIdentification: Deref((*string)(data.ManufacturerNodeIdentification)), + ManufacturerLabel: Deref((*string)(data.ManufacturerLabel)), + ManufacturerDescription: Deref((*string)(data.ManufacturerDescription)), + } + + return ret, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/internal/measurement.go b/src/eebus-bridge/third_party/eebus-go/usecases/internal/measurement.go new file mode 100644 index 0000000..21b7348 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/internal/measurement.go @@ -0,0 +1,71 @@ +package internal + +import ( + "slices" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// return the phase specific measurement data +func MeasurementPhaseSpecificDataForFilter( + localEntity spineapi.EntityLocalInterface, + remoteEntity spineapi.EntityRemoteInterface, + measurementFilter model.MeasurementDescriptionDataType, + energyDirection model.EnergyDirectionType, + validPhaseNameTypes []model.ElectricalConnectionPhaseNameType, +) ([]float64, error) { + measurement, err := client.NewMeasurement(localEntity, remoteEntity) + electricalConnection, err1 := client.NewElectricalConnection(localEntity, remoteEntity) + if err != nil || err1 != nil { + return nil, api.ErrMetadataNotAvailable + } + + data, err := measurement.GetDataForFilter(measurementFilter) + if err != nil || len(data) == 0 { + return nil, api.ErrDataNotAvailable + } + + var result []float64 + + for _, item := range data { + if item.Value == nil || item.MeasurementId == nil { + continue + } + + if validPhaseNameTypes != nil { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + param, err := electricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(param) == 0 || + param[0].AcMeasuredPhases == nil || + !slices.Contains(validPhaseNameTypes, *param[0].AcMeasuredPhases) { + continue + } + } + + if energyDirection != "" { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + desc, err := electricalConnection.GetDescriptionForParameterDescriptionFilter(filter) + if err != nil || desc == nil { + continue + } + + // if energy direction is not consume + if desc.PositiveEnergyDirection == nil || *desc.PositiveEnergyDirection != energyDirection { + return nil, err + } + } + + value := item.Value.GetValue() + + result = append(result, value) + } + + return result, nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/events.go new file mode 100644 index 0000000..38a2f81 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/events.go @@ -0,0 +1,168 @@ +package mgcp + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *MGCP) HandleEvent(payload spineapi.EventPayload) { + // only about events from an SGMW entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.gridConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.DeviceConfigurationKeyValueDescriptionListDataType: + e.gridConfigurationDescriptionDataUpdate(payload.Entity) + + case *model.DeviceConfigurationKeyValueListDataType: + e.gridConfigurationDataUpdate(payload) + + case *model.MeasurementDescriptionListDataType: + e.gridMeasurementDescriptionDataUpdate(payload.Entity) + + case *model.MeasurementListDataType: + e.gridMeasurementDataUpdate(payload) + } +} + +// process required steps when a grid device is connected +func (e *MGCP) gridConnected(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + if !deviceConfiguration.HasSubscription() { + if _, err := deviceConfiguration.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get configuration data + if _, err := deviceConfiguration.RequestKeyValueDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if !electricalConnection.HasSubscription() { + if _, err := electricalConnection.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get electrical connection parameter + if _, err := electricalConnection.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := electricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if !measurement.HasSubscription() { + if _, err := measurement.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get measurement parameters + if _, err := measurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := measurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Error(err) + } + } +} + +// the configuration key description data of an SMGW was updated +func (e *MGCP) gridConfigurationDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity); err == nil { + // key value descriptions received, now get the data + if _, err := deviceConfiguration.RequestKeyValues(nil, nil); err != nil { + logging.Log().Error("Error getting configuration key values:", err) + } + } +} + +// the configuration key data of an SMGW was updated +func (e *MGCP) gridConfigurationDataUpdate(payload spineapi.EventPayload) { + if dc, err := client.NewDeviceConfiguration(e.LocalEntity, payload.Entity); err == nil { + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypePvCurtailmentLimitFactor), + } + if dc.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePowerLimitationFactor) + } + } +} + +// the measurement descriptiondata of an SMGW was updated +func (e *MGCP) gridMeasurementDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + // measurement descriptions received, now get the data + if _, err := measurement.RequestData(nil, nil); err != nil { + logging.Log().Error("Error getting measurement list values:", err) + } + } +} + +// the measurement data of an SMGW was updated +func (e *MGCP) gridMeasurementDataUpdate(payload spineapi.EventPayload) { + if measurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + // Scenario 2 + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePower) + } + + // Scenario 3 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeGridFeedIn) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyFeedIn) + } + + // Scenario 4 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeGridConsumption) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyConsumed) + } + + // Scenario 5 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACCurrent) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentPerPhase) + } + + // Scenario 6 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACVoltage) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateVoltagePerPhase) + } + + // Scenario 7 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACFrequency) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFrequency) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/public.go new file mode 100644 index 0000000..f966e3f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/public.go @@ -0,0 +1,191 @@ +package mgcp + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + internal "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the current power limitation factor +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *MGCP) PowerLimitationFactor(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil || measurement == nil { + return 0, err + } + + keyname := model.DeviceConfigurationKeyNameTypePvCurtailmentLimitFactor + + deviceConfiguration, err := client.NewDeviceConfiguration(e.LocalEntity, entity) + if err != nil || deviceConfiguration == nil { + return 0, err + } + + // check if device configuration description has curtailment limit factor key name + filter := model.DeviceConfigurationKeyValueDescriptionDataType{ + KeyName: &keyname, + } + _, err = deviceConfiguration.GetKeyValueDescriptionsForFilter(filter) + if err != nil { + return 0, err + } + + filter.ValueType = util.Ptr(model.DeviceConfigurationKeyValueTypeTypeScaledNumber) + data, err := deviceConfiguration.GetKeyValueDataForFilter(filter) + if err != nil || data == nil || data.Value == nil || data.Value.ScaledNumber == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.ScaledNumber.GetValue(), nil +} + +// Scenario 2 + +// return the momentary power consumption or production at the grid connection point +// +// - positive values are used for consumption +// - negative values are used for production +func (e *MGCP) Power(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + data, err := internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, model.EnergyDirectionTypeConsume, nil) + if err != nil || len(data) != 1 { + return 0, api.ErrDataNotAvailable + } + + return data[0], nil +} + +// Scenario 3 + +// return the total feed in energy at the grid connection point +// +// - negative values are used for production +func (e *MGCP) EnergyFeedIn(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil || measurement == nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeGridFeedIn), + } + result, err := measurement.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} + +// Scenario 4 + +// return the total consumption energy at the grid connection point +// +// - positive values are used for consumption +func (e *MGCP) EnergyConsumed(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil || measurement == nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeGridConsumption), + } + result, err := measurement.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} + +// Scenario 5 + +// return the momentary current consumption or production at the grid connection point +// +// - positive values are used for consumption +// - negative values are used for production +func (e *MGCP) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + return internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) +} + +// Scenario 6 + +// return the voltage phase details at the grid connection point +func (e *MGCP) VoltagePerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + } + return internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, "", ucapi.PhaseNameMapping) +} + +// Scenario 7 + +// return frequency at the grid connection point +func (e *MGCP) Frequency(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil || measurement == nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeFrequency), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACFrequency), + } + result, err := measurement.GetDataForFilter(filter) + if err != nil || len(result) == 0 || result[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + return result[0].Value.GetValue(), nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/types.go new file mode 100644 index 0000000..6a94de9 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/types.go @@ -0,0 +1,60 @@ +package mgcp + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entites supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "ma-mgcp-UseCaseSupportUpdate" + + // Grid maximum allowed feed-in power as percentage value of the cumulated + // nominal peak power of all electricity producting PV systems was updated + // + // Use `PowerLimitationFactor` to get the current data + // + // Use Case MGCP, Scenario 2 + DataUpdatePowerLimitationFactor api.EventType = "ma-mgcp-DataUpdatePowerLimitationFactor" + + // Grid momentary power consumption/production data updated + // + // Use `Power` to get the current data + // + // Use Case MGCP, Scenario 2 + DataUpdatePower api.EventType = "ma-mgcp-DataUpdatePower" + + // Total grid feed in energy data updated + // + // Use `EnergyFeedIn` to get the current data + // + // Use Case MGCP, Scenario 3 + DataUpdateEnergyFeedIn api.EventType = "ma-mgcp-DataUpdateEnergyFeedIn" + + // Total grid consumed energy data updated + // + // Use `EnergyConsumed` to get the current data + // + // Use Case MGCP, Scenario 4 + DataUpdateEnergyConsumed api.EventType = "ma-mgcp-DataUpdateEnergyConsumed" + + // Phase specific momentary current consumption/production phase detail data updated + // + // Use `CurrentPerPhase` to get the current data + // + // Use Case MGCP, Scenario 5 + DataUpdateCurrentPerPhase api.EventType = "ma-mgcp-DataUpdateCurrentPerPhase" + + // Phase specific voltage at the grid connection point + // + // Use `VoltagePerPhase` to get the current data + // + // Use Case MGCP, Scenario 6 + DataUpdateVoltagePerPhase api.EventType = "ma-mgcp-DataUpdateVoltagePerPhase" + + // Grid frequency data updated + // + // Use `Frequency` to get the current data + // + // Use Case MGCP, Scenario 7 + DataUpdateFrequency api.EventType = "ma-mgcp-DataUpdateFrequency" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/usecase.go new file mode 100644 index 0000000..8fcfa78 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mgcp/usecase.go @@ -0,0 +1,111 @@ +package mgcp + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + usecase "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type MGCP struct { + *usecase.UseCaseBase +} + +var _ ucapi.MaMGCPInterface = (*MGCP)(nil) + +func NewMGCP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *MGCP { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeGridConnectionPoint} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeCEM, + model.EntityTypeTypeGridConnectionPointOfPremises, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{model.FeatureTypeTypeDeviceConfiguration}, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(5), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(6), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(7), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeMeasurement, + model.FeatureTypeTypeElectricalConnection, + }, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeMonitoringAppliance, + model.UseCaseNameTypeMonitoringOfGridConnectionPoint, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes) + + uc := &MGCP{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *MGCP) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeDeviceConfiguration, + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/events.go new file mode 100644 index 0000000..ae13b5b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/events.go @@ -0,0 +1,131 @@ +package mpc + +import ( + "github.com/enbility/eebus-go/features/client" + internal "github.com/enbility/eebus-go/usecases/internal" + "github.com/enbility/ship-go/logging" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// handle SPINE events +func (e *MPC) HandleEvent(payload spineapi.EventPayload) { + // only about events from an SGMW entity or device changes for this remote device + + if !e.IsCompatibleEntityType(payload.Entity) { + return + } + + if internal.IsEntityConnected(payload) { + e.deviceConnected(payload.Entity) + return + } + + if payload.EventType != spineapi.EventTypeDataChange || + payload.ChangeType != spineapi.ElementChangeUpdate { + return + } + + switch payload.Data.(type) { + case *model.MeasurementDescriptionListDataType: + e.deviceMeasurementDescriptionDataUpdate(payload.Entity) + + case *model.MeasurementListDataType: + e.deviceMeasurementDataUpdate(payload) + } +} + +// process required steps when a device is connected +func (e *MPC) deviceConnected(entity spineapi.EntityRemoteInterface) { + if electricalConnection, err := client.NewElectricalConnection(e.LocalEntity, entity); err == nil { + if !electricalConnection.HasSubscription() { + if _, err := electricalConnection.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get electrical connection parameter + if _, err := electricalConnection.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := electricalConnection.RequestParameterDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + } + + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + if !measurement.HasSubscription() { + if _, err := measurement.Subscribe(); err != nil { + logging.Log().Error(err) + } + } + + // get measurement parameters + if _, err := measurement.RequestDescriptions(nil, nil); err != nil { + logging.Log().Error(err) + } + + if _, err := measurement.RequestConstraints(nil, nil); err != nil { + logging.Log().Error(err) + } + } +} + +// the measurement descriptiondata of a device was updated +func (e *MPC) deviceMeasurementDescriptionDataUpdate(entity spineapi.EntityRemoteInterface) { + if measurement, err := client.NewMeasurement(e.LocalEntity, entity); err == nil { + // measurement descriptions received, now get the data + if _, err := measurement.RequestData(nil, nil); err != nil { + logging.Log().Error("Error getting measurement list values:", err) + } + } +} + +// the measurement data of a device was updated +func (e *MPC) deviceMeasurementDataUpdate(payload spineapi.EventPayload) { + if measurement, err := client.NewMeasurement(e.LocalEntity, payload.Entity); err == nil { + // Scenario 1 + filter := model.MeasurementDescriptionDataType{ + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePower) + } + + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACPower) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdatePowerPerPhase) + } + + // Scenario 2 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACEnergyConsumed) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyConsumed) + } + + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACEnergyProduced) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateEnergyProduced) + } + + // Scenario 3 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACCurrent) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateCurrentsPerPhase) + } + + // Scenario 4 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACVoltage) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateVoltagePerPhase) + } + + // Scenario 5 + filter.ScopeType = util.Ptr(model.ScopeTypeTypeACFrequency) + if measurement.CheckEventPayloadDataForFilter(payload.Data, filter) && e.EventCB != nil { + e.EventCB(payload.Ski, payload.Device, payload.Entity, DataUpdateFrequency) + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/public.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/public.go new file mode 100644 index 0000000..29a22c8 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/public.go @@ -0,0 +1,186 @@ +package mpc + +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/client" + ucapi "github.com/enbility/eebus-go/usecases/api" + internal "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Scenario 1 + +// return the momentary active power consumption or production +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *MPC) Power(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + values, err := internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, model.EnergyDirectionTypeConsume, nil) + if err != nil { + return 0, err + } + if len(values) != 1 { + return 0, api.ErrDataNotAvailable + } + return values[0], nil +} + +// return the momentary active phase specific power consumption or production per phase +// +// possible errors: +// - ErrDataNotAvailable if no such limit is (yet) available +// - and others +func (e *MPC) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + return internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) +} + +// Scenario 2 + +// return the total consumption energy +// +// - positive values are used for consumption +func (e *MPC) EnergyConsumed(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyConsumed), + } + values, err := measurement.GetDataForFilter(filter) + if err != nil || len(values) == 0 { + return 0, api.ErrDataNotAvailable + } + + // we assume thre is only one result + value := values[0].Value + if value == nil { + return 0, api.ErrDataNotAvailable + } + + return value.GetValue(), nil +} + +// return the total feed in energy +// +// - negative values are used for production +func (e *MPC) EnergyProduced(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyProduced), + } + values, err := measurement.GetDataForFilter(filter) + if err != nil || len(values) == 0 { + return 0, api.ErrDataNotAvailable + } + + // we assume thre is only one result + value := values[0].Value + if value == nil { + return 0, api.ErrDataNotAvailable + } + + return value.GetValue(), nil +} + +// Scenario 3 + +// return the momentary phase specific current consumption or production +// +// - positive values are used for consumption +// - negative values are used for production +func (e *MPC) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + return internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) +} + +// Scenario 4 + +// return the phase specific voltage details +func (e *MPC) VoltagePerPhase(entity spineapi.EntityRemoteInterface) ([]float64, error) { + if !e.IsCompatibleEntityType(entity) { + return nil, api.ErrNoCompatibleEntity + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + } + return internal.MeasurementPhaseSpecificDataForFilter(e.LocalEntity, entity, filter, "", ucapi.PhaseNameMapping) +} + +// Scenario 5 + +// return frequency +func (e *MPC) Frequency(entity spineapi.EntityRemoteInterface) (float64, error) { + if !e.IsCompatibleEntityType(entity) { + return 0, api.ErrNoCompatibleEntity + } + + measurement, err := client.NewMeasurement(e.LocalEntity, entity) + if err != nil { + return 0, err + } + + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeFrequency), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACFrequency), + } + data, err := measurement.GetDataForFilter(filter) + if err != nil || len(data) == 0 || data[0].Value == nil { + return 0, api.ErrDataNotAvailable + } + + // take the first item + value := data[0].Value + + return value.GetValue(), nil +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/types.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/types.go new file mode 100644 index 0000000..01892c1 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/types.go @@ -0,0 +1,59 @@ +package mpc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "ma-mpc-UseCaseSupportUpdate" + + // Total momentary active power consumption or production + // + // Use `Power` to get the current data + // + // Use Case MCP, Scenario 1 + DataUpdatePower api.EventType = "ma-mpc-DataUpdatePower" + + // Phase specific momentary active power consumption or production + // + // Use `PowerPerPhase` to get the current data + // + // Use Case MCP, Scenario 1 + DataUpdatePowerPerPhase api.EventType = "ma-mpc-DataUpdatePowerPerPhase" + + // Total energy consumed + // + // Use `EnergyConsumed` to get the current data + // + // Use Case MCP, Scenario 2 + DataUpdateEnergyConsumed api.EventType = "ma-mpc-DataUpdateEnergyConsumed" + + // Total energy produced + // + // Use `EnergyProduced` to get the current data + // + // Use Case MCP, Scenario 2 + DataUpdateEnergyProduced api.EventType = "ma-mpc-DataUpdateEnergyProduced" + + // Phase specific momentary current consumption or production + // + // Use `CurrentPerPhase` to get the current data + // + // Use Case MCP, Scenario 3 + DataUpdateCurrentsPerPhase api.EventType = "ma-mpc-DataUpdateCurrentsPerPhase" + + // Phase specific voltage + // + // Use `VoltagePerPhase` to get the current data + // + // Use Case MCP, Scenario 3 + DataUpdateVoltagePerPhase api.EventType = "ma-mpc-DataUpdateVoltagePerPhase" + + // Power network frequency data updated + // + // Use `Frequency` to get the current data + // + // Use Case MCP, Scenario 3 + DataUpdateFrequency api.EventType = "ma-mpc-DataUpdateFrequency" +) diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/usecase.go new file mode 100644 index 0000000..69a420c --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/ma/mpc/usecase.go @@ -0,0 +1,102 @@ +package mpc + +import ( + "github.com/enbility/eebus-go/api" + ucapi "github.com/enbility/eebus-go/usecases/api" + usecase "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type MPC struct { + *usecase.UseCaseBase +} + +var _ ucapi.MaMPCInterface = (*MPC)(nil) + +func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *MPC { + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeMonitoredUnit} + validEntityTypes := []model.EntityTypeType{ + model.EntityTypeTypeCompressor, + model.EntityTypeTypeElectricalImmersionHeater, + model.EntityTypeTypeEVSE, + model.EntityTypeTypeHeatPumpAppliance, + model.EntityTypeTypeInverter, + model.EntityTypeTypeSmartEnergyAppliance, + model.EntityTypeTypeSubMeterElectricity, + } + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + { + Scenario: model.UseCaseScenarioSupportType(5), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + } + + usecase := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeMonitoringAppliance, + model.UseCaseNameTypeMonitoringOfPowerConsumption, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + validEntityTypes) + + uc := &MPC{ + UseCaseBase: usecase, + } + + _ = spine.Events.Subscribe(uc) + + return uc +} + +func (e *MPC) AddFeatures() { + // client features + var clientFeatures = []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + } + for _, feature := range clientFeatures { + _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemCEVCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemCEVCInterface.go new file mode 100644 index 0000000..d0936be --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemCEVCInterface.go @@ -0,0 +1,825 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemCEVCInterface is an autogenerated mock type for the CemCEVCInterface type +type CemCEVCInterface struct { + mock.Mock +} + +type CemCEVCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemCEVCInterface) EXPECT() *CemCEVCInterface_Expecter { + return &CemCEVCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemCEVCInterface) AddFeatures() { + _m.Called() +} + +// CemCEVCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemCEVCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) AddFeatures() *CemCEVCInterface_AddFeatures_Call { + return &CemCEVCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemCEVCInterface_AddFeatures_Call) Run(run func()) *CemCEVCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_AddFeatures_Call) Return() *CemCEVCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemCEVCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemCEVCInterface) AddUseCase() { + _m.Called() +} + +// CemCEVCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemCEVCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) AddUseCase() *CemCEVCInterface_AddUseCase_Call { + return &CemCEVCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemCEVCInterface_AddUseCase_Call) Run(run func()) *CemCEVCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_AddUseCase_Call) Return() *CemCEVCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_AddUseCase_Call) RunAndReturn(run func()) *CemCEVCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemCEVCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemCEVCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemCEVCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemCEVCInterface_AvailableScenariosForEntity_Call { + return &CemCEVCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemCEVCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemCEVCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemCEVCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// ChargePlan provides a mock function with given fields: entity +func (_m *CemCEVCInterface) ChargePlan(entity spine_goapi.EntityRemoteInterface) (api.ChargePlan, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ChargePlan") + } + + var r0 api.ChargePlan + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.ChargePlan, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.ChargePlan); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.ChargePlan) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemCEVCInterface_ChargePlan_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChargePlan' +type CemCEVCInterface_ChargePlan_Call struct { + *mock.Call +} + +// ChargePlan is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) ChargePlan(entity interface{}) *CemCEVCInterface_ChargePlan_Call { + return &CemCEVCInterface_ChargePlan_Call{Call: _e.mock.On("ChargePlan", entity)} +} + +func (_c *CemCEVCInterface_ChargePlan_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_ChargePlan_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_ChargePlan_Call) Return(_a0 api.ChargePlan, _a1 error) *CemCEVCInterface_ChargePlan_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemCEVCInterface_ChargePlan_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.ChargePlan, error)) *CemCEVCInterface_ChargePlan_Call { + _c.Call.Return(run) + return _c +} + +// ChargePlanConstraints provides a mock function with given fields: entity +func (_m *CemCEVCInterface) ChargePlanConstraints(entity spine_goapi.EntityRemoteInterface) ([]api.DurationSlotValue, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ChargePlanConstraints") + } + + var r0 []api.DurationSlotValue + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]api.DurationSlotValue, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []api.DurationSlotValue); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.DurationSlotValue) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemCEVCInterface_ChargePlanConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChargePlanConstraints' +type CemCEVCInterface_ChargePlanConstraints_Call struct { + *mock.Call +} + +// ChargePlanConstraints is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) ChargePlanConstraints(entity interface{}) *CemCEVCInterface_ChargePlanConstraints_Call { + return &CemCEVCInterface_ChargePlanConstraints_Call{Call: _e.mock.On("ChargePlanConstraints", entity)} +} + +func (_c *CemCEVCInterface_ChargePlanConstraints_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_ChargePlanConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_ChargePlanConstraints_Call) Return(_a0 []api.DurationSlotValue, _a1 error) *CemCEVCInterface_ChargePlanConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemCEVCInterface_ChargePlanConstraints_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]api.DurationSlotValue, error)) *CemCEVCInterface_ChargePlanConstraints_Call { + _c.Call.Return(run) + return _c +} + +// ChargeStrategy provides a mock function with given fields: remoteEntity +func (_m *CemCEVCInterface) ChargeStrategy(remoteEntity spine_goapi.EntityRemoteInterface) api.EVChargeStrategyType { + ret := _m.Called(remoteEntity) + + if len(ret) == 0 { + panic("no return value specified for ChargeStrategy") + } + + var r0 api.EVChargeStrategyType + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.EVChargeStrategyType); ok { + r0 = rf(remoteEntity) + } else { + r0 = ret.Get(0).(api.EVChargeStrategyType) + } + + return r0 +} + +// CemCEVCInterface_ChargeStrategy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChargeStrategy' +type CemCEVCInterface_ChargeStrategy_Call struct { + *mock.Call +} + +// ChargeStrategy is a helper method to define mock.On call +// - remoteEntity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) ChargeStrategy(remoteEntity interface{}) *CemCEVCInterface_ChargeStrategy_Call { + return &CemCEVCInterface_ChargeStrategy_Call{Call: _e.mock.On("ChargeStrategy", remoteEntity)} +} + +func (_c *CemCEVCInterface_ChargeStrategy_Call) Run(run func(remoteEntity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_ChargeStrategy_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_ChargeStrategy_Call) Return(_a0 api.EVChargeStrategyType) *CemCEVCInterface_ChargeStrategy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_ChargeStrategy_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) api.EVChargeStrategyType) *CemCEVCInterface_ChargeStrategy_Call { + _c.Call.Return(run) + return _c +} + +// EnergyDemand provides a mock function with given fields: remoteEntity +func (_m *CemCEVCInterface) EnergyDemand(remoteEntity spine_goapi.EntityRemoteInterface) (api.Demand, error) { + ret := _m.Called(remoteEntity) + + if len(ret) == 0 { + panic("no return value specified for EnergyDemand") + } + + var r0 api.Demand + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.Demand, error)); ok { + return rf(remoteEntity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.Demand); ok { + r0 = rf(remoteEntity) + } else { + r0 = ret.Get(0).(api.Demand) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(remoteEntity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemCEVCInterface_EnergyDemand_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyDemand' +type CemCEVCInterface_EnergyDemand_Call struct { + *mock.Call +} + +// EnergyDemand is a helper method to define mock.On call +// - remoteEntity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) EnergyDemand(remoteEntity interface{}) *CemCEVCInterface_EnergyDemand_Call { + return &CemCEVCInterface_EnergyDemand_Call{Call: _e.mock.On("EnergyDemand", remoteEntity)} +} + +func (_c *CemCEVCInterface_EnergyDemand_Call) Run(run func(remoteEntity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_EnergyDemand_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_EnergyDemand_Call) Return(_a0 api.Demand, _a1 error) *CemCEVCInterface_EnergyDemand_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemCEVCInterface_EnergyDemand_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.Demand, error)) *CemCEVCInterface_EnergyDemand_Call { + _c.Call.Return(run) + return _c +} + +// IncentiveConstraints provides a mock function with given fields: entity +func (_m *CemCEVCInterface) IncentiveConstraints(entity spine_goapi.EntityRemoteInterface) (api.IncentiveSlotConstraints, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IncentiveConstraints") + } + + var r0 api.IncentiveSlotConstraints + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.IncentiveSlotConstraints, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.IncentiveSlotConstraints); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.IncentiveSlotConstraints) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemCEVCInterface_IncentiveConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncentiveConstraints' +type CemCEVCInterface_IncentiveConstraints_Call struct { + *mock.Call +} + +// IncentiveConstraints is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) IncentiveConstraints(entity interface{}) *CemCEVCInterface_IncentiveConstraints_Call { + return &CemCEVCInterface_IncentiveConstraints_Call{Call: _e.mock.On("IncentiveConstraints", entity)} +} + +func (_c *CemCEVCInterface_IncentiveConstraints_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_IncentiveConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_IncentiveConstraints_Call) Return(_a0 api.IncentiveSlotConstraints, _a1 error) *CemCEVCInterface_IncentiveConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemCEVCInterface_IncentiveConstraints_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.IncentiveSlotConstraints, error)) *CemCEVCInterface_IncentiveConstraints_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemCEVCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemCEVCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemCEVCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemCEVCInterface_IsCompatibleEntityType_Call { + return &CemCEVCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemCEVCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemCEVCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemCEVCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemCEVCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemCEVCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemCEVCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemCEVCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemCEVCInterface_IsScenarioAvailableAtEntity_Call { + return &CemCEVCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemCEVCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemCEVCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemCEVCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemCEVCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemCEVCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemCEVCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemCEVCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemCEVCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) RemoteEntitiesScenarios() *CemCEVCInterface_RemoteEntitiesScenarios_Call { + return &CemCEVCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemCEVCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemCEVCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemCEVCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemCEVCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemCEVCInterface) RemoveUseCase() { + _m.Called() +} + +// CemCEVCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemCEVCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) RemoveUseCase() *CemCEVCInterface_RemoveUseCase_Call { + return &CemCEVCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemCEVCInterface_RemoveUseCase_Call) Run(run func()) *CemCEVCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_RemoveUseCase_Call) Return() *CemCEVCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemCEVCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// TimeSlotConstraints provides a mock function with given fields: entity +func (_m *CemCEVCInterface) TimeSlotConstraints(entity spine_goapi.EntityRemoteInterface) (api.TimeSlotConstraints, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for TimeSlotConstraints") + } + + var r0 api.TimeSlotConstraints + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.TimeSlotConstraints, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.TimeSlotConstraints); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.TimeSlotConstraints) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemCEVCInterface_TimeSlotConstraints_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TimeSlotConstraints' +type CemCEVCInterface_TimeSlotConstraints_Call struct { + *mock.Call +} + +// TimeSlotConstraints is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemCEVCInterface_Expecter) TimeSlotConstraints(entity interface{}) *CemCEVCInterface_TimeSlotConstraints_Call { + return &CemCEVCInterface_TimeSlotConstraints_Call{Call: _e.mock.On("TimeSlotConstraints", entity)} +} + +func (_c *CemCEVCInterface_TimeSlotConstraints_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemCEVCInterface_TimeSlotConstraints_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemCEVCInterface_TimeSlotConstraints_Call) Return(_a0 api.TimeSlotConstraints, _a1 error) *CemCEVCInterface_TimeSlotConstraints_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemCEVCInterface_TimeSlotConstraints_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.TimeSlotConstraints, error)) *CemCEVCInterface_TimeSlotConstraints_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemCEVCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemCEVCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemCEVCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemCEVCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemCEVCInterface_UpdateUseCaseAvailability_Call { + return &CemCEVCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemCEVCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemCEVCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemCEVCInterface_UpdateUseCaseAvailability_Call) Return() *CemCEVCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemCEVCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// WriteIncentiveTableDescriptions provides a mock function with given fields: entity, data +func (_m *CemCEVCInterface) WriteIncentiveTableDescriptions(entity spine_goapi.EntityRemoteInterface, data []api.IncentiveTariffDescription) error { + ret := _m.Called(entity, data) + + if len(ret) == 0 { + panic("no return value specified for WriteIncentiveTableDescriptions") + } + + var r0 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.IncentiveTariffDescription) error); ok { + r0 = rf(entity, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemCEVCInterface_WriteIncentiveTableDescriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteIncentiveTableDescriptions' +type CemCEVCInterface_WriteIncentiveTableDescriptions_Call struct { + *mock.Call +} + +// WriteIncentiveTableDescriptions is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - data []api.IncentiveTariffDescription +func (_e *CemCEVCInterface_Expecter) WriteIncentiveTableDescriptions(entity interface{}, data interface{}) *CemCEVCInterface_WriteIncentiveTableDescriptions_Call { + return &CemCEVCInterface_WriteIncentiveTableDescriptions_Call{Call: _e.mock.On("WriteIncentiveTableDescriptions", entity, data)} +} + +func (_c *CemCEVCInterface_WriteIncentiveTableDescriptions_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, data []api.IncentiveTariffDescription)) *CemCEVCInterface_WriteIncentiveTableDescriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].([]api.IncentiveTariffDescription)) + }) + return _c +} + +func (_c *CemCEVCInterface_WriteIncentiveTableDescriptions_Call) Return(_a0 error) *CemCEVCInterface_WriteIncentiveTableDescriptions_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_WriteIncentiveTableDescriptions_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, []api.IncentiveTariffDescription) error) *CemCEVCInterface_WriteIncentiveTableDescriptions_Call { + _c.Call.Return(run) + return _c +} + +// WriteIncentives provides a mock function with given fields: entity, data +func (_m *CemCEVCInterface) WriteIncentives(entity spine_goapi.EntityRemoteInterface, data []api.DurationSlotValue) error { + ret := _m.Called(entity, data) + + if len(ret) == 0 { + panic("no return value specified for WriteIncentives") + } + + var r0 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.DurationSlotValue) error); ok { + r0 = rf(entity, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemCEVCInterface_WriteIncentives_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteIncentives' +type CemCEVCInterface_WriteIncentives_Call struct { + *mock.Call +} + +// WriteIncentives is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - data []api.DurationSlotValue +func (_e *CemCEVCInterface_Expecter) WriteIncentives(entity interface{}, data interface{}) *CemCEVCInterface_WriteIncentives_Call { + return &CemCEVCInterface_WriteIncentives_Call{Call: _e.mock.On("WriteIncentives", entity, data)} +} + +func (_c *CemCEVCInterface_WriteIncentives_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, data []api.DurationSlotValue)) *CemCEVCInterface_WriteIncentives_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].([]api.DurationSlotValue)) + }) + return _c +} + +func (_c *CemCEVCInterface_WriteIncentives_Call) Return(_a0 error) *CemCEVCInterface_WriteIncentives_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_WriteIncentives_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, []api.DurationSlotValue) error) *CemCEVCInterface_WriteIncentives_Call { + _c.Call.Return(run) + return _c +} + +// WritePowerLimits provides a mock function with given fields: entity, data +func (_m *CemCEVCInterface) WritePowerLimits(entity spine_goapi.EntityRemoteInterface, data []api.DurationSlotValue) error { + ret := _m.Called(entity, data) + + if len(ret) == 0 { + panic("no return value specified for WritePowerLimits") + } + + var r0 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.DurationSlotValue) error); ok { + r0 = rf(entity, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemCEVCInterface_WritePowerLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WritePowerLimits' +type CemCEVCInterface_WritePowerLimits_Call struct { + *mock.Call +} + +// WritePowerLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - data []api.DurationSlotValue +func (_e *CemCEVCInterface_Expecter) WritePowerLimits(entity interface{}, data interface{}) *CemCEVCInterface_WritePowerLimits_Call { + return &CemCEVCInterface_WritePowerLimits_Call{Call: _e.mock.On("WritePowerLimits", entity, data)} +} + +func (_c *CemCEVCInterface_WritePowerLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, data []api.DurationSlotValue)) *CemCEVCInterface_WritePowerLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].([]api.DurationSlotValue)) + }) + return _c +} + +func (_c *CemCEVCInterface_WritePowerLimits_Call) Return(_a0 error) *CemCEVCInterface_WritePowerLimits_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_WritePowerLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, []api.DurationSlotValue) error) *CemCEVCInterface_WritePowerLimits_Call { + _c.Call.Return(run) + return _c +} + +// NewCemCEVCInterface creates a new instance of CemCEVCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemCEVCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemCEVCInterface { + mock := &CemCEVCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCCInterface.go new file mode 100644 index 0000000..3bf596f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCCInterface.go @@ -0,0 +1,812 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemEVCCInterface is an autogenerated mock type for the CemEVCCInterface type +type CemEVCCInterface struct { + mock.Mock +} + +type CemEVCCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemEVCCInterface) EXPECT() *CemEVCCInterface_Expecter { + return &CemEVCCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemEVCCInterface) AddFeatures() { + _m.Called() +} + +// CemEVCCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemEVCCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemEVCCInterface_Expecter) AddFeatures() *CemEVCCInterface_AddFeatures_Call { + return &CemEVCCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemEVCCInterface_AddFeatures_Call) Run(run func()) *CemEVCCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCCInterface_AddFeatures_Call) Return() *CemEVCCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVCCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemEVCCInterface) AddUseCase() { + _m.Called() +} + +// CemEVCCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemEVCCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemEVCCInterface_Expecter) AddUseCase() *CemEVCCInterface_AddUseCase_Call { + return &CemEVCCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemEVCCInterface_AddUseCase_Call) Run(run func()) *CemEVCCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCCInterface_AddUseCase_Call) Return() *CemEVCCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCCInterface_AddUseCase_Call) RunAndReturn(run func()) *CemEVCCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AsymmetricChargingSupport provides a mock function with given fields: entity +func (_m *CemEVCCInterface) AsymmetricChargingSupport(entity spine_goapi.EntityRemoteInterface) (bool, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AsymmetricChargingSupport") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (bool, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_AsymmetricChargingSupport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AsymmetricChargingSupport' +type CemEVCCInterface_AsymmetricChargingSupport_Call struct { + *mock.Call +} + +// AsymmetricChargingSupport is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) AsymmetricChargingSupport(entity interface{}) *CemEVCCInterface_AsymmetricChargingSupport_Call { + return &CemEVCCInterface_AsymmetricChargingSupport_Call{Call: _e.mock.On("AsymmetricChargingSupport", entity)} +} + +func (_c *CemEVCCInterface_AsymmetricChargingSupport_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_AsymmetricChargingSupport_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_AsymmetricChargingSupport_Call) Return(_a0 bool, _a1 error) *CemEVCCInterface_AsymmetricChargingSupport_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_AsymmetricChargingSupport_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (bool, error)) *CemEVCCInterface_AsymmetricChargingSupport_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemEVCCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemEVCCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemEVCCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemEVCCInterface_AvailableScenariosForEntity_Call { + return &CemEVCCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemEVCCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemEVCCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemEVCCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// ChargeState provides a mock function with given fields: entity +func (_m *CemEVCCInterface) ChargeState(entity spine_goapi.EntityRemoteInterface) (api.EVChargeStateType, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ChargeState") + } + + var r0 api.EVChargeStateType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.EVChargeStateType, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.EVChargeStateType); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.EVChargeStateType) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_ChargeState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChargeState' +type CemEVCCInterface_ChargeState_Call struct { + *mock.Call +} + +// ChargeState is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) ChargeState(entity interface{}) *CemEVCCInterface_ChargeState_Call { + return &CemEVCCInterface_ChargeState_Call{Call: _e.mock.On("ChargeState", entity)} +} + +func (_c *CemEVCCInterface_ChargeState_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_ChargeState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_ChargeState_Call) Return(_a0 api.EVChargeStateType, _a1 error) *CemEVCCInterface_ChargeState_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_ChargeState_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.EVChargeStateType, error)) *CemEVCCInterface_ChargeState_Call { + _c.Call.Return(run) + return _c +} + +// ChargingPowerLimits provides a mock function with given fields: entity +func (_m *CemEVCCInterface) ChargingPowerLimits(entity spine_goapi.EntityRemoteInterface) (float64, float64, float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ChargingPowerLimits") + } + + var r0 float64 + var r1 float64 + var r2 float64 + var r3 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, float64, float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r1 = rf(entity) + } else { + r1 = ret.Get(1).(float64) + } + + if rf, ok := ret.Get(2).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r2 = rf(entity) + } else { + r2 = ret.Get(2).(float64) + } + + if rf, ok := ret.Get(3).(func(spine_goapi.EntityRemoteInterface) error); ok { + r3 = rf(entity) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// CemEVCCInterface_ChargingPowerLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChargingPowerLimits' +type CemEVCCInterface_ChargingPowerLimits_Call struct { + *mock.Call +} + +// ChargingPowerLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) ChargingPowerLimits(entity interface{}) *CemEVCCInterface_ChargingPowerLimits_Call { + return &CemEVCCInterface_ChargingPowerLimits_Call{Call: _e.mock.On("ChargingPowerLimits", entity)} +} + +func (_c *CemEVCCInterface_ChargingPowerLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_ChargingPowerLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_ChargingPowerLimits_Call) Return(_a0 float64, _a1 float64, _a2 float64, _a3 error) *CemEVCCInterface_ChargingPowerLimits_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *CemEVCCInterface_ChargingPowerLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, float64, float64, error)) *CemEVCCInterface_ChargingPowerLimits_Call { + _c.Call.Return(run) + return _c +} + +// CommunicationStandard provides a mock function with given fields: entity +func (_m *CemEVCCInterface) CommunicationStandard(entity spine_goapi.EntityRemoteInterface) (model.DeviceConfigurationKeyValueStringType, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CommunicationStandard") + } + + var r0 model.DeviceConfigurationKeyValueStringType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (model.DeviceConfigurationKeyValueStringType, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) model.DeviceConfigurationKeyValueStringType); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(model.DeviceConfigurationKeyValueStringType) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_CommunicationStandard_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CommunicationStandard' +type CemEVCCInterface_CommunicationStandard_Call struct { + *mock.Call +} + +// CommunicationStandard is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) CommunicationStandard(entity interface{}) *CemEVCCInterface_CommunicationStandard_Call { + return &CemEVCCInterface_CommunicationStandard_Call{Call: _e.mock.On("CommunicationStandard", entity)} +} + +func (_c *CemEVCCInterface_CommunicationStandard_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_CommunicationStandard_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_CommunicationStandard_Call) Return(_a0 model.DeviceConfigurationKeyValueStringType, _a1 error) *CemEVCCInterface_CommunicationStandard_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_CommunicationStandard_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (model.DeviceConfigurationKeyValueStringType, error)) *CemEVCCInterface_CommunicationStandard_Call { + _c.Call.Return(run) + return _c +} + +// EVConnected provides a mock function with given fields: entity +func (_m *CemEVCCInterface) EVConnected(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EVConnected") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVCCInterface_EVConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EVConnected' +type CemEVCCInterface_EVConnected_Call struct { + *mock.Call +} + +// EVConnected is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) EVConnected(entity interface{}) *CemEVCCInterface_EVConnected_Call { + return &CemEVCCInterface_EVConnected_Call{Call: _e.mock.On("EVConnected", entity)} +} + +func (_c *CemEVCCInterface_EVConnected_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_EVConnected_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_EVConnected_Call) Return(_a0 bool) *CemEVCCInterface_EVConnected_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCCInterface_EVConnected_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemEVCCInterface_EVConnected_Call { + _c.Call.Return(run) + return _c +} + +// Identifications provides a mock function with given fields: entity +func (_m *CemEVCCInterface) Identifications(entity spine_goapi.EntityRemoteInterface) ([]api.IdentificationItem, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Identifications") + } + + var r0 []api.IdentificationItem + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]api.IdentificationItem, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []api.IdentificationItem); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.IdentificationItem) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_Identifications_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Identifications' +type CemEVCCInterface_Identifications_Call struct { + *mock.Call +} + +// Identifications is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) Identifications(entity interface{}) *CemEVCCInterface_Identifications_Call { + return &CemEVCCInterface_Identifications_Call{Call: _e.mock.On("Identifications", entity)} +} + +func (_c *CemEVCCInterface_Identifications_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_Identifications_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_Identifications_Call) Return(_a0 []api.IdentificationItem, _a1 error) *CemEVCCInterface_Identifications_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_Identifications_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]api.IdentificationItem, error)) *CemEVCCInterface_Identifications_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemEVCCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVCCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemEVCCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemEVCCInterface_IsCompatibleEntityType_Call { + return &CemEVCCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemEVCCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemEVCCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemEVCCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsInSleepMode provides a mock function with given fields: entity +func (_m *CemEVCCInterface) IsInSleepMode(entity spine_goapi.EntityRemoteInterface) (bool, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsInSleepMode") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (bool, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_IsInSleepMode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInSleepMode' +type CemEVCCInterface_IsInSleepMode_Call struct { + *mock.Call +} + +// IsInSleepMode is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) IsInSleepMode(entity interface{}) *CemEVCCInterface_IsInSleepMode_Call { + return &CemEVCCInterface_IsInSleepMode_Call{Call: _e.mock.On("IsInSleepMode", entity)} +} + +func (_c *CemEVCCInterface_IsInSleepMode_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_IsInSleepMode_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_IsInSleepMode_Call) Return(_a0 bool, _a1 error) *CemEVCCInterface_IsInSleepMode_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_IsInSleepMode_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (bool, error)) *CemEVCCInterface_IsInSleepMode_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemEVCCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVCCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemEVCCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemEVCCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemEVCCInterface_IsScenarioAvailableAtEntity_Call { + return &CemEVCCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemEVCCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemEVCCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemEVCCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemEVCCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemEVCCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// ManufacturerData provides a mock function with given fields: entity +func (_m *CemEVCCInterface) ManufacturerData(entity spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ManufacturerData") + } + + var r0 eebus_goapi.ManufacturerData + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) eebus_goapi.ManufacturerData); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(eebus_goapi.ManufacturerData) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCCInterface_ManufacturerData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ManufacturerData' +type CemEVCCInterface_ManufacturerData_Call struct { + *mock.Call +} + +// ManufacturerData is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCCInterface_Expecter) ManufacturerData(entity interface{}) *CemEVCCInterface_ManufacturerData_Call { + return &CemEVCCInterface_ManufacturerData_Call{Call: _e.mock.On("ManufacturerData", entity)} +} + +func (_c *CemEVCCInterface_ManufacturerData_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCCInterface_ManufacturerData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCCInterface_ManufacturerData_Call) Return(_a0 eebus_goapi.ManufacturerData, _a1 error) *CemEVCCInterface_ManufacturerData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCCInterface_ManufacturerData_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error)) *CemEVCCInterface_ManufacturerData_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemEVCCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemEVCCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemEVCCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemEVCCInterface_Expecter) RemoteEntitiesScenarios() *CemEVCCInterface_RemoteEntitiesScenarios_Call { + return &CemEVCCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemEVCCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemEVCCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemEVCCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemEVCCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemEVCCInterface) RemoveUseCase() { + _m.Called() +} + +// CemEVCCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemEVCCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemEVCCInterface_Expecter) RemoveUseCase() *CemEVCCInterface_RemoveUseCase_Call { + return &CemEVCCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemEVCCInterface_RemoveUseCase_Call) Run(run func()) *CemEVCCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCCInterface_RemoveUseCase_Call) Return() *CemEVCCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemEVCCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemEVCCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemEVCCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemEVCCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemEVCCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemEVCCInterface_UpdateUseCaseAvailability_Call { + return &CemEVCCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemEVCCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemEVCCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemEVCCInterface_UpdateUseCaseAvailability_Call) Return() *CemEVCCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemEVCCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemEVCCInterface creates a new instance of CemEVCCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemEVCCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemEVCCInterface { + mock := &CemEVCCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCEMInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCEMInterface.go new file mode 100644 index 0000000..ae4fa5b --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVCEMInterface.go @@ -0,0 +1,582 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemEVCEMInterface is an autogenerated mock type for the CemEVCEMInterface type +type CemEVCEMInterface struct { + mock.Mock +} + +type CemEVCEMInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemEVCEMInterface) EXPECT() *CemEVCEMInterface_Expecter { + return &CemEVCEMInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemEVCEMInterface) AddFeatures() { + _m.Called() +} + +// CemEVCEMInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemEVCEMInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemEVCEMInterface_Expecter) AddFeatures() *CemEVCEMInterface_AddFeatures_Call { + return &CemEVCEMInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemEVCEMInterface_AddFeatures_Call) Run(run func()) *CemEVCEMInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCEMInterface_AddFeatures_Call) Return() *CemEVCEMInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCEMInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVCEMInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemEVCEMInterface) AddUseCase() { + _m.Called() +} + +// CemEVCEMInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemEVCEMInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemEVCEMInterface_Expecter) AddUseCase() *CemEVCEMInterface_AddUseCase_Call { + return &CemEVCEMInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemEVCEMInterface_AddUseCase_Call) Run(run func()) *CemEVCEMInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCEMInterface_AddUseCase_Call) Return() *CemEVCEMInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCEMInterface_AddUseCase_Call) RunAndReturn(run func()) *CemEVCEMInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemEVCEMInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemEVCEMInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemEVCEMInterface_AvailableScenariosForEntity_Call { + return &CemEVCEMInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemEVCEMInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemEVCEMInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCEMInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemEVCEMInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentPerPhase provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) CurrentPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCEMInterface_CurrentPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentPerPhase' +type CemEVCEMInterface_CurrentPerPhase_Call struct { + *mock.Call +} + +// CurrentPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) CurrentPerPhase(entity interface{}) *CemEVCEMInterface_CurrentPerPhase_Call { + return &CemEVCEMInterface_CurrentPerPhase_Call{Call: _e.mock.On("CurrentPerPhase", entity)} +} + +func (_c *CemEVCEMInterface_CurrentPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_CurrentPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_CurrentPerPhase_Call) Return(_a0 []float64, _a1 error) *CemEVCEMInterface_CurrentPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCEMInterface_CurrentPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *CemEVCEMInterface_CurrentPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// EnergyCharged provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) EnergyCharged(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyCharged") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCEMInterface_EnergyCharged_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyCharged' +type CemEVCEMInterface_EnergyCharged_Call struct { + *mock.Call +} + +// EnergyCharged is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) EnergyCharged(entity interface{}) *CemEVCEMInterface_EnergyCharged_Call { + return &CemEVCEMInterface_EnergyCharged_Call{Call: _e.mock.On("EnergyCharged", entity)} +} + +func (_c *CemEVCEMInterface_EnergyCharged_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_EnergyCharged_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_EnergyCharged_Call) Return(_a0 float64, _a1 error) *CemEVCEMInterface_EnergyCharged_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCEMInterface_EnergyCharged_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemEVCEMInterface_EnergyCharged_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVCEMInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemEVCEMInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemEVCEMInterface_IsCompatibleEntityType_Call { + return &CemEVCEMInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemEVCEMInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemEVCEMInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCEMInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemEVCEMInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemEVCEMInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVCEMInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemEVCEMInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemEVCEMInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call { + return &CemEVCEMInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemEVCEMInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// PhasesConnected provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) PhasesConnected(entity spine_goapi.EntityRemoteInterface) (uint, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PhasesConnected") + } + + var r0 uint + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (uint, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) uint); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(uint) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCEMInterface_PhasesConnected_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PhasesConnected' +type CemEVCEMInterface_PhasesConnected_Call struct { + *mock.Call +} + +// PhasesConnected is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) PhasesConnected(entity interface{}) *CemEVCEMInterface_PhasesConnected_Call { + return &CemEVCEMInterface_PhasesConnected_Call{Call: _e.mock.On("PhasesConnected", entity)} +} + +func (_c *CemEVCEMInterface_PhasesConnected_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_PhasesConnected_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_PhasesConnected_Call) Return(_a0 uint, _a1 error) *CemEVCEMInterface_PhasesConnected_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCEMInterface_PhasesConnected_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (uint, error)) *CemEVCEMInterface_PhasesConnected_Call { + _c.Call.Return(run) + return _c +} + +// PowerPerPhase provides a mock function with given fields: entity +func (_m *CemEVCEMInterface) PowerPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PowerPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVCEMInterface_PowerPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerPerPhase' +type CemEVCEMInterface_PowerPerPhase_Call struct { + *mock.Call +} + +// PowerPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVCEMInterface_Expecter) PowerPerPhase(entity interface{}) *CemEVCEMInterface_PowerPerPhase_Call { + return &CemEVCEMInterface_PowerPerPhase_Call{Call: _e.mock.On("PowerPerPhase", entity)} +} + +func (_c *CemEVCEMInterface_PowerPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVCEMInterface_PowerPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVCEMInterface_PowerPerPhase_Call) Return(_a0 []float64, _a1 error) *CemEVCEMInterface_PowerPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVCEMInterface_PowerPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *CemEVCEMInterface_PowerPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemEVCEMInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemEVCEMInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemEVCEMInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemEVCEMInterface_Expecter) RemoteEntitiesScenarios() *CemEVCEMInterface_RemoteEntitiesScenarios_Call { + return &CemEVCEMInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemEVCEMInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemEVCEMInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCEMInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemEVCEMInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVCEMInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemEVCEMInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemEVCEMInterface) RemoveUseCase() { + _m.Called() +} + +// CemEVCEMInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemEVCEMInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemEVCEMInterface_Expecter) RemoveUseCase() *CemEVCEMInterface_RemoveUseCase_Call { + return &CemEVCEMInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemEVCEMInterface_RemoveUseCase_Call) Run(run func()) *CemEVCEMInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVCEMInterface_RemoveUseCase_Call) Return() *CemEVCEMInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCEMInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemEVCEMInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemEVCEMInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemEVCEMInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemEVCEMInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemEVCEMInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemEVCEMInterface_UpdateUseCaseAvailability_Call { + return &CemEVCEMInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemEVCEMInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemEVCEMInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemEVCEMInterface_UpdateUseCaseAvailability_Call) Return() *CemEVCEMInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVCEMInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemEVCEMInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemEVCEMInterface creates a new instance of CemEVCEMInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemEVCEMInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemEVCEMInterface { + mock := &CemEVCEMInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSECCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSECCInterface.go new file mode 100644 index 0000000..5b57763 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSECCInterface.go @@ -0,0 +1,475 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemEVSECCInterface is an autogenerated mock type for the CemEVSECCInterface type +type CemEVSECCInterface struct { + mock.Mock +} + +type CemEVSECCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemEVSECCInterface) EXPECT() *CemEVSECCInterface_Expecter { + return &CemEVSECCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemEVSECCInterface) AddFeatures() { + _m.Called() +} + +// CemEVSECCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemEVSECCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemEVSECCInterface_Expecter) AddFeatures() *CemEVSECCInterface_AddFeatures_Call { + return &CemEVSECCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemEVSECCInterface_AddFeatures_Call) Run(run func()) *CemEVSECCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSECCInterface_AddFeatures_Call) Return() *CemEVSECCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSECCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVSECCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemEVSECCInterface) AddUseCase() { + _m.Called() +} + +// CemEVSECCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemEVSECCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemEVSECCInterface_Expecter) AddUseCase() *CemEVSECCInterface_AddUseCase_Call { + return &CemEVSECCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemEVSECCInterface_AddUseCase_Call) Run(run func()) *CemEVSECCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSECCInterface_AddUseCase_Call) Return() *CemEVSECCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSECCInterface_AddUseCase_Call) RunAndReturn(run func()) *CemEVSECCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemEVSECCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemEVSECCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemEVSECCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSECCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemEVSECCInterface_AvailableScenariosForEntity_Call { + return &CemEVSECCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemEVSECCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSECCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSECCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemEVSECCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSECCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemEVSECCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemEVSECCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVSECCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemEVSECCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSECCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemEVSECCInterface_IsCompatibleEntityType_Call { + return &CemEVSECCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemEVSECCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSECCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSECCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemEVSECCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSECCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemEVSECCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemEVSECCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVSECCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemEVSECCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemEVSECCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call { + return &CemEVSECCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemEVSECCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// ManufacturerData provides a mock function with given fields: entity +func (_m *CemEVSECCInterface) ManufacturerData(entity spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ManufacturerData") + } + + var r0 eebus_goapi.ManufacturerData + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) eebus_goapi.ManufacturerData); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(eebus_goapi.ManufacturerData) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVSECCInterface_ManufacturerData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ManufacturerData' +type CemEVSECCInterface_ManufacturerData_Call struct { + *mock.Call +} + +// ManufacturerData is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSECCInterface_Expecter) ManufacturerData(entity interface{}) *CemEVSECCInterface_ManufacturerData_Call { + return &CemEVSECCInterface_ManufacturerData_Call{Call: _e.mock.On("ManufacturerData", entity)} +} + +func (_c *CemEVSECCInterface_ManufacturerData_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSECCInterface_ManufacturerData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSECCInterface_ManufacturerData_Call) Return(_a0 eebus_goapi.ManufacturerData, _a1 error) *CemEVSECCInterface_ManufacturerData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVSECCInterface_ManufacturerData_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (eebus_goapi.ManufacturerData, error)) *CemEVSECCInterface_ManufacturerData_Call { + _c.Call.Return(run) + return _c +} + +// OperatingState provides a mock function with given fields: entity +func (_m *CemEVSECCInterface) OperatingState(entity spine_goapi.EntityRemoteInterface) (model.DeviceDiagnosisOperatingStateType, string, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for OperatingState") + } + + var r0 model.DeviceDiagnosisOperatingStateType + var r1 string + var r2 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (model.DeviceDiagnosisOperatingStateType, string, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) model.DeviceDiagnosisOperatingStateType); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(model.DeviceDiagnosisOperatingStateType) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) string); ok { + r1 = rf(entity) + } else { + r1 = ret.Get(1).(string) + } + + if rf, ok := ret.Get(2).(func(spine_goapi.EntityRemoteInterface) error); ok { + r2 = rf(entity) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CemEVSECCInterface_OperatingState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OperatingState' +type CemEVSECCInterface_OperatingState_Call struct { + *mock.Call +} + +// OperatingState is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSECCInterface_Expecter) OperatingState(entity interface{}) *CemEVSECCInterface_OperatingState_Call { + return &CemEVSECCInterface_OperatingState_Call{Call: _e.mock.On("OperatingState", entity)} +} + +func (_c *CemEVSECCInterface_OperatingState_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSECCInterface_OperatingState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSECCInterface_OperatingState_Call) Return(_a0 model.DeviceDiagnosisOperatingStateType, _a1 string, _a2 error) *CemEVSECCInterface_OperatingState_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *CemEVSECCInterface_OperatingState_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (model.DeviceDiagnosisOperatingStateType, string, error)) *CemEVSECCInterface_OperatingState_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemEVSECCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemEVSECCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemEVSECCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemEVSECCInterface_Expecter) RemoteEntitiesScenarios() *CemEVSECCInterface_RemoteEntitiesScenarios_Call { + return &CemEVSECCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemEVSECCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemEVSECCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSECCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemEVSECCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSECCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemEVSECCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemEVSECCInterface) RemoveUseCase() { + _m.Called() +} + +// CemEVSECCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemEVSECCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemEVSECCInterface_Expecter) RemoveUseCase() *CemEVSECCInterface_RemoveUseCase_Call { + return &CemEVSECCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemEVSECCInterface_RemoveUseCase_Call) Run(run func()) *CemEVSECCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSECCInterface_RemoveUseCase_Call) Return() *CemEVSECCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSECCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemEVSECCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemEVSECCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemEVSECCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemEVSECCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemEVSECCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemEVSECCInterface_UpdateUseCaseAvailability_Call { + return &CemEVSECCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemEVSECCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemEVSECCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemEVSECCInterface_UpdateUseCaseAvailability_Call) Return() *CemEVSECCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSECCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemEVSECCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemEVSECCInterface creates a new instance of CemEVSECCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemEVSECCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemEVSECCInterface { + mock := &CemEVSECCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSOCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSOCInterface.go new file mode 100644 index 0000000..cdbfcd6 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemEVSOCInterface.go @@ -0,0 +1,410 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemEVSOCInterface is an autogenerated mock type for the CemEVSOCInterface type +type CemEVSOCInterface struct { + mock.Mock +} + +type CemEVSOCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemEVSOCInterface) EXPECT() *CemEVSOCInterface_Expecter { + return &CemEVSOCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemEVSOCInterface) AddFeatures() { + _m.Called() +} + +// CemEVSOCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemEVSOCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemEVSOCInterface_Expecter) AddFeatures() *CemEVSOCInterface_AddFeatures_Call { + return &CemEVSOCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemEVSOCInterface_AddFeatures_Call) Run(run func()) *CemEVSOCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSOCInterface_AddFeatures_Call) Return() *CemEVSOCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSOCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVSOCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemEVSOCInterface) AddUseCase() { + _m.Called() +} + +// CemEVSOCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemEVSOCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemEVSOCInterface_Expecter) AddUseCase() *CemEVSOCInterface_AddUseCase_Call { + return &CemEVSOCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemEVSOCInterface_AddUseCase_Call) Run(run func()) *CemEVSOCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSOCInterface_AddUseCase_Call) Return() *CemEVSOCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSOCInterface_AddUseCase_Call) RunAndReturn(run func()) *CemEVSOCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemEVSOCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemEVSOCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemEVSOCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSOCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemEVSOCInterface_AvailableScenariosForEntity_Call { + return &CemEVSOCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemEVSOCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSOCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSOCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemEVSOCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSOCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemEVSOCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemEVSOCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVSOCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemEVSOCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSOCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemEVSOCInterface_IsCompatibleEntityType_Call { + return &CemEVSOCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemEVSOCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSOCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSOCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemEVSOCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSOCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemEVSOCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemEVSOCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemEVSOCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemEVSOCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemEVSOCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call { + return &CemEVSOCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemEVSOCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemEVSOCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemEVSOCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemEVSOCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemEVSOCInterface_Expecter) RemoteEntitiesScenarios() *CemEVSOCInterface_RemoteEntitiesScenarios_Call { + return &CemEVSOCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemEVSOCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemEVSOCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSOCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemEVSOCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemEVSOCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemEVSOCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemEVSOCInterface) RemoveUseCase() { + _m.Called() +} + +// CemEVSOCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemEVSOCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemEVSOCInterface_Expecter) RemoveUseCase() *CemEVSOCInterface_RemoveUseCase_Call { + return &CemEVSOCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemEVSOCInterface_RemoveUseCase_Call) Run(run func()) *CemEVSOCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemEVSOCInterface_RemoveUseCase_Call) Return() *CemEVSOCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSOCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemEVSOCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// StateOfCharge provides a mock function with given fields: entity +func (_m *CemEVSOCInterface) StateOfCharge(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for StateOfCharge") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemEVSOCInterface_StateOfCharge_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StateOfCharge' +type CemEVSOCInterface_StateOfCharge_Call struct { + *mock.Call +} + +// StateOfCharge is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemEVSOCInterface_Expecter) StateOfCharge(entity interface{}) *CemEVSOCInterface_StateOfCharge_Call { + return &CemEVSOCInterface_StateOfCharge_Call{Call: _e.mock.On("StateOfCharge", entity)} +} + +func (_c *CemEVSOCInterface_StateOfCharge_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemEVSOCInterface_StateOfCharge_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemEVSOCInterface_StateOfCharge_Call) Return(_a0 float64, _a1 error) *CemEVSOCInterface_StateOfCharge_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemEVSOCInterface_StateOfCharge_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemEVSOCInterface_StateOfCharge_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemEVSOCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemEVSOCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemEVSOCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemEVSOCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemEVSOCInterface_UpdateUseCaseAvailability_Call { + return &CemEVSOCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemEVSOCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemEVSOCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemEVSOCInterface_UpdateUseCaseAvailability_Call) Return() *CemEVSOCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemEVSOCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemEVSOCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemEVSOCInterface creates a new instance of CemEVSOCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemEVSOCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemEVSOCInterface { + mock := &CemEVSOCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOPEVInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOPEVInterface.go new file mode 100644 index 0000000..6966e14 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOPEVInterface.go @@ -0,0 +1,552 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemOPEVInterface is an autogenerated mock type for the CemOPEVInterface type +type CemOPEVInterface struct { + mock.Mock +} + +type CemOPEVInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemOPEVInterface) EXPECT() *CemOPEVInterface_Expecter { + return &CemOPEVInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemOPEVInterface) AddFeatures() { + _m.Called() +} + +// CemOPEVInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemOPEVInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) AddFeatures() *CemOPEVInterface_AddFeatures_Call { + return &CemOPEVInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemOPEVInterface_AddFeatures_Call) Run(run func()) *CemOPEVInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_AddFeatures_Call) Return() *CemOPEVInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_AddFeatures_Call) RunAndReturn(run func()) *CemOPEVInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemOPEVInterface) AddUseCase() { + _m.Called() +} + +// CemOPEVInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemOPEVInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) AddUseCase() *CemOPEVInterface_AddUseCase_Call { + return &CemOPEVInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemOPEVInterface_AddUseCase_Call) Run(run func()) *CemOPEVInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_AddUseCase_Call) Return() *CemOPEVInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_AddUseCase_Call) RunAndReturn(run func()) *CemOPEVInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemOPEVInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemOPEVInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemOPEVInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOPEVInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemOPEVInterface_AvailableScenariosForEntity_Call { + return &CemOPEVInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemOPEVInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOPEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOPEVInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemOPEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOPEVInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemOPEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentLimits provides a mock function with given fields: entity +func (_m *CemOPEVInterface) CurrentLimits(entity spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentLimits") + } + + var r0 []float64 + var r1 []float64 + var r2 []float64 + var r3 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r1 = rf(entity) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]float64) + } + } + + if rf, ok := ret.Get(2).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r2 = rf(entity) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([]float64) + } + } + + if rf, ok := ret.Get(3).(func(spine_goapi.EntityRemoteInterface) error); ok { + r3 = rf(entity) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// CemOPEVInterface_CurrentLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentLimits' +type CemOPEVInterface_CurrentLimits_Call struct { + *mock.Call +} + +// CurrentLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOPEVInterface_Expecter) CurrentLimits(entity interface{}) *CemOPEVInterface_CurrentLimits_Call { + return &CemOPEVInterface_CurrentLimits_Call{Call: _e.mock.On("CurrentLimits", entity)} +} + +func (_c *CemOPEVInterface_CurrentLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOPEVInterface_CurrentLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOPEVInterface_CurrentLimits_Call) Return(_a0 []float64, _a1 []float64, _a2 []float64, _a3 error) *CemOPEVInterface_CurrentLimits_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *CemOPEVInterface_CurrentLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error)) *CemOPEVInterface_CurrentLimits_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemOPEVInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemOPEVInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemOPEVInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOPEVInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemOPEVInterface_IsCompatibleEntityType_Call { + return &CemOPEVInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemOPEVInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOPEVInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOPEVInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemOPEVInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOPEVInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemOPEVInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemOPEVInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemOPEVInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemOPEVInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemOPEVInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemOPEVInterface_IsScenarioAvailableAtEntity_Call { + return &CemOPEVInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemOPEVInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemOPEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemOPEVInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemOPEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOPEVInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemOPEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// LoadControlLimits provides a mock function with given fields: entity +func (_m *CemOPEVInterface) LoadControlLimits(entity spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for LoadControlLimits") + } + + var r0 []api.LoadLimitsPhase + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []api.LoadLimitsPhase); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.LoadLimitsPhase) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemOPEVInterface_LoadControlLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadControlLimits' +type CemOPEVInterface_LoadControlLimits_Call struct { + *mock.Call +} + +// LoadControlLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOPEVInterface_Expecter) LoadControlLimits(entity interface{}) *CemOPEVInterface_LoadControlLimits_Call { + return &CemOPEVInterface_LoadControlLimits_Call{Call: _e.mock.On("LoadControlLimits", entity)} +} + +func (_c *CemOPEVInterface_LoadControlLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOPEVInterface_LoadControlLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOPEVInterface_LoadControlLimits_Call) Return(limits []api.LoadLimitsPhase, resultErr error) *CemOPEVInterface_LoadControlLimits_Call { + _c.Call.Return(limits, resultErr) + return _c +} + +func (_c *CemOPEVInterface_LoadControlLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error)) *CemOPEVInterface_LoadControlLimits_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemOPEVInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemOPEVInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemOPEVInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) RemoteEntitiesScenarios() *CemOPEVInterface_RemoteEntitiesScenarios_Call { + return &CemOPEVInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemOPEVInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemOPEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemOPEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOPEVInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemOPEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemOPEVInterface) RemoveUseCase() { + _m.Called() +} + +// CemOPEVInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemOPEVInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) RemoveUseCase() *CemOPEVInterface_RemoveUseCase_Call { + return &CemOPEVInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemOPEVInterface_RemoveUseCase_Call) Run(run func()) *CemOPEVInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_RemoveUseCase_Call) Return() *CemOPEVInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemOPEVInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemOPEVInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemOPEVInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemOPEVInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemOPEVInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemOPEVInterface_UpdateUseCaseAvailability_Call { + return &CemOPEVInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemOPEVInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemOPEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemOPEVInterface_UpdateUseCaseAvailability_Call) Return() *CemOPEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemOPEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// WriteLoadControlLimits provides a mock function with given fields: entity, limits, resultCB +func (_m *CemOPEVInterface) WriteLoadControlLimits(entity spine_goapi.EntityRemoteInterface, limits []api.LoadLimitsPhase, resultCB func(model.ResultDataType)) (*model.MsgCounterType, error) { + ret := _m.Called(entity, limits, resultCB) + + if len(ret) == 0 { + panic("no return value specified for WriteLoadControlLimits") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) (*model.MsgCounterType, error)); ok { + return rf(entity, limits, resultCB) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) *model.MsgCounterType); ok { + r0 = rf(entity, limits, resultCB) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) error); ok { + r1 = rf(entity, limits, resultCB) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemOPEVInterface_WriteLoadControlLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteLoadControlLimits' +type CemOPEVInterface_WriteLoadControlLimits_Call struct { + *mock.Call +} + +// WriteLoadControlLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - limits []api.LoadLimitsPhase +// - resultCB func(model.ResultDataType) +func (_e *CemOPEVInterface_Expecter) WriteLoadControlLimits(entity interface{}, limits interface{}, resultCB interface{}) *CemOPEVInterface_WriteLoadControlLimits_Call { + return &CemOPEVInterface_WriteLoadControlLimits_Call{Call: _e.mock.On("WriteLoadControlLimits", entity, limits, resultCB)} +} + +func (_c *CemOPEVInterface_WriteLoadControlLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, limits []api.LoadLimitsPhase, resultCB func(model.ResultDataType))) *CemOPEVInterface_WriteLoadControlLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].([]api.LoadLimitsPhase), args[2].(func(model.ResultDataType))) + }) + return _c +} + +func (_c *CemOPEVInterface_WriteLoadControlLimits_Call) Return(_a0 *model.MsgCounterType, _a1 error) *CemOPEVInterface_WriteLoadControlLimits_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemOPEVInterface_WriteLoadControlLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) (*model.MsgCounterType, error)) *CemOPEVInterface_WriteLoadControlLimits_Call { + _c.Call.Return(run) + return _c +} + +// NewCemOPEVInterface creates a new instance of CemOPEVInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemOPEVInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemOPEVInterface { + mock := &CemOPEVInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOSCEVInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOSCEVInterface.go new file mode 100644 index 0000000..28fdf4d --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemOSCEVInterface.go @@ -0,0 +1,552 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemOSCEVInterface is an autogenerated mock type for the CemOSCEVInterface type +type CemOSCEVInterface struct { + mock.Mock +} + +type CemOSCEVInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemOSCEVInterface) EXPECT() *CemOSCEVInterface_Expecter { + return &CemOSCEVInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemOSCEVInterface) AddFeatures() { + _m.Called() +} + +// CemOSCEVInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemOSCEVInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) AddFeatures() *CemOSCEVInterface_AddFeatures_Call { + return &CemOSCEVInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemOSCEVInterface_AddFeatures_Call) Run(run func()) *CemOSCEVInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_AddFeatures_Call) Return() *CemOSCEVInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_AddFeatures_Call) RunAndReturn(run func()) *CemOSCEVInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemOSCEVInterface) AddUseCase() { + _m.Called() +} + +// CemOSCEVInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemOSCEVInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) AddUseCase() *CemOSCEVInterface_AddUseCase_Call { + return &CemOSCEVInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemOSCEVInterface_AddUseCase_Call) Run(run func()) *CemOSCEVInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_AddUseCase_Call) Return() *CemOSCEVInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_AddUseCase_Call) RunAndReturn(run func()) *CemOSCEVInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemOSCEVInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemOSCEVInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemOSCEVInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOSCEVInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemOSCEVInterface_AvailableScenariosForEntity_Call { + return &CemOSCEVInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemOSCEVInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOSCEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOSCEVInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemOSCEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOSCEVInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemOSCEVInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentLimits provides a mock function with given fields: entity +func (_m *CemOSCEVInterface) CurrentLimits(entity spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentLimits") + } + + var r0 []float64 + var r1 []float64 + var r2 []float64 + var r3 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r1 = rf(entity) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]float64) + } + } + + if rf, ok := ret.Get(2).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r2 = rf(entity) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).([]float64) + } + } + + if rf, ok := ret.Get(3).(func(spine_goapi.EntityRemoteInterface) error); ok { + r3 = rf(entity) + } else { + r3 = ret.Error(3) + } + + return r0, r1, r2, r3 +} + +// CemOSCEVInterface_CurrentLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentLimits' +type CemOSCEVInterface_CurrentLimits_Call struct { + *mock.Call +} + +// CurrentLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOSCEVInterface_Expecter) CurrentLimits(entity interface{}) *CemOSCEVInterface_CurrentLimits_Call { + return &CemOSCEVInterface_CurrentLimits_Call{Call: _e.mock.On("CurrentLimits", entity)} +} + +func (_c *CemOSCEVInterface_CurrentLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOSCEVInterface_CurrentLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOSCEVInterface_CurrentLimits_Call) Return(_a0 []float64, _a1 []float64, _a2 []float64, _a3 error) *CemOSCEVInterface_CurrentLimits_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *CemOSCEVInterface_CurrentLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, []float64, []float64, error)) *CemOSCEVInterface_CurrentLimits_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemOSCEVInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemOSCEVInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemOSCEVInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOSCEVInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemOSCEVInterface_IsCompatibleEntityType_Call { + return &CemOSCEVInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemOSCEVInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOSCEVInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOSCEVInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemOSCEVInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOSCEVInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemOSCEVInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemOSCEVInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemOSCEVInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemOSCEVInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemOSCEVInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call { + return &CemOSCEVInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemOSCEVInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// LoadControlLimits provides a mock function with given fields: entity +func (_m *CemOSCEVInterface) LoadControlLimits(entity spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for LoadControlLimits") + } + + var r0 []api.LoadLimitsPhase + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []api.LoadLimitsPhase); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.LoadLimitsPhase) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemOSCEVInterface_LoadControlLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadControlLimits' +type CemOSCEVInterface_LoadControlLimits_Call struct { + *mock.Call +} + +// LoadControlLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemOSCEVInterface_Expecter) LoadControlLimits(entity interface{}) *CemOSCEVInterface_LoadControlLimits_Call { + return &CemOSCEVInterface_LoadControlLimits_Call{Call: _e.mock.On("LoadControlLimits", entity)} +} + +func (_c *CemOSCEVInterface_LoadControlLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemOSCEVInterface_LoadControlLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemOSCEVInterface_LoadControlLimits_Call) Return(limits []api.LoadLimitsPhase, resultErr error) *CemOSCEVInterface_LoadControlLimits_Call { + _c.Call.Return(limits, resultErr) + return _c +} + +func (_c *CemOSCEVInterface_LoadControlLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]api.LoadLimitsPhase, error)) *CemOSCEVInterface_LoadControlLimits_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemOSCEVInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemOSCEVInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemOSCEVInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) RemoteEntitiesScenarios() *CemOSCEVInterface_RemoteEntitiesScenarios_Call { + return &CemOSCEVInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemOSCEVInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemOSCEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemOSCEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOSCEVInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemOSCEVInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemOSCEVInterface) RemoveUseCase() { + _m.Called() +} + +// CemOSCEVInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemOSCEVInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) RemoveUseCase() *CemOSCEVInterface_RemoveUseCase_Call { + return &CemOSCEVInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemOSCEVInterface_RemoveUseCase_Call) Run(run func()) *CemOSCEVInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_RemoveUseCase_Call) Return() *CemOSCEVInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemOSCEVInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemOSCEVInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemOSCEVInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemOSCEVInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemOSCEVInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemOSCEVInterface_UpdateUseCaseAvailability_Call { + return &CemOSCEVInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemOSCEVInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemOSCEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemOSCEVInterface_UpdateUseCaseAvailability_Call) Return() *CemOSCEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemOSCEVInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// WriteLoadControlLimits provides a mock function with given fields: entity, limits, resultCB +func (_m *CemOSCEVInterface) WriteLoadControlLimits(entity spine_goapi.EntityRemoteInterface, limits []api.LoadLimitsPhase, resultCB func(model.ResultDataType)) (*model.MsgCounterType, error) { + ret := _m.Called(entity, limits, resultCB) + + if len(ret) == 0 { + panic("no return value specified for WriteLoadControlLimits") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) (*model.MsgCounterType, error)); ok { + return rf(entity, limits, resultCB) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) *model.MsgCounterType); ok { + r0 = rf(entity, limits, resultCB) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) error); ok { + r1 = rf(entity, limits, resultCB) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemOSCEVInterface_WriteLoadControlLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteLoadControlLimits' +type CemOSCEVInterface_WriteLoadControlLimits_Call struct { + *mock.Call +} + +// WriteLoadControlLimits is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - limits []api.LoadLimitsPhase +// - resultCB func(model.ResultDataType) +func (_e *CemOSCEVInterface_Expecter) WriteLoadControlLimits(entity interface{}, limits interface{}, resultCB interface{}) *CemOSCEVInterface_WriteLoadControlLimits_Call { + return &CemOSCEVInterface_WriteLoadControlLimits_Call{Call: _e.mock.On("WriteLoadControlLimits", entity, limits, resultCB)} +} + +func (_c *CemOSCEVInterface_WriteLoadControlLimits_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, limits []api.LoadLimitsPhase, resultCB func(model.ResultDataType))) *CemOSCEVInterface_WriteLoadControlLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].([]api.LoadLimitsPhase), args[2].(func(model.ResultDataType))) + }) + return _c +} + +func (_c *CemOSCEVInterface_WriteLoadControlLimits_Call) Return(_a0 *model.MsgCounterType, _a1 error) *CemOSCEVInterface_WriteLoadControlLimits_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemOSCEVInterface_WriteLoadControlLimits_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, []api.LoadLimitsPhase, func(model.ResultDataType)) (*model.MsgCounterType, error)) *CemOSCEVInterface_WriteLoadControlLimits_Call { + _c.Call.Return(run) + return _c +} + +// NewCemOSCEVInterface creates a new instance of CemOSCEVInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemOSCEVInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemOSCEVInterface { + mock := &CemOSCEVInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVABDInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVABDInterface.go new file mode 100644 index 0000000..f84ed25 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVABDInterface.go @@ -0,0 +1,578 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemVABDInterface is an autogenerated mock type for the CemVABDInterface type +type CemVABDInterface struct { + mock.Mock +} + +type CemVABDInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemVABDInterface) EXPECT() *CemVABDInterface_Expecter { + return &CemVABDInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemVABDInterface) AddFeatures() { + _m.Called() +} + +// CemVABDInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemVABDInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemVABDInterface_Expecter) AddFeatures() *CemVABDInterface_AddFeatures_Call { + return &CemVABDInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemVABDInterface_AddFeatures_Call) Run(run func()) *CemVABDInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVABDInterface_AddFeatures_Call) Return() *CemVABDInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVABDInterface_AddFeatures_Call) RunAndReturn(run func()) *CemVABDInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemVABDInterface) AddUseCase() { + _m.Called() +} + +// CemVABDInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemVABDInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemVABDInterface_Expecter) AddUseCase() *CemVABDInterface_AddUseCase_Call { + return &CemVABDInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemVABDInterface_AddUseCase_Call) Run(run func()) *CemVABDInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVABDInterface_AddUseCase_Call) Return() *CemVABDInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVABDInterface_AddUseCase_Call) RunAndReturn(run func()) *CemVABDInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemVABDInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemVABDInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemVABDInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemVABDInterface_AvailableScenariosForEntity_Call { + return &CemVABDInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemVABDInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemVABDInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVABDInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemVABDInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// EnergyCharged provides a mock function with given fields: entity +func (_m *CemVABDInterface) EnergyCharged(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyCharged") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVABDInterface_EnergyCharged_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyCharged' +type CemVABDInterface_EnergyCharged_Call struct { + *mock.Call +} + +// EnergyCharged is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) EnergyCharged(entity interface{}) *CemVABDInterface_EnergyCharged_Call { + return &CemVABDInterface_EnergyCharged_Call{Call: _e.mock.On("EnergyCharged", entity)} +} + +func (_c *CemVABDInterface_EnergyCharged_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_EnergyCharged_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_EnergyCharged_Call) Return(_a0 float64, _a1 error) *CemVABDInterface_EnergyCharged_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVABDInterface_EnergyCharged_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVABDInterface_EnergyCharged_Call { + _c.Call.Return(run) + return _c +} + +// EnergyDischarged provides a mock function with given fields: entity +func (_m *CemVABDInterface) EnergyDischarged(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyDischarged") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVABDInterface_EnergyDischarged_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyDischarged' +type CemVABDInterface_EnergyDischarged_Call struct { + *mock.Call +} + +// EnergyDischarged is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) EnergyDischarged(entity interface{}) *CemVABDInterface_EnergyDischarged_Call { + return &CemVABDInterface_EnergyDischarged_Call{Call: _e.mock.On("EnergyDischarged", entity)} +} + +func (_c *CemVABDInterface_EnergyDischarged_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_EnergyDischarged_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_EnergyDischarged_Call) Return(_a0 float64, _a1 error) *CemVABDInterface_EnergyDischarged_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVABDInterface_EnergyDischarged_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVABDInterface_EnergyDischarged_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemVABDInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemVABDInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemVABDInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemVABDInterface_IsCompatibleEntityType_Call { + return &CemVABDInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemVABDInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemVABDInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVABDInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemVABDInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemVABDInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemVABDInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemVABDInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemVABDInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemVABDInterface_IsScenarioAvailableAtEntity_Call { + return &CemVABDInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemVABDInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemVABDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemVABDInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemVABDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVABDInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemVABDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: entity +func (_m *CemVABDInterface) Power(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVABDInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type CemVABDInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) Power(entity interface{}) *CemVABDInterface_Power_Call { + return &CemVABDInterface_Power_Call{Call: _e.mock.On("Power", entity)} +} + +func (_c *CemVABDInterface_Power_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_Power_Call) Return(_a0 float64, _a1 error) *CemVABDInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVABDInterface_Power_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVABDInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemVABDInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemVABDInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemVABDInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemVABDInterface_Expecter) RemoteEntitiesScenarios() *CemVABDInterface_RemoteEntitiesScenarios_Call { + return &CemVABDInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemVABDInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemVABDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVABDInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemVABDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVABDInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemVABDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemVABDInterface) RemoveUseCase() { + _m.Called() +} + +// CemVABDInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemVABDInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemVABDInterface_Expecter) RemoveUseCase() *CemVABDInterface_RemoveUseCase_Call { + return &CemVABDInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemVABDInterface_RemoveUseCase_Call) Run(run func()) *CemVABDInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVABDInterface_RemoveUseCase_Call) Return() *CemVABDInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVABDInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemVABDInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// StateOfCharge provides a mock function with given fields: entity +func (_m *CemVABDInterface) StateOfCharge(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for StateOfCharge") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVABDInterface_StateOfCharge_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StateOfCharge' +type CemVABDInterface_StateOfCharge_Call struct { + *mock.Call +} + +// StateOfCharge is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVABDInterface_Expecter) StateOfCharge(entity interface{}) *CemVABDInterface_StateOfCharge_Call { + return &CemVABDInterface_StateOfCharge_Call{Call: _e.mock.On("StateOfCharge", entity)} +} + +func (_c *CemVABDInterface_StateOfCharge_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVABDInterface_StateOfCharge_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVABDInterface_StateOfCharge_Call) Return(_a0 float64, _a1 error) *CemVABDInterface_StateOfCharge_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVABDInterface_StateOfCharge_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVABDInterface_StateOfCharge_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemVABDInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemVABDInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemVABDInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemVABDInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemVABDInterface_UpdateUseCaseAvailability_Call { + return &CemVABDInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemVABDInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemVABDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemVABDInterface_UpdateUseCaseAvailability_Call) Return() *CemVABDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVABDInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemVABDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemVABDInterface creates a new instance of CemVABDInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemVABDInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemVABDInterface { + mock := &CemVABDInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVAPDInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVAPDInterface.go new file mode 100644 index 0000000..65c3af9 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CemVAPDInterface.go @@ -0,0 +1,522 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// CemVAPDInterface is an autogenerated mock type for the CemVAPDInterface type +type CemVAPDInterface struct { + mock.Mock +} + +type CemVAPDInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CemVAPDInterface) EXPECT() *CemVAPDInterface_Expecter { + return &CemVAPDInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CemVAPDInterface) AddFeatures() { + _m.Called() +} + +// CemVAPDInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CemVAPDInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CemVAPDInterface_Expecter) AddFeatures() *CemVAPDInterface_AddFeatures_Call { + return &CemVAPDInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CemVAPDInterface_AddFeatures_Call) Run(run func()) *CemVAPDInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVAPDInterface_AddFeatures_Call) Return() *CemVAPDInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVAPDInterface_AddFeatures_Call) RunAndReturn(run func()) *CemVAPDInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CemVAPDInterface) AddUseCase() { + _m.Called() +} + +// CemVAPDInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CemVAPDInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CemVAPDInterface_Expecter) AddUseCase() *CemVAPDInterface_AddUseCase_Call { + return &CemVAPDInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CemVAPDInterface_AddUseCase_Call) Run(run func()) *CemVAPDInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVAPDInterface_AddUseCase_Call) Return() *CemVAPDInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVAPDInterface_AddUseCase_Call) RunAndReturn(run func()) *CemVAPDInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CemVAPDInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CemVAPDInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CemVAPDInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVAPDInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CemVAPDInterface_AvailableScenariosForEntity_Call { + return &CemVAPDInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CemVAPDInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVAPDInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVAPDInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CemVAPDInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVAPDInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CemVAPDInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CemVAPDInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemVAPDInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CemVAPDInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVAPDInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CemVAPDInterface_IsCompatibleEntityType_Call { + return &CemVAPDInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CemVAPDInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVAPDInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVAPDInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CemVAPDInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVAPDInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CemVAPDInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CemVAPDInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CemVAPDInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CemVAPDInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CemVAPDInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CemVAPDInterface_IsScenarioAvailableAtEntity_Call { + return &CemVAPDInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CemVAPDInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CemVAPDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CemVAPDInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CemVAPDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVAPDInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CemVAPDInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// PVYieldTotal provides a mock function with given fields: entity +func (_m *CemVAPDInterface) PVYieldTotal(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PVYieldTotal") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVAPDInterface_PVYieldTotal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PVYieldTotal' +type CemVAPDInterface_PVYieldTotal_Call struct { + *mock.Call +} + +// PVYieldTotal is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVAPDInterface_Expecter) PVYieldTotal(entity interface{}) *CemVAPDInterface_PVYieldTotal_Call { + return &CemVAPDInterface_PVYieldTotal_Call{Call: _e.mock.On("PVYieldTotal", entity)} +} + +func (_c *CemVAPDInterface_PVYieldTotal_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVAPDInterface_PVYieldTotal_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVAPDInterface_PVYieldTotal_Call) Return(_a0 float64, _a1 error) *CemVAPDInterface_PVYieldTotal_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVAPDInterface_PVYieldTotal_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVAPDInterface_PVYieldTotal_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: entity +func (_m *CemVAPDInterface) Power(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVAPDInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type CemVAPDInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVAPDInterface_Expecter) Power(entity interface{}) *CemVAPDInterface_Power_Call { + return &CemVAPDInterface_Power_Call{Call: _e.mock.On("Power", entity)} +} + +func (_c *CemVAPDInterface_Power_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVAPDInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVAPDInterface_Power_Call) Return(_a0 float64, _a1 error) *CemVAPDInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVAPDInterface_Power_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVAPDInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// PowerNominalPeak provides a mock function with given fields: entity +func (_m *CemVAPDInterface) PowerNominalPeak(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PowerNominalPeak") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CemVAPDInterface_PowerNominalPeak_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerNominalPeak' +type CemVAPDInterface_PowerNominalPeak_Call struct { + *mock.Call +} + +// PowerNominalPeak is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CemVAPDInterface_Expecter) PowerNominalPeak(entity interface{}) *CemVAPDInterface_PowerNominalPeak_Call { + return &CemVAPDInterface_PowerNominalPeak_Call{Call: _e.mock.On("PowerNominalPeak", entity)} +} + +func (_c *CemVAPDInterface_PowerNominalPeak_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CemVAPDInterface_PowerNominalPeak_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CemVAPDInterface_PowerNominalPeak_Call) Return(_a0 float64, _a1 error) *CemVAPDInterface_PowerNominalPeak_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CemVAPDInterface_PowerNominalPeak_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *CemVAPDInterface_PowerNominalPeak_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CemVAPDInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CemVAPDInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CemVAPDInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CemVAPDInterface_Expecter) RemoteEntitiesScenarios() *CemVAPDInterface_RemoteEntitiesScenarios_Call { + return &CemVAPDInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CemVAPDInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CemVAPDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVAPDInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CemVAPDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemVAPDInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CemVAPDInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CemVAPDInterface) RemoveUseCase() { + _m.Called() +} + +// CemVAPDInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CemVAPDInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CemVAPDInterface_Expecter) RemoveUseCase() *CemVAPDInterface_RemoveUseCase_Call { + return &CemVAPDInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CemVAPDInterface_RemoveUseCase_Call) Run(run func()) *CemVAPDInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemVAPDInterface_RemoveUseCase_Call) Return() *CemVAPDInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVAPDInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemVAPDInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CemVAPDInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CemVAPDInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CemVAPDInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CemVAPDInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CemVAPDInterface_UpdateUseCaseAvailability_Call { + return &CemVAPDInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CemVAPDInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CemVAPDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemVAPDInterface_UpdateUseCaseAvailability_Call) Return() *CemVAPDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CemVAPDInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CemVAPDInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCemVAPDInterface creates a new instance of CemVAPDInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCemVAPDInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CemVAPDInterface { + mock := &CemVAPDInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPCInterface.go new file mode 100644 index 0000000..e5d65d3 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPCInterface.go @@ -0,0 +1,907 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" + + time "time" +) + +// CsLPCInterface is an autogenerated mock type for the CsLPCInterface type +type CsLPCInterface struct { + mock.Mock +} + +type CsLPCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CsLPCInterface) EXPECT() *CsLPCInterface_Expecter { + return &CsLPCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CsLPCInterface) AddFeatures() { + _m.Called() +} + +// CsLPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CsLPCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) AddFeatures() *CsLPCInterface_AddFeatures_Call { + return &CsLPCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CsLPCInterface_AddFeatures_Call) Run(run func()) *CsLPCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_AddFeatures_Call) Return() *CsLPCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_AddFeatures_Call) RunAndReturn(run func()) *CsLPCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CsLPCInterface) AddUseCase() { + _m.Called() +} + +// CsLPCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CsLPCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) AddUseCase() *CsLPCInterface_AddUseCase_Call { + return &CsLPCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CsLPCInterface_AddUseCase_Call) Run(run func()) *CsLPCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_AddUseCase_Call) Return() *CsLPCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_AddUseCase_Call) RunAndReturn(run func()) *CsLPCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// ApproveOrDenyConsumptionLimit provides a mock function with given fields: msgCounter, approve, reason +func (_m *CsLPCInterface) ApproveOrDenyConsumptionLimit(msgCounter model.MsgCounterType, approve bool, reason string) { + _m.Called(msgCounter, approve, reason) +} + +// CsLPCInterface_ApproveOrDenyConsumptionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApproveOrDenyConsumptionLimit' +type CsLPCInterface_ApproveOrDenyConsumptionLimit_Call struct { + *mock.Call +} + +// ApproveOrDenyConsumptionLimit is a helper method to define mock.On call +// - msgCounter model.MsgCounterType +// - approve bool +// - reason string +func (_e *CsLPCInterface_Expecter) ApproveOrDenyConsumptionLimit(msgCounter interface{}, approve interface{}, reason interface{}) *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call { + return &CsLPCInterface_ApproveOrDenyConsumptionLimit_Call{Call: _e.mock.On("ApproveOrDenyConsumptionLimit", msgCounter, approve, reason)} +} + +func (_c *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call) Run(run func(msgCounter model.MsgCounterType, approve bool, reason string)) *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(bool), args[2].(string)) + }) + return _c +} + +func (_c *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call) Return() *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call) RunAndReturn(run func(model.MsgCounterType, bool, string)) *CsLPCInterface_ApproveOrDenyConsumptionLimit_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CsLPCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CsLPCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CsLPCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CsLPCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CsLPCInterface_AvailableScenariosForEntity_Call { + return &CsLPCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CsLPCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CsLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CsLPCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CsLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CsLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// ConsumptionLimit provides a mock function with given fields: +func (_m *CsLPCInterface) ConsumptionLimit() (api.LoadLimit, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ConsumptionLimit") + } + + var r0 api.LoadLimit + var r1 error + if rf, ok := ret.Get(0).(func() (api.LoadLimit, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() api.LoadLimit); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(api.LoadLimit) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CsLPCInterface_ConsumptionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumptionLimit' +type CsLPCInterface_ConsumptionLimit_Call struct { + *mock.Call +} + +// ConsumptionLimit is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) ConsumptionLimit() *CsLPCInterface_ConsumptionLimit_Call { + return &CsLPCInterface_ConsumptionLimit_Call{Call: _e.mock.On("ConsumptionLimit")} +} + +func (_c *CsLPCInterface_ConsumptionLimit_Call) Run(run func()) *CsLPCInterface_ConsumptionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_ConsumptionLimit_Call) Return(_a0 api.LoadLimit, _a1 error) *CsLPCInterface_ConsumptionLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CsLPCInterface_ConsumptionLimit_Call) RunAndReturn(run func() (api.LoadLimit, error)) *CsLPCInterface_ConsumptionLimit_Call { + _c.Call.Return(run) + return _c +} + +// ConsumptionNominalMax provides a mock function with given fields: +func (_m *CsLPCInterface) ConsumptionNominalMax() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ConsumptionNominalMax") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CsLPCInterface_ConsumptionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumptionNominalMax' +type CsLPCInterface_ConsumptionNominalMax_Call struct { + *mock.Call +} + +// ConsumptionNominalMax is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) ConsumptionNominalMax() *CsLPCInterface_ConsumptionNominalMax_Call { + return &CsLPCInterface_ConsumptionNominalMax_Call{Call: _e.mock.On("ConsumptionNominalMax")} +} + +func (_c *CsLPCInterface_ConsumptionNominalMax_Call) Run(run func()) *CsLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_ConsumptionNominalMax_Call) Return(_a0 float64, _a1 error) *CsLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CsLPCInterface_ConsumptionNominalMax_Call) RunAndReturn(run func() (float64, error)) *CsLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeConsumptionActivePowerLimit provides a mock function with given fields: +func (_m *CsLPCInterface) FailsafeConsumptionActivePowerLimit() (float64, bool, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FailsafeConsumptionActivePowerLimit") + } + + var r0 float64 + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func() (float64, bool, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() bool); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(bool) + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeConsumptionActivePowerLimit' +type CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call struct { + *mock.Call +} + +// FailsafeConsumptionActivePowerLimit is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) FailsafeConsumptionActivePowerLimit() *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + return &CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call{Call: _e.mock.On("FailsafeConsumptionActivePowerLimit")} +} + +func (_c *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call) Run(run func()) *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call) Return(value float64, isChangeable bool, resultErr error) *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(value, isChangeable, resultErr) + return _c +} + +func (_c *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call) RunAndReturn(run func() (float64, bool, error)) *CsLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeDurationMinimum provides a mock function with given fields: +func (_m *CsLPCInterface) FailsafeDurationMinimum() (time.Duration, bool, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FailsafeDurationMinimum") + } + + var r0 time.Duration + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func() (time.Duration, bool, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() time.Duration); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func() bool); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(bool) + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CsLPCInterface_FailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeDurationMinimum' +type CsLPCInterface_FailsafeDurationMinimum_Call struct { + *mock.Call +} + +// FailsafeDurationMinimum is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) FailsafeDurationMinimum() *CsLPCInterface_FailsafeDurationMinimum_Call { + return &CsLPCInterface_FailsafeDurationMinimum_Call{Call: _e.mock.On("FailsafeDurationMinimum")} +} + +func (_c *CsLPCInterface_FailsafeDurationMinimum_Call) Run(run func()) *CsLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_FailsafeDurationMinimum_Call) Return(duration time.Duration, isChangeable bool, resultErr error) *CsLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(duration, isChangeable, resultErr) + return _c +} + +func (_c *CsLPCInterface_FailsafeDurationMinimum_Call) RunAndReturn(run func() (time.Duration, bool, error)) *CsLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CsLPCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CsLPCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CsLPCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CsLPCInterface_IsCompatibleEntityType_Call { + return &CsLPCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CsLPCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CsLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CsLPCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CsLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CsLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsHeartbeatWithinDuration provides a mock function with given fields: +func (_m *CsLPCInterface) IsHeartbeatWithinDuration() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatWithinDuration") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPCInterface_IsHeartbeatWithinDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatWithinDuration' +type CsLPCInterface_IsHeartbeatWithinDuration_Call struct { + *mock.Call +} + +// IsHeartbeatWithinDuration is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) IsHeartbeatWithinDuration() *CsLPCInterface_IsHeartbeatWithinDuration_Call { + return &CsLPCInterface_IsHeartbeatWithinDuration_Call{Call: _e.mock.On("IsHeartbeatWithinDuration")} +} + +func (_c *CsLPCInterface_IsHeartbeatWithinDuration_Call) Run(run func()) *CsLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_IsHeartbeatWithinDuration_Call) Return(_a0 bool) *CsLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_IsHeartbeatWithinDuration_Call) RunAndReturn(run func() bool) *CsLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CsLPCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CsLPCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CsLPCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CsLPCInterface_IsScenarioAvailableAtEntity_Call { + return &CsLPCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CsLPCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CsLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CsLPCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CsLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CsLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// PendingConsumptionLimits provides a mock function with given fields: +func (_m *CsLPCInterface) PendingConsumptionLimits() map[model.MsgCounterType]api.LoadLimit { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for PendingConsumptionLimits") + } + + var r0 map[model.MsgCounterType]api.LoadLimit + if rf, ok := ret.Get(0).(func() map[model.MsgCounterType]api.LoadLimit); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.MsgCounterType]api.LoadLimit) + } + } + + return r0 +} + +// CsLPCInterface_PendingConsumptionLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PendingConsumptionLimits' +type CsLPCInterface_PendingConsumptionLimits_Call struct { + *mock.Call +} + +// PendingConsumptionLimits is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) PendingConsumptionLimits() *CsLPCInterface_PendingConsumptionLimits_Call { + return &CsLPCInterface_PendingConsumptionLimits_Call{Call: _e.mock.On("PendingConsumptionLimits")} +} + +func (_c *CsLPCInterface_PendingConsumptionLimits_Call) Run(run func()) *CsLPCInterface_PendingConsumptionLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_PendingConsumptionLimits_Call) Return(_a0 map[model.MsgCounterType]api.LoadLimit) *CsLPCInterface_PendingConsumptionLimits_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_PendingConsumptionLimits_Call) RunAndReturn(run func() map[model.MsgCounterType]api.LoadLimit) *CsLPCInterface_PendingConsumptionLimits_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CsLPCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CsLPCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CsLPCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) RemoteEntitiesScenarios() *CsLPCInterface_RemoteEntitiesScenarios_Call { + return &CsLPCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CsLPCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CsLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CsLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CsLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CsLPCInterface) RemoveUseCase() { + _m.Called() +} + +// CsLPCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CsLPCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) RemoveUseCase() *CsLPCInterface_RemoveUseCase_Call { + return &CsLPCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CsLPCInterface_RemoveUseCase_Call) Run(run func()) *CsLPCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_RemoveUseCase_Call) Return() *CsLPCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CsLPCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// SetConsumptionLimit provides a mock function with given fields: limit +func (_m *CsLPCInterface) SetConsumptionLimit(limit api.LoadLimit) error { + ret := _m.Called(limit) + + if len(ret) == 0 { + panic("no return value specified for SetConsumptionLimit") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.LoadLimit) error); ok { + r0 = rf(limit) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPCInterface_SetConsumptionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetConsumptionLimit' +type CsLPCInterface_SetConsumptionLimit_Call struct { + *mock.Call +} + +// SetConsumptionLimit is a helper method to define mock.On call +// - limit api.LoadLimit +func (_e *CsLPCInterface_Expecter) SetConsumptionLimit(limit interface{}) *CsLPCInterface_SetConsumptionLimit_Call { + return &CsLPCInterface_SetConsumptionLimit_Call{Call: _e.mock.On("SetConsumptionLimit", limit)} +} + +func (_c *CsLPCInterface_SetConsumptionLimit_Call) Run(run func(limit api.LoadLimit)) *CsLPCInterface_SetConsumptionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.LoadLimit)) + }) + return _c +} + +func (_c *CsLPCInterface_SetConsumptionLimit_Call) Return(resultErr error) *CsLPCInterface_SetConsumptionLimit_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPCInterface_SetConsumptionLimit_Call) RunAndReturn(run func(api.LoadLimit) error) *CsLPCInterface_SetConsumptionLimit_Call { + _c.Call.Return(run) + return _c +} + +// SetConsumptionNominalMax provides a mock function with given fields: value +func (_m *CsLPCInterface) SetConsumptionNominalMax(value float64) error { + ret := _m.Called(value) + + if len(ret) == 0 { + panic("no return value specified for SetConsumptionNominalMax") + } + + var r0 error + if rf, ok := ret.Get(0).(func(float64) error); ok { + r0 = rf(value) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPCInterface_SetConsumptionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetConsumptionNominalMax' +type CsLPCInterface_SetConsumptionNominalMax_Call struct { + *mock.Call +} + +// SetConsumptionNominalMax is a helper method to define mock.On call +// - value float64 +func (_e *CsLPCInterface_Expecter) SetConsumptionNominalMax(value interface{}) *CsLPCInterface_SetConsumptionNominalMax_Call { + return &CsLPCInterface_SetConsumptionNominalMax_Call{Call: _e.mock.On("SetConsumptionNominalMax", value)} +} + +func (_c *CsLPCInterface_SetConsumptionNominalMax_Call) Run(run func(value float64)) *CsLPCInterface_SetConsumptionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64)) + }) + return _c +} + +func (_c *CsLPCInterface_SetConsumptionNominalMax_Call) Return(resultErr error) *CsLPCInterface_SetConsumptionNominalMax_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPCInterface_SetConsumptionNominalMax_Call) RunAndReturn(run func(float64) error) *CsLPCInterface_SetConsumptionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// SetFailsafeConsumptionActivePowerLimit provides a mock function with given fields: value, changeable +func (_m *CsLPCInterface) SetFailsafeConsumptionActivePowerLimit(value float64, changeable bool) error { + ret := _m.Called(value, changeable) + + if len(ret) == 0 { + panic("no return value specified for SetFailsafeConsumptionActivePowerLimit") + } + + var r0 error + if rf, ok := ret.Get(0).(func(float64, bool) error); ok { + r0 = rf(value, changeable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFailsafeConsumptionActivePowerLimit' +type CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call struct { + *mock.Call +} + +// SetFailsafeConsumptionActivePowerLimit is a helper method to define mock.On call +// - value float64 +// - changeable bool +func (_e *CsLPCInterface_Expecter) SetFailsafeConsumptionActivePowerLimit(value interface{}, changeable interface{}) *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call { + return &CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call{Call: _e.mock.On("SetFailsafeConsumptionActivePowerLimit", value, changeable)} +} + +func (_c *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call) Run(run func(value float64, changeable bool)) *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(bool)) + }) + return _c +} + +func (_c *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call) Return(resultErr error) *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call) RunAndReturn(run func(float64, bool) error) *CsLPCInterface_SetFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// SetFailsafeDurationMinimum provides a mock function with given fields: duration, changeable +func (_m *CsLPCInterface) SetFailsafeDurationMinimum(duration time.Duration, changeable bool) error { + ret := _m.Called(duration, changeable) + + if len(ret) == 0 { + panic("no return value specified for SetFailsafeDurationMinimum") + } + + var r0 error + if rf, ok := ret.Get(0).(func(time.Duration, bool) error); ok { + r0 = rf(duration, changeable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPCInterface_SetFailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFailsafeDurationMinimum' +type CsLPCInterface_SetFailsafeDurationMinimum_Call struct { + *mock.Call +} + +// SetFailsafeDurationMinimum is a helper method to define mock.On call +// - duration time.Duration +// - changeable bool +func (_e *CsLPCInterface_Expecter) SetFailsafeDurationMinimum(duration interface{}, changeable interface{}) *CsLPCInterface_SetFailsafeDurationMinimum_Call { + return &CsLPCInterface_SetFailsafeDurationMinimum_Call{Call: _e.mock.On("SetFailsafeDurationMinimum", duration, changeable)} +} + +func (_c *CsLPCInterface_SetFailsafeDurationMinimum_Call) Run(run func(duration time.Duration, changeable bool)) *CsLPCInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration), args[1].(bool)) + }) + return _c +} + +func (_c *CsLPCInterface_SetFailsafeDurationMinimum_Call) Return(resultErr error) *CsLPCInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPCInterface_SetFailsafeDurationMinimum_Call) RunAndReturn(run func(time.Duration, bool) error) *CsLPCInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CsLPCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CsLPCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CsLPCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CsLPCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CsLPCInterface_UpdateUseCaseAvailability_Call { + return &CsLPCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CsLPCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CsLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CsLPCInterface_UpdateUseCaseAvailability_Call) Return() *CsLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CsLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCsLPCInterface creates a new instance of CsLPCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCsLPCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CsLPCInterface { + mock := &CsLPCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPPInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPPInterface.go new file mode 100644 index 0000000..984c610 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/CsLPPInterface.go @@ -0,0 +1,907 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" + + time "time" +) + +// CsLPPInterface is an autogenerated mock type for the CsLPPInterface type +type CsLPPInterface struct { + mock.Mock +} + +type CsLPPInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *CsLPPInterface) EXPECT() *CsLPPInterface_Expecter { + return &CsLPPInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *CsLPPInterface) AddFeatures() { + _m.Called() +} + +// CsLPPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type CsLPPInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) AddFeatures() *CsLPPInterface_AddFeatures_Call { + return &CsLPPInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *CsLPPInterface_AddFeatures_Call) Run(run func()) *CsLPPInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_AddFeatures_Call) Return() *CsLPPInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_AddFeatures_Call) RunAndReturn(run func()) *CsLPPInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *CsLPPInterface) AddUseCase() { + _m.Called() +} + +// CsLPPInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type CsLPPInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) AddUseCase() *CsLPPInterface_AddUseCase_Call { + return &CsLPPInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *CsLPPInterface_AddUseCase_Call) Run(run func()) *CsLPPInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_AddUseCase_Call) Return() *CsLPPInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_AddUseCase_Call) RunAndReturn(run func()) *CsLPPInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// ApproveOrDenyProductionLimit provides a mock function with given fields: msgCounter, approve, reason +func (_m *CsLPPInterface) ApproveOrDenyProductionLimit(msgCounter model.MsgCounterType, approve bool, reason string) { + _m.Called(msgCounter, approve, reason) +} + +// CsLPPInterface_ApproveOrDenyProductionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApproveOrDenyProductionLimit' +type CsLPPInterface_ApproveOrDenyProductionLimit_Call struct { + *mock.Call +} + +// ApproveOrDenyProductionLimit is a helper method to define mock.On call +// - msgCounter model.MsgCounterType +// - approve bool +// - reason string +func (_e *CsLPPInterface_Expecter) ApproveOrDenyProductionLimit(msgCounter interface{}, approve interface{}, reason interface{}) *CsLPPInterface_ApproveOrDenyProductionLimit_Call { + return &CsLPPInterface_ApproveOrDenyProductionLimit_Call{Call: _e.mock.On("ApproveOrDenyProductionLimit", msgCounter, approve, reason)} +} + +func (_c *CsLPPInterface_ApproveOrDenyProductionLimit_Call) Run(run func(msgCounter model.MsgCounterType, approve bool, reason string)) *CsLPPInterface_ApproveOrDenyProductionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(bool), args[2].(string)) + }) + return _c +} + +func (_c *CsLPPInterface_ApproveOrDenyProductionLimit_Call) Return() *CsLPPInterface_ApproveOrDenyProductionLimit_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_ApproveOrDenyProductionLimit_Call) RunAndReturn(run func(model.MsgCounterType, bool, string)) *CsLPPInterface_ApproveOrDenyProductionLimit_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *CsLPPInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// CsLPPInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type CsLPPInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CsLPPInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *CsLPPInterface_AvailableScenariosForEntity_Call { + return &CsLPPInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *CsLPPInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CsLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CsLPPInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *CsLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *CsLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeDurationMinimum provides a mock function with given fields: +func (_m *CsLPPInterface) FailsafeDurationMinimum() (time.Duration, bool, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FailsafeDurationMinimum") + } + + var r0 time.Duration + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func() (time.Duration, bool, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() time.Duration); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func() bool); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(bool) + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CsLPPInterface_FailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeDurationMinimum' +type CsLPPInterface_FailsafeDurationMinimum_Call struct { + *mock.Call +} + +// FailsafeDurationMinimum is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) FailsafeDurationMinimum() *CsLPPInterface_FailsafeDurationMinimum_Call { + return &CsLPPInterface_FailsafeDurationMinimum_Call{Call: _e.mock.On("FailsafeDurationMinimum")} +} + +func (_c *CsLPPInterface_FailsafeDurationMinimum_Call) Run(run func()) *CsLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_FailsafeDurationMinimum_Call) Return(duration time.Duration, isChangeable bool, resultErr error) *CsLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(duration, isChangeable, resultErr) + return _c +} + +func (_c *CsLPPInterface_FailsafeDurationMinimum_Call) RunAndReturn(run func() (time.Duration, bool, error)) *CsLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeProductionActivePowerLimit provides a mock function with given fields: +func (_m *CsLPPInterface) FailsafeProductionActivePowerLimit() (float64, bool, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FailsafeProductionActivePowerLimit") + } + + var r0 float64 + var r1 bool + var r2 error + if rf, ok := ret.Get(0).(func() (float64, bool, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() bool); ok { + r1 = rf() + } else { + r1 = ret.Get(1).(bool) + } + + if rf, ok := ret.Get(2).(func() error); ok { + r2 = rf() + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// CsLPPInterface_FailsafeProductionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeProductionActivePowerLimit' +type CsLPPInterface_FailsafeProductionActivePowerLimit_Call struct { + *mock.Call +} + +// FailsafeProductionActivePowerLimit is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) FailsafeProductionActivePowerLimit() *CsLPPInterface_FailsafeProductionActivePowerLimit_Call { + return &CsLPPInterface_FailsafeProductionActivePowerLimit_Call{Call: _e.mock.On("FailsafeProductionActivePowerLimit")} +} + +func (_c *CsLPPInterface_FailsafeProductionActivePowerLimit_Call) Run(run func()) *CsLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_FailsafeProductionActivePowerLimit_Call) Return(value float64, isChangeable bool, resultErr error) *CsLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Return(value, isChangeable, resultErr) + return _c +} + +func (_c *CsLPPInterface_FailsafeProductionActivePowerLimit_Call) RunAndReturn(run func() (float64, bool, error)) *CsLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *CsLPPInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPPInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type CsLPPInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *CsLPPInterface_Expecter) IsCompatibleEntityType(entity interface{}) *CsLPPInterface_IsCompatibleEntityType_Call { + return &CsLPPInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *CsLPPInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *CsLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *CsLPPInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *CsLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *CsLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsHeartbeatWithinDuration provides a mock function with given fields: +func (_m *CsLPPInterface) IsHeartbeatWithinDuration() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatWithinDuration") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPPInterface_IsHeartbeatWithinDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatWithinDuration' +type CsLPPInterface_IsHeartbeatWithinDuration_Call struct { + *mock.Call +} + +// IsHeartbeatWithinDuration is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) IsHeartbeatWithinDuration() *CsLPPInterface_IsHeartbeatWithinDuration_Call { + return &CsLPPInterface_IsHeartbeatWithinDuration_Call{Call: _e.mock.On("IsHeartbeatWithinDuration")} +} + +func (_c *CsLPPInterface_IsHeartbeatWithinDuration_Call) Run(run func()) *CsLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_IsHeartbeatWithinDuration_Call) Return(_a0 bool) *CsLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_IsHeartbeatWithinDuration_Call) RunAndReturn(run func() bool) *CsLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *CsLPPInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// CsLPPInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type CsLPPInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *CsLPPInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *CsLPPInterface_IsScenarioAvailableAtEntity_Call { + return &CsLPPInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *CsLPPInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *CsLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *CsLPPInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *CsLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *CsLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// PendingProductionLimits provides a mock function with given fields: +func (_m *CsLPPInterface) PendingProductionLimits() map[model.MsgCounterType]api.LoadLimit { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for PendingProductionLimits") + } + + var r0 map[model.MsgCounterType]api.LoadLimit + if rf, ok := ret.Get(0).(func() map[model.MsgCounterType]api.LoadLimit); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.MsgCounterType]api.LoadLimit) + } + } + + return r0 +} + +// CsLPPInterface_PendingProductionLimits_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PendingProductionLimits' +type CsLPPInterface_PendingProductionLimits_Call struct { + *mock.Call +} + +// PendingProductionLimits is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) PendingProductionLimits() *CsLPPInterface_PendingProductionLimits_Call { + return &CsLPPInterface_PendingProductionLimits_Call{Call: _e.mock.On("PendingProductionLimits")} +} + +func (_c *CsLPPInterface_PendingProductionLimits_Call) Run(run func()) *CsLPPInterface_PendingProductionLimits_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_PendingProductionLimits_Call) Return(_a0 map[model.MsgCounterType]api.LoadLimit) *CsLPPInterface_PendingProductionLimits_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_PendingProductionLimits_Call) RunAndReturn(run func() map[model.MsgCounterType]api.LoadLimit) *CsLPPInterface_PendingProductionLimits_Call { + _c.Call.Return(run) + return _c +} + +// ProductionLimit provides a mock function with given fields: +func (_m *CsLPPInterface) ProductionLimit() (api.LoadLimit, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ProductionLimit") + } + + var r0 api.LoadLimit + var r1 error + if rf, ok := ret.Get(0).(func() (api.LoadLimit, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() api.LoadLimit); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(api.LoadLimit) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CsLPPInterface_ProductionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProductionLimit' +type CsLPPInterface_ProductionLimit_Call struct { + *mock.Call +} + +// ProductionLimit is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) ProductionLimit() *CsLPPInterface_ProductionLimit_Call { + return &CsLPPInterface_ProductionLimit_Call{Call: _e.mock.On("ProductionLimit")} +} + +func (_c *CsLPPInterface_ProductionLimit_Call) Run(run func()) *CsLPPInterface_ProductionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_ProductionLimit_Call) Return(_a0 api.LoadLimit, _a1 error) *CsLPPInterface_ProductionLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CsLPPInterface_ProductionLimit_Call) RunAndReturn(run func() (api.LoadLimit, error)) *CsLPPInterface_ProductionLimit_Call { + _c.Call.Return(run) + return _c +} + +// ProductionNominalMax provides a mock function with given fields: +func (_m *CsLPPInterface) ProductionNominalMax() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ProductionNominalMax") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CsLPPInterface_ProductionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProductionNominalMax' +type CsLPPInterface_ProductionNominalMax_Call struct { + *mock.Call +} + +// ProductionNominalMax is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) ProductionNominalMax() *CsLPPInterface_ProductionNominalMax_Call { + return &CsLPPInterface_ProductionNominalMax_Call{Call: _e.mock.On("ProductionNominalMax")} +} + +func (_c *CsLPPInterface_ProductionNominalMax_Call) Run(run func()) *CsLPPInterface_ProductionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_ProductionNominalMax_Call) Return(_a0 float64, _a1 error) *CsLPPInterface_ProductionNominalMax_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *CsLPPInterface_ProductionNominalMax_Call) RunAndReturn(run func() (float64, error)) *CsLPPInterface_ProductionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *CsLPPInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// CsLPPInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type CsLPPInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) RemoteEntitiesScenarios() *CsLPPInterface_RemoteEntitiesScenarios_Call { + return &CsLPPInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *CsLPPInterface_RemoteEntitiesScenarios_Call) Run(run func()) *CsLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *CsLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CsLPPInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *CsLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *CsLPPInterface) RemoveUseCase() { + _m.Called() +} + +// CsLPPInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type CsLPPInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) RemoveUseCase() *CsLPPInterface_RemoveUseCase_Call { + return &CsLPPInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *CsLPPInterface_RemoveUseCase_Call) Run(run func()) *CsLPPInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_RemoveUseCase_Call) Return() *CsLPPInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CsLPPInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// SetFailsafeDurationMinimum provides a mock function with given fields: duration, changeable +func (_m *CsLPPInterface) SetFailsafeDurationMinimum(duration time.Duration, changeable bool) error { + ret := _m.Called(duration, changeable) + + if len(ret) == 0 { + panic("no return value specified for SetFailsafeDurationMinimum") + } + + var r0 error + if rf, ok := ret.Get(0).(func(time.Duration, bool) error); ok { + r0 = rf(duration, changeable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPPInterface_SetFailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFailsafeDurationMinimum' +type CsLPPInterface_SetFailsafeDurationMinimum_Call struct { + *mock.Call +} + +// SetFailsafeDurationMinimum is a helper method to define mock.On call +// - duration time.Duration +// - changeable bool +func (_e *CsLPPInterface_Expecter) SetFailsafeDurationMinimum(duration interface{}, changeable interface{}) *CsLPPInterface_SetFailsafeDurationMinimum_Call { + return &CsLPPInterface_SetFailsafeDurationMinimum_Call{Call: _e.mock.On("SetFailsafeDurationMinimum", duration, changeable)} +} + +func (_c *CsLPPInterface_SetFailsafeDurationMinimum_Call) Run(run func(duration time.Duration, changeable bool)) *CsLPPInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration), args[1].(bool)) + }) + return _c +} + +func (_c *CsLPPInterface_SetFailsafeDurationMinimum_Call) Return(resultErr error) *CsLPPInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPPInterface_SetFailsafeDurationMinimum_Call) RunAndReturn(run func(time.Duration, bool) error) *CsLPPInterface_SetFailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// SetFailsafeProductionActivePowerLimit provides a mock function with given fields: value, changeable +func (_m *CsLPPInterface) SetFailsafeProductionActivePowerLimit(value float64, changeable bool) error { + ret := _m.Called(value, changeable) + + if len(ret) == 0 { + panic("no return value specified for SetFailsafeProductionActivePowerLimit") + } + + var r0 error + if rf, ok := ret.Get(0).(func(float64, bool) error); ok { + r0 = rf(value, changeable) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetFailsafeProductionActivePowerLimit' +type CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call struct { + *mock.Call +} + +// SetFailsafeProductionActivePowerLimit is a helper method to define mock.On call +// - value float64 +// - changeable bool +func (_e *CsLPPInterface_Expecter) SetFailsafeProductionActivePowerLimit(value interface{}, changeable interface{}) *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call { + return &CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call{Call: _e.mock.On("SetFailsafeProductionActivePowerLimit", value, changeable)} +} + +func (_c *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call) Run(run func(value float64, changeable bool)) *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(bool)) + }) + return _c +} + +func (_c *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call) Return(resultErr error) *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call) RunAndReturn(run func(float64, bool) error) *CsLPPInterface_SetFailsafeProductionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// SetProductionLimit provides a mock function with given fields: limit +func (_m *CsLPPInterface) SetProductionLimit(limit api.LoadLimit) error { + ret := _m.Called(limit) + + if len(ret) == 0 { + panic("no return value specified for SetProductionLimit") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.LoadLimit) error); ok { + r0 = rf(limit) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPPInterface_SetProductionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetProductionLimit' +type CsLPPInterface_SetProductionLimit_Call struct { + *mock.Call +} + +// SetProductionLimit is a helper method to define mock.On call +// - limit api.LoadLimit +func (_e *CsLPPInterface_Expecter) SetProductionLimit(limit interface{}) *CsLPPInterface_SetProductionLimit_Call { + return &CsLPPInterface_SetProductionLimit_Call{Call: _e.mock.On("SetProductionLimit", limit)} +} + +func (_c *CsLPPInterface_SetProductionLimit_Call) Run(run func(limit api.LoadLimit)) *CsLPPInterface_SetProductionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.LoadLimit)) + }) + return _c +} + +func (_c *CsLPPInterface_SetProductionLimit_Call) Return(resultErr error) *CsLPPInterface_SetProductionLimit_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPPInterface_SetProductionLimit_Call) RunAndReturn(run func(api.LoadLimit) error) *CsLPPInterface_SetProductionLimit_Call { + _c.Call.Return(run) + return _c +} + +// SetProductionNominalMax provides a mock function with given fields: value +func (_m *CsLPPInterface) SetProductionNominalMax(value float64) error { + ret := _m.Called(value) + + if len(ret) == 0 { + panic("no return value specified for SetProductionNominalMax") + } + + var r0 error + if rf, ok := ret.Get(0).(func(float64) error); ok { + r0 = rf(value) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CsLPPInterface_SetProductionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetProductionNominalMax' +type CsLPPInterface_SetProductionNominalMax_Call struct { + *mock.Call +} + +// SetProductionNominalMax is a helper method to define mock.On call +// - value float64 +func (_e *CsLPPInterface_Expecter) SetProductionNominalMax(value interface{}) *CsLPPInterface_SetProductionNominalMax_Call { + return &CsLPPInterface_SetProductionNominalMax_Call{Call: _e.mock.On("SetProductionNominalMax", value)} +} + +func (_c *CsLPPInterface_SetProductionNominalMax_Call) Run(run func(value float64)) *CsLPPInterface_SetProductionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64)) + }) + return _c +} + +func (_c *CsLPPInterface_SetProductionNominalMax_Call) Return(resultErr error) *CsLPPInterface_SetProductionNominalMax_Call { + _c.Call.Return(resultErr) + return _c +} + +func (_c *CsLPPInterface_SetProductionNominalMax_Call) RunAndReturn(run func(float64) error) *CsLPPInterface_SetProductionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *CsLPPInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// CsLPPInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type CsLPPInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *CsLPPInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *CsLPPInterface_UpdateUseCaseAvailability_Call { + return &CsLPPInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *CsLPPInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *CsLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CsLPPInterface_UpdateUseCaseAvailability_Call) Return() *CsLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *CsLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewCsLPPInterface creates a new instance of CsLPPInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCsLPPInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *CsLPPInterface { + mock := &CsLPPInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPCInterface.go new file mode 100644 index 0000000..d727d4f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPCInterface.go @@ -0,0 +1,762 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" + + time "time" +) + +// EgLPCInterface is an autogenerated mock type for the EgLPCInterface type +type EgLPCInterface struct { + mock.Mock +} + +type EgLPCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EgLPCInterface) EXPECT() *EgLPCInterface_Expecter { + return &EgLPCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *EgLPCInterface) AddFeatures() { + _m.Called() +} + +// EgLPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type EgLPCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) AddFeatures() *EgLPCInterface_AddFeatures_Call { + return &EgLPCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *EgLPCInterface_AddFeatures_Call) Run(run func()) *EgLPCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_AddFeatures_Call) Return() *EgLPCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_AddFeatures_Call) RunAndReturn(run func()) *EgLPCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *EgLPCInterface) AddUseCase() { + _m.Called() +} + +// EgLPCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type EgLPCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) AddUseCase() *EgLPCInterface_AddUseCase_Call { + return &EgLPCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *EgLPCInterface_AddUseCase_Call) Run(run func()) *EgLPCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_AddUseCase_Call) Return() *EgLPCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_AddUseCase_Call) RunAndReturn(run func()) *EgLPCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *EgLPCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// EgLPCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type EgLPCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *EgLPCInterface_AvailableScenariosForEntity_Call { + return &EgLPCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *EgLPCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *EgLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *EgLPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// ConsumptionLimit provides a mock function with given fields: entity +func (_m *EgLPCInterface) ConsumptionLimit(entity spine_goapi.EntityRemoteInterface) (api.LoadLimit, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ConsumptionLimit") + } + + var r0 api.LoadLimit + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.LoadLimit, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.LoadLimit); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.LoadLimit) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_ConsumptionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumptionLimit' +type EgLPCInterface_ConsumptionLimit_Call struct { + *mock.Call +} + +// ConsumptionLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) ConsumptionLimit(entity interface{}) *EgLPCInterface_ConsumptionLimit_Call { + return &EgLPCInterface_ConsumptionLimit_Call{Call: _e.mock.On("ConsumptionLimit", entity)} +} + +func (_c *EgLPCInterface_ConsumptionLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_ConsumptionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_ConsumptionLimit_Call) Return(limit api.LoadLimit, resultErr error) *EgLPCInterface_ConsumptionLimit_Call { + _c.Call.Return(limit, resultErr) + return _c +} + +func (_c *EgLPCInterface_ConsumptionLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.LoadLimit, error)) *EgLPCInterface_ConsumptionLimit_Call { + _c.Call.Return(run) + return _c +} + +// ConsumptionNominalMax provides a mock function with given fields: entity +func (_m *EgLPCInterface) ConsumptionNominalMax(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ConsumptionNominalMax") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_ConsumptionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumptionNominalMax' +type EgLPCInterface_ConsumptionNominalMax_Call struct { + *mock.Call +} + +// ConsumptionNominalMax is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) ConsumptionNominalMax(entity interface{}) *EgLPCInterface_ConsumptionNominalMax_Call { + return &EgLPCInterface_ConsumptionNominalMax_Call{Call: _e.mock.On("ConsumptionNominalMax", entity)} +} + +func (_c *EgLPCInterface_ConsumptionNominalMax_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_ConsumptionNominalMax_Call) Return(_a0 float64, _a1 error) *EgLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_ConsumptionNominalMax_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *EgLPCInterface_ConsumptionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeConsumptionActivePowerLimit provides a mock function with given fields: entity +func (_m *EgLPCInterface) FailsafeConsumptionActivePowerLimit(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for FailsafeConsumptionActivePowerLimit") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeConsumptionActivePowerLimit' +type EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call struct { + *mock.Call +} + +// FailsafeConsumptionActivePowerLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) FailsafeConsumptionActivePowerLimit(entity interface{}) *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + return &EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call{Call: _e.mock.On("FailsafeConsumptionActivePowerLimit", entity)} +} + +func (_c *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call) Return(_a0 float64, _a1 error) *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *EgLPCInterface_FailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeDurationMinimum provides a mock function with given fields: entity +func (_m *EgLPCInterface) FailsafeDurationMinimum(entity spine_goapi.EntityRemoteInterface) (time.Duration, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for FailsafeDurationMinimum") + } + + var r0 time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (time.Duration, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) time.Duration); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_FailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeDurationMinimum' +type EgLPCInterface_FailsafeDurationMinimum_Call struct { + *mock.Call +} + +// FailsafeDurationMinimum is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) FailsafeDurationMinimum(entity interface{}) *EgLPCInterface_FailsafeDurationMinimum_Call { + return &EgLPCInterface_FailsafeDurationMinimum_Call{Call: _e.mock.On("FailsafeDurationMinimum", entity)} +} + +func (_c *EgLPCInterface_FailsafeDurationMinimum_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_FailsafeDurationMinimum_Call) Return(_a0 time.Duration, _a1 error) *EgLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_FailsafeDurationMinimum_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (time.Duration, error)) *EgLPCInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *EgLPCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type EgLPCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *EgLPCInterface_IsCompatibleEntityType_Call { + return &EgLPCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *EgLPCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *EgLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *EgLPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *EgLPCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type EgLPCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *EgLPCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *EgLPCInterface_IsScenarioAvailableAtEntity_Call { + return &EgLPCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *EgLPCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *EgLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *EgLPCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *EgLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *EgLPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *EgLPCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// EgLPCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type EgLPCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) RemoteEntitiesScenarios() *EgLPCInterface_RemoteEntitiesScenarios_Call { + return &EgLPCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *EgLPCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *EgLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *EgLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *EgLPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *EgLPCInterface) RemoveUseCase() { + _m.Called() +} + +// EgLPCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type EgLPCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) RemoveUseCase() *EgLPCInterface_RemoveUseCase_Call { + return &EgLPCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *EgLPCInterface_RemoveUseCase_Call) Run(run func()) *EgLPCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_RemoveUseCase_Call) Return() *EgLPCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *EgLPCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *EgLPCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// EgLPCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type EgLPCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *EgLPCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *EgLPCInterface_UpdateUseCaseAvailability_Call { + return &EgLPCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *EgLPCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *EgLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *EgLPCInterface_UpdateUseCaseAvailability_Call) Return() *EgLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *EgLPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// WriteConsumptionLimit provides a mock function with given fields: entity, limit, resultCB +func (_m *EgLPCInterface) WriteConsumptionLimit(entity spine_goapi.EntityRemoteInterface, limit api.LoadLimit, resultCB func(model.ResultDataType)) (*model.MsgCounterType, error) { + ret := _m.Called(entity, limit, resultCB) + + if len(ret) == 0 { + panic("no return value specified for WriteConsumptionLimit") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) (*model.MsgCounterType, error)); ok { + return rf(entity, limit, resultCB) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) *model.MsgCounterType); ok { + r0 = rf(entity, limit, resultCB) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) error); ok { + r1 = rf(entity, limit, resultCB) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_WriteConsumptionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteConsumptionLimit' +type EgLPCInterface_WriteConsumptionLimit_Call struct { + *mock.Call +} + +// WriteConsumptionLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - limit api.LoadLimit +// - resultCB func(model.ResultDataType) +func (_e *EgLPCInterface_Expecter) WriteConsumptionLimit(entity interface{}, limit interface{}, resultCB interface{}) *EgLPCInterface_WriteConsumptionLimit_Call { + return &EgLPCInterface_WriteConsumptionLimit_Call{Call: _e.mock.On("WriteConsumptionLimit", entity, limit, resultCB)} +} + +func (_c *EgLPCInterface_WriteConsumptionLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, limit api.LoadLimit, resultCB func(model.ResultDataType))) *EgLPCInterface_WriteConsumptionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(api.LoadLimit), args[2].(func(model.ResultDataType))) + }) + return _c +} + +func (_c *EgLPCInterface_WriteConsumptionLimit_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPCInterface_WriteConsumptionLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_WriteConsumptionLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) (*model.MsgCounterType, error)) *EgLPCInterface_WriteConsumptionLimit_Call { + _c.Call.Return(run) + return _c +} + +// WriteFailsafeConsumptionActivePowerLimit provides a mock function with given fields: entity, value +func (_m *EgLPCInterface) WriteFailsafeConsumptionActivePowerLimit(entity spine_goapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) { + ret := _m.Called(entity, value) + + if len(ret) == 0 { + panic("no return value specified for WriteFailsafeConsumptionActivePowerLimit") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, float64) (*model.MsgCounterType, error)); ok { + return rf(entity, value) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, float64) *model.MsgCounterType); ok { + r0 = rf(entity, value) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, float64) error); ok { + r1 = rf(entity, value) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteFailsafeConsumptionActivePowerLimit' +type EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call struct { + *mock.Call +} + +// WriteFailsafeConsumptionActivePowerLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - value float64 +func (_e *EgLPCInterface_Expecter) WriteFailsafeConsumptionActivePowerLimit(entity interface{}, value interface{}) *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call { + return &EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call{Call: _e.mock.On("WriteFailsafeConsumptionActivePowerLimit", entity, value)} +} + +func (_c *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, value float64)) *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(float64)) + }) + return _c +} + +func (_c *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, float64) (*model.MsgCounterType, error)) *EgLPCInterface_WriteFailsafeConsumptionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// WriteFailsafeDurationMinimum provides a mock function with given fields: entity, duration +func (_m *EgLPCInterface) WriteFailsafeDurationMinimum(entity spine_goapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) { + ret := _m.Called(entity, duration) + + if len(ret) == 0 { + panic("no return value specified for WriteFailsafeDurationMinimum") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, time.Duration) (*model.MsgCounterType, error)); ok { + return rf(entity, duration) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, time.Duration) *model.MsgCounterType); ok { + r0 = rf(entity, duration) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, time.Duration) error); ok { + r1 = rf(entity, duration) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPCInterface_WriteFailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteFailsafeDurationMinimum' +type EgLPCInterface_WriteFailsafeDurationMinimum_Call struct { + *mock.Call +} + +// WriteFailsafeDurationMinimum is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - duration time.Duration +func (_e *EgLPCInterface_Expecter) WriteFailsafeDurationMinimum(entity interface{}, duration interface{}) *EgLPCInterface_WriteFailsafeDurationMinimum_Call { + return &EgLPCInterface_WriteFailsafeDurationMinimum_Call{Call: _e.mock.On("WriteFailsafeDurationMinimum", entity, duration)} +} + +func (_c *EgLPCInterface_WriteFailsafeDurationMinimum_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, duration time.Duration)) *EgLPCInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(time.Duration)) + }) + return _c +} + +func (_c *EgLPCInterface_WriteFailsafeDurationMinimum_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPCInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPCInterface_WriteFailsafeDurationMinimum_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, time.Duration) (*model.MsgCounterType, error)) *EgLPCInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// NewEgLPCInterface creates a new instance of EgLPCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEgLPCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EgLPCInterface { + mock := &EgLPCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPPInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPPInterface.go new file mode 100644 index 0000000..dddd2fc --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/EgLPPInterface.go @@ -0,0 +1,762 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + api "github.com/enbility/eebus-go/usecases/api" + + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + spine_goapi "github.com/enbility/spine-go/api" + + time "time" +) + +// EgLPPInterface is an autogenerated mock type for the EgLPPInterface type +type EgLPPInterface struct { + mock.Mock +} + +type EgLPPInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EgLPPInterface) EXPECT() *EgLPPInterface_Expecter { + return &EgLPPInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *EgLPPInterface) AddFeatures() { + _m.Called() +} + +// EgLPPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type EgLPPInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) AddFeatures() *EgLPPInterface_AddFeatures_Call { + return &EgLPPInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *EgLPPInterface_AddFeatures_Call) Run(run func()) *EgLPPInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_AddFeatures_Call) Return() *EgLPPInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_AddFeatures_Call) RunAndReturn(run func()) *EgLPPInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *EgLPPInterface) AddUseCase() { + _m.Called() +} + +// EgLPPInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type EgLPPInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) AddUseCase() *EgLPPInterface_AddUseCase_Call { + return &EgLPPInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *EgLPPInterface_AddUseCase_Call) Run(run func()) *EgLPPInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_AddUseCase_Call) Return() *EgLPPInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_AddUseCase_Call) RunAndReturn(run func()) *EgLPPInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *EgLPPInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// EgLPPInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type EgLPPInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *EgLPPInterface_AvailableScenariosForEntity_Call { + return &EgLPPInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *EgLPPInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *EgLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPPInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *EgLPPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeDurationMinimum provides a mock function with given fields: entity +func (_m *EgLPPInterface) FailsafeDurationMinimum(entity spine_goapi.EntityRemoteInterface) (time.Duration, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for FailsafeDurationMinimum") + } + + var r0 time.Duration + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (time.Duration, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) time.Duration); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(time.Duration) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_FailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeDurationMinimum' +type EgLPPInterface_FailsafeDurationMinimum_Call struct { + *mock.Call +} + +// FailsafeDurationMinimum is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) FailsafeDurationMinimum(entity interface{}) *EgLPPInterface_FailsafeDurationMinimum_Call { + return &EgLPPInterface_FailsafeDurationMinimum_Call{Call: _e.mock.On("FailsafeDurationMinimum", entity)} +} + +func (_c *EgLPPInterface_FailsafeDurationMinimum_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_FailsafeDurationMinimum_Call) Return(_a0 time.Duration, _a1 error) *EgLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_FailsafeDurationMinimum_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (time.Duration, error)) *EgLPPInterface_FailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// FailsafeProductionActivePowerLimit provides a mock function with given fields: entity +func (_m *EgLPPInterface) FailsafeProductionActivePowerLimit(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for FailsafeProductionActivePowerLimit") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_FailsafeProductionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FailsafeProductionActivePowerLimit' +type EgLPPInterface_FailsafeProductionActivePowerLimit_Call struct { + *mock.Call +} + +// FailsafeProductionActivePowerLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) FailsafeProductionActivePowerLimit(entity interface{}) *EgLPPInterface_FailsafeProductionActivePowerLimit_Call { + return &EgLPPInterface_FailsafeProductionActivePowerLimit_Call{Call: _e.mock.On("FailsafeProductionActivePowerLimit", entity)} +} + +func (_c *EgLPPInterface_FailsafeProductionActivePowerLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_FailsafeProductionActivePowerLimit_Call) Return(_a0 float64, _a1 error) *EgLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_FailsafeProductionActivePowerLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *EgLPPInterface_FailsafeProductionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *EgLPPInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPPInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type EgLPPInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) IsCompatibleEntityType(entity interface{}) *EgLPPInterface_IsCompatibleEntityType_Call { + return &EgLPPInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *EgLPPInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *EgLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPPInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *EgLPPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *EgLPPInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPPInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type EgLPPInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *EgLPPInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *EgLPPInterface_IsScenarioAvailableAtEntity_Call { + return &EgLPPInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *EgLPPInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *EgLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *EgLPPInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *EgLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPPInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *EgLPPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// ProductionLimit provides a mock function with given fields: entity +func (_m *EgLPPInterface) ProductionLimit(entity spine_goapi.EntityRemoteInterface) (api.LoadLimit, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ProductionLimit") + } + + var r0 api.LoadLimit + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (api.LoadLimit, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) api.LoadLimit); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(api.LoadLimit) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_ProductionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProductionLimit' +type EgLPPInterface_ProductionLimit_Call struct { + *mock.Call +} + +// ProductionLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) ProductionLimit(entity interface{}) *EgLPPInterface_ProductionLimit_Call { + return &EgLPPInterface_ProductionLimit_Call{Call: _e.mock.On("ProductionLimit", entity)} +} + +func (_c *EgLPPInterface_ProductionLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_ProductionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_ProductionLimit_Call) Return(limit api.LoadLimit, resultErr error) *EgLPPInterface_ProductionLimit_Call { + _c.Call.Return(limit, resultErr) + return _c +} + +func (_c *EgLPPInterface_ProductionLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (api.LoadLimit, error)) *EgLPPInterface_ProductionLimit_Call { + _c.Call.Return(run) + return _c +} + +// ProductionNominalMax provides a mock function with given fields: entity +func (_m *EgLPPInterface) ProductionNominalMax(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for ProductionNominalMax") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_ProductionNominalMax_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProductionNominalMax' +type EgLPPInterface_ProductionNominalMax_Call struct { + *mock.Call +} + +// ProductionNominalMax is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) ProductionNominalMax(entity interface{}) *EgLPPInterface_ProductionNominalMax_Call { + return &EgLPPInterface_ProductionNominalMax_Call{Call: _e.mock.On("ProductionNominalMax", entity)} +} + +func (_c *EgLPPInterface_ProductionNominalMax_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_ProductionNominalMax_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_ProductionNominalMax_Call) Return(_a0 float64, _a1 error) *EgLPPInterface_ProductionNominalMax_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_ProductionNominalMax_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *EgLPPInterface_ProductionNominalMax_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *EgLPPInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// EgLPPInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type EgLPPInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) RemoteEntitiesScenarios() *EgLPPInterface_RemoteEntitiesScenarios_Call { + return &EgLPPInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *EgLPPInterface_RemoteEntitiesScenarios_Call) Run(run func()) *EgLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *EgLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPPInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *EgLPPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *EgLPPInterface) RemoveUseCase() { + _m.Called() +} + +// EgLPPInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type EgLPPInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) RemoveUseCase() *EgLPPInterface_RemoveUseCase_Call { + return &EgLPPInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *EgLPPInterface_RemoveUseCase_Call) Run(run func()) *EgLPPInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_RemoveUseCase_Call) Return() *EgLPPInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_RemoveUseCase_Call) RunAndReturn(run func()) *EgLPPInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *EgLPPInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// EgLPPInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type EgLPPInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *EgLPPInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *EgLPPInterface_UpdateUseCaseAvailability_Call { + return &EgLPPInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *EgLPPInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *EgLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *EgLPPInterface_UpdateUseCaseAvailability_Call) Return() *EgLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *EgLPPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// WriteFailsafeDurationMinimum provides a mock function with given fields: entity, duration +func (_m *EgLPPInterface) WriteFailsafeDurationMinimum(entity spine_goapi.EntityRemoteInterface, duration time.Duration) (*model.MsgCounterType, error) { + ret := _m.Called(entity, duration) + + if len(ret) == 0 { + panic("no return value specified for WriteFailsafeDurationMinimum") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, time.Duration) (*model.MsgCounterType, error)); ok { + return rf(entity, duration) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, time.Duration) *model.MsgCounterType); ok { + r0 = rf(entity, duration) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, time.Duration) error); ok { + r1 = rf(entity, duration) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_WriteFailsafeDurationMinimum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteFailsafeDurationMinimum' +type EgLPPInterface_WriteFailsafeDurationMinimum_Call struct { + *mock.Call +} + +// WriteFailsafeDurationMinimum is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - duration time.Duration +func (_e *EgLPPInterface_Expecter) WriteFailsafeDurationMinimum(entity interface{}, duration interface{}) *EgLPPInterface_WriteFailsafeDurationMinimum_Call { + return &EgLPPInterface_WriteFailsafeDurationMinimum_Call{Call: _e.mock.On("WriteFailsafeDurationMinimum", entity, duration)} +} + +func (_c *EgLPPInterface_WriteFailsafeDurationMinimum_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, duration time.Duration)) *EgLPPInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(time.Duration)) + }) + return _c +} + +func (_c *EgLPPInterface_WriteFailsafeDurationMinimum_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPPInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_WriteFailsafeDurationMinimum_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, time.Duration) (*model.MsgCounterType, error)) *EgLPPInterface_WriteFailsafeDurationMinimum_Call { + _c.Call.Return(run) + return _c +} + +// WriteFailsafeProductionActivePowerLimit provides a mock function with given fields: entity, value +func (_m *EgLPPInterface) WriteFailsafeProductionActivePowerLimit(entity spine_goapi.EntityRemoteInterface, value float64) (*model.MsgCounterType, error) { + ret := _m.Called(entity, value) + + if len(ret) == 0 { + panic("no return value specified for WriteFailsafeProductionActivePowerLimit") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, float64) (*model.MsgCounterType, error)); ok { + return rf(entity, value) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, float64) *model.MsgCounterType); ok { + r0 = rf(entity, value) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, float64) error); ok { + r1 = rf(entity, value) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteFailsafeProductionActivePowerLimit' +type EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call struct { + *mock.Call +} + +// WriteFailsafeProductionActivePowerLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - value float64 +func (_e *EgLPPInterface_Expecter) WriteFailsafeProductionActivePowerLimit(entity interface{}, value interface{}) *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call { + return &EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call{Call: _e.mock.On("WriteFailsafeProductionActivePowerLimit", entity, value)} +} + +func (_c *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, value float64)) *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(float64)) + }) + return _c +} + +func (_c *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, float64) (*model.MsgCounterType, error)) *EgLPPInterface_WriteFailsafeProductionActivePowerLimit_Call { + _c.Call.Return(run) + return _c +} + +// WriteProductionLimit provides a mock function with given fields: entity, limit, resultCB +func (_m *EgLPPInterface) WriteProductionLimit(entity spine_goapi.EntityRemoteInterface, limit api.LoadLimit, resultCB func(model.ResultDataType)) (*model.MsgCounterType, error) { + ret := _m.Called(entity, limit, resultCB) + + if len(ret) == 0 { + panic("no return value specified for WriteProductionLimit") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) (*model.MsgCounterType, error)); ok { + return rf(entity, limit, resultCB) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) *model.MsgCounterType); ok { + r0 = rf(entity, limit, resultCB) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) error); ok { + r1 = rf(entity, limit, resultCB) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EgLPPInterface_WriteProductionLimit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteProductionLimit' +type EgLPPInterface_WriteProductionLimit_Call struct { + *mock.Call +} + +// WriteProductionLimit is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - limit api.LoadLimit +// - resultCB func(model.ResultDataType) +func (_e *EgLPPInterface_Expecter) WriteProductionLimit(entity interface{}, limit interface{}, resultCB interface{}) *EgLPPInterface_WriteProductionLimit_Call { + return &EgLPPInterface_WriteProductionLimit_Call{Call: _e.mock.On("WriteProductionLimit", entity, limit, resultCB)} +} + +func (_c *EgLPPInterface_WriteProductionLimit_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, limit api.LoadLimit, resultCB func(model.ResultDataType))) *EgLPPInterface_WriteProductionLimit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(api.LoadLimit), args[2].(func(model.ResultDataType))) + }) + return _c +} + +func (_c *EgLPPInterface_WriteProductionLimit_Call) Return(_a0 *model.MsgCounterType, _a1 error) *EgLPPInterface_WriteProductionLimit_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EgLPPInterface_WriteProductionLimit_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, api.LoadLimit, func(model.ResultDataType)) (*model.MsgCounterType, error)) *EgLPPInterface_WriteProductionLimit_Call { + _c.Call.Return(run) + return _c +} + +// NewEgLPPInterface creates a new instance of EgLPPInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEgLPPInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EgLPPInterface { + mock := &EgLPPInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/GcpMGCPInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/GcpMGCPInterface.go new file mode 100644 index 0000000..12fb206 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/GcpMGCPInterface.go @@ -0,0 +1,750 @@ +// Code generated by mockery v2.42.1. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// GcpMGCPInterface is an autogenerated mock type for the GcpMGCPInterface type +type GcpMGCPInterface struct { + mock.Mock +} + +type GcpMGCPInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *GcpMGCPInterface) EXPECT() *GcpMGCPInterface_Expecter { + return &GcpMGCPInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *GcpMGCPInterface) AddFeatures() { + _m.Called() +} + +// GcpMGCPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type GcpMGCPInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *GcpMGCPInterface_Expecter) AddFeatures() *GcpMGCPInterface_AddFeatures_Call { + return &GcpMGCPInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *GcpMGCPInterface_AddFeatures_Call) Run(run func()) *GcpMGCPInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *GcpMGCPInterface_AddFeatures_Call) Return() *GcpMGCPInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *GcpMGCPInterface_AddFeatures_Call) RunAndReturn(run func()) *GcpMGCPInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *GcpMGCPInterface) AddUseCase() { + _m.Called() +} + +// GcpMGCPInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type GcpMGCPInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *GcpMGCPInterface_Expecter) AddUseCase() *GcpMGCPInterface_AddUseCase_Call { + return &GcpMGCPInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *GcpMGCPInterface_AddUseCase_Call) Run(run func()) *GcpMGCPInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *GcpMGCPInterface_AddUseCase_Call) Return() *GcpMGCPInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *GcpMGCPInterface_AddUseCase_Call) RunAndReturn(run func()) *GcpMGCPInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// GcpMGCPInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type GcpMGCPInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *GcpMGCPInterface_AvailableScenariosForEntity_Call { + return &GcpMGCPInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *GcpMGCPInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *GcpMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *GcpMGCPInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *GcpMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentPerPhase provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) CurrentPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_CurrentPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentPerPhase' +type GcpMGCPInterface_CurrentPerPhase_Call struct { + *mock.Call +} + +// CurrentPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) CurrentPerPhase(entity interface{}) *GcpMGCPInterface_CurrentPerPhase_Call { + return &GcpMGCPInterface_CurrentPerPhase_Call{Call: _e.mock.On("CurrentPerPhase", entity)} +} + +func (_c *GcpMGCPInterface_CurrentPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_CurrentPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_CurrentPerPhase_Call) Return(_a0 []float64, _a1 error) *GcpMGCPInterface_CurrentPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_CurrentPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *GcpMGCPInterface_CurrentPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// EnergyConsumed provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) EnergyConsumed(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyConsumed") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_EnergyConsumed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyConsumed' +type GcpMGCPInterface_EnergyConsumed_Call struct { + *mock.Call +} + +// EnergyConsumed is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) EnergyConsumed(entity interface{}) *GcpMGCPInterface_EnergyConsumed_Call { + return &GcpMGCPInterface_EnergyConsumed_Call{Call: _e.mock.On("EnergyConsumed", entity)} +} + +func (_c *GcpMGCPInterface_EnergyConsumed_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_EnergyConsumed_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_EnergyConsumed_Call) Return(_a0 float64, _a1 error) *GcpMGCPInterface_EnergyConsumed_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_EnergyConsumed_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *GcpMGCPInterface_EnergyConsumed_Call { + _c.Call.Return(run) + return _c +} + +// EnergyFeedIn provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) EnergyFeedIn(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyFeedIn") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_EnergyFeedIn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyFeedIn' +type GcpMGCPInterface_EnergyFeedIn_Call struct { + *mock.Call +} + +// EnergyFeedIn is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) EnergyFeedIn(entity interface{}) *GcpMGCPInterface_EnergyFeedIn_Call { + return &GcpMGCPInterface_EnergyFeedIn_Call{Call: _e.mock.On("EnergyFeedIn", entity)} +} + +func (_c *GcpMGCPInterface_EnergyFeedIn_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_EnergyFeedIn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_EnergyFeedIn_Call) Return(_a0 float64, _a1 error) *GcpMGCPInterface_EnergyFeedIn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_EnergyFeedIn_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *GcpMGCPInterface_EnergyFeedIn_Call { + _c.Call.Return(run) + return _c +} + +// Frequency provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) Frequency(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Frequency") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_Frequency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Frequency' +type GcpMGCPInterface_Frequency_Call struct { + *mock.Call +} + +// Frequency is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) Frequency(entity interface{}) *GcpMGCPInterface_Frequency_Call { + return &GcpMGCPInterface_Frequency_Call{Call: _e.mock.On("Frequency", entity)} +} + +func (_c *GcpMGCPInterface_Frequency_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_Frequency_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_Frequency_Call) Return(_a0 float64, _a1 error) *GcpMGCPInterface_Frequency_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_Frequency_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *GcpMGCPInterface_Frequency_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// GcpMGCPInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type GcpMGCPInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) IsCompatibleEntityType(entity interface{}) *GcpMGCPInterface_IsCompatibleEntityType_Call { + return &GcpMGCPInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *GcpMGCPInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *GcpMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *GcpMGCPInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *GcpMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *GcpMGCPInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// GcpMGCPInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type GcpMGCPInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *GcpMGCPInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call { + return &GcpMGCPInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *GcpMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) Power(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type GcpMGCPInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) Power(entity interface{}) *GcpMGCPInterface_Power_Call { + return &GcpMGCPInterface_Power_Call{Call: _e.mock.On("Power", entity)} +} + +func (_c *GcpMGCPInterface_Power_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_Power_Call) Return(_a0 float64, _a1 error) *GcpMGCPInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_Power_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *GcpMGCPInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// PowerLimitationFactor provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) PowerLimitationFactor(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PowerLimitationFactor") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_PowerLimitationFactor_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerLimitationFactor' +type GcpMGCPInterface_PowerLimitationFactor_Call struct { + *mock.Call +} + +// PowerLimitationFactor is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) PowerLimitationFactor(entity interface{}) *GcpMGCPInterface_PowerLimitationFactor_Call { + return &GcpMGCPInterface_PowerLimitationFactor_Call{Call: _e.mock.On("PowerLimitationFactor", entity)} +} + +func (_c *GcpMGCPInterface_PowerLimitationFactor_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_PowerLimitationFactor_Call) Return(_a0 float64, _a1 error) *GcpMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_PowerLimitationFactor_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *GcpMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *GcpMGCPInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// GcpMGCPInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type GcpMGCPInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *GcpMGCPInterface_Expecter) RemoteEntitiesScenarios() *GcpMGCPInterface_RemoteEntitiesScenarios_Call { + return &GcpMGCPInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *GcpMGCPInterface_RemoteEntitiesScenarios_Call) Run(run func()) *GcpMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *GcpMGCPInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *GcpMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *GcpMGCPInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *GcpMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *GcpMGCPInterface) RemoveUseCase() { + _m.Called() +} + +// GcpMGCPInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type GcpMGCPInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *GcpMGCPInterface_Expecter) RemoveUseCase() *GcpMGCPInterface_RemoveUseCase_Call { + return &GcpMGCPInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *GcpMGCPInterface_RemoveUseCase_Call) Run(run func()) *GcpMGCPInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *GcpMGCPInterface_RemoveUseCase_Call) Return() *GcpMGCPInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *GcpMGCPInterface_RemoveUseCase_Call) RunAndReturn(run func()) *GcpMGCPInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *GcpMGCPInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// GcpMGCPInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type GcpMGCPInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *GcpMGCPInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *GcpMGCPInterface_UpdateUseCaseAvailability_Call { + return &GcpMGCPInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *GcpMGCPInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *GcpMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *GcpMGCPInterface_UpdateUseCaseAvailability_Call) Return() *GcpMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *GcpMGCPInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *GcpMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// VoltagePerPhase provides a mock function with given fields: entity +func (_m *GcpMGCPInterface) VoltagePerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for VoltagePerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GcpMGCPInterface_VoltagePerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VoltagePerPhase' +type GcpMGCPInterface_VoltagePerPhase_Call struct { + *mock.Call +} + +// VoltagePerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *GcpMGCPInterface_Expecter) VoltagePerPhase(entity interface{}) *GcpMGCPInterface_VoltagePerPhase_Call { + return &GcpMGCPInterface_VoltagePerPhase_Call{Call: _e.mock.On("VoltagePerPhase", entity)} +} + +func (_c *GcpMGCPInterface_VoltagePerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *GcpMGCPInterface_VoltagePerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *GcpMGCPInterface_VoltagePerPhase_Call) Return(_a0 []float64, _a1 error) *GcpMGCPInterface_VoltagePerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GcpMGCPInterface_VoltagePerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *GcpMGCPInterface_VoltagePerPhase_Call { + _c.Call.Return(run) + return _c +} + +// NewGcpMGCPInterface creates a new instance of GcpMGCPInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewGcpMGCPInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *GcpMGCPInterface { + mock := &GcpMGCPInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMGCPInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMGCPInterface.go new file mode 100644 index 0000000..bc4ea31 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMGCPInterface.go @@ -0,0 +1,750 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// MaMGCPInterface is an autogenerated mock type for the MaMGCPInterface type +type MaMGCPInterface struct { + mock.Mock +} + +type MaMGCPInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MaMGCPInterface) EXPECT() *MaMGCPInterface_Expecter { + return &MaMGCPInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *MaMGCPInterface) AddFeatures() { + _m.Called() +} + +// MaMGCPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type MaMGCPInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *MaMGCPInterface_Expecter) AddFeatures() *MaMGCPInterface_AddFeatures_Call { + return &MaMGCPInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *MaMGCPInterface_AddFeatures_Call) Run(run func()) *MaMGCPInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMGCPInterface_AddFeatures_Call) Return() *MaMGCPInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMGCPInterface_AddFeatures_Call) RunAndReturn(run func()) *MaMGCPInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *MaMGCPInterface) AddUseCase() { + _m.Called() +} + +// MaMGCPInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type MaMGCPInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *MaMGCPInterface_Expecter) AddUseCase() *MaMGCPInterface_AddUseCase_Call { + return &MaMGCPInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *MaMGCPInterface_AddUseCase_Call) Run(run func()) *MaMGCPInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMGCPInterface_AddUseCase_Call) Return() *MaMGCPInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMGCPInterface_AddUseCase_Call) RunAndReturn(run func()) *MaMGCPInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *MaMGCPInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// MaMGCPInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type MaMGCPInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *MaMGCPInterface_AvailableScenariosForEntity_Call { + return &MaMGCPInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *MaMGCPInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *MaMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMGCPInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *MaMGCPInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentPerPhase provides a mock function with given fields: entity +func (_m *MaMGCPInterface) CurrentPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_CurrentPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentPerPhase' +type MaMGCPInterface_CurrentPerPhase_Call struct { + *mock.Call +} + +// CurrentPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) CurrentPerPhase(entity interface{}) *MaMGCPInterface_CurrentPerPhase_Call { + return &MaMGCPInterface_CurrentPerPhase_Call{Call: _e.mock.On("CurrentPerPhase", entity)} +} + +func (_c *MaMGCPInterface_CurrentPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_CurrentPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_CurrentPerPhase_Call) Return(_a0 []float64, _a1 error) *MaMGCPInterface_CurrentPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_CurrentPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *MaMGCPInterface_CurrentPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// EnergyConsumed provides a mock function with given fields: entity +func (_m *MaMGCPInterface) EnergyConsumed(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyConsumed") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_EnergyConsumed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyConsumed' +type MaMGCPInterface_EnergyConsumed_Call struct { + *mock.Call +} + +// EnergyConsumed is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) EnergyConsumed(entity interface{}) *MaMGCPInterface_EnergyConsumed_Call { + return &MaMGCPInterface_EnergyConsumed_Call{Call: _e.mock.On("EnergyConsumed", entity)} +} + +func (_c *MaMGCPInterface_EnergyConsumed_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_EnergyConsumed_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_EnergyConsumed_Call) Return(_a0 float64, _a1 error) *MaMGCPInterface_EnergyConsumed_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_EnergyConsumed_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMGCPInterface_EnergyConsumed_Call { + _c.Call.Return(run) + return _c +} + +// EnergyFeedIn provides a mock function with given fields: entity +func (_m *MaMGCPInterface) EnergyFeedIn(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyFeedIn") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_EnergyFeedIn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyFeedIn' +type MaMGCPInterface_EnergyFeedIn_Call struct { + *mock.Call +} + +// EnergyFeedIn is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) EnergyFeedIn(entity interface{}) *MaMGCPInterface_EnergyFeedIn_Call { + return &MaMGCPInterface_EnergyFeedIn_Call{Call: _e.mock.On("EnergyFeedIn", entity)} +} + +func (_c *MaMGCPInterface_EnergyFeedIn_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_EnergyFeedIn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_EnergyFeedIn_Call) Return(_a0 float64, _a1 error) *MaMGCPInterface_EnergyFeedIn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_EnergyFeedIn_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMGCPInterface_EnergyFeedIn_Call { + _c.Call.Return(run) + return _c +} + +// Frequency provides a mock function with given fields: entity +func (_m *MaMGCPInterface) Frequency(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Frequency") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_Frequency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Frequency' +type MaMGCPInterface_Frequency_Call struct { + *mock.Call +} + +// Frequency is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) Frequency(entity interface{}) *MaMGCPInterface_Frequency_Call { + return &MaMGCPInterface_Frequency_Call{Call: _e.mock.On("Frequency", entity)} +} + +func (_c *MaMGCPInterface_Frequency_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_Frequency_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_Frequency_Call) Return(_a0 float64, _a1 error) *MaMGCPInterface_Frequency_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_Frequency_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMGCPInterface_Frequency_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *MaMGCPInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MaMGCPInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type MaMGCPInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) IsCompatibleEntityType(entity interface{}) *MaMGCPInterface_IsCompatibleEntityType_Call { + return &MaMGCPInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *MaMGCPInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *MaMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMGCPInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *MaMGCPInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *MaMGCPInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MaMGCPInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type MaMGCPInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *MaMGCPInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *MaMGCPInterface_IsScenarioAvailableAtEntity_Call { + return &MaMGCPInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *MaMGCPInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *MaMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *MaMGCPInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *MaMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMGCPInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *MaMGCPInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: entity +func (_m *MaMGCPInterface) Power(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type MaMGCPInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) Power(entity interface{}) *MaMGCPInterface_Power_Call { + return &MaMGCPInterface_Power_Call{Call: _e.mock.On("Power", entity)} +} + +func (_c *MaMGCPInterface_Power_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_Power_Call) Return(_a0 float64, _a1 error) *MaMGCPInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_Power_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMGCPInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// PowerLimitationFactor provides a mock function with given fields: entity +func (_m *MaMGCPInterface) PowerLimitationFactor(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PowerLimitationFactor") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_PowerLimitationFactor_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerLimitationFactor' +type MaMGCPInterface_PowerLimitationFactor_Call struct { + *mock.Call +} + +// PowerLimitationFactor is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) PowerLimitationFactor(entity interface{}) *MaMGCPInterface_PowerLimitationFactor_Call { + return &MaMGCPInterface_PowerLimitationFactor_Call{Call: _e.mock.On("PowerLimitationFactor", entity)} +} + +func (_c *MaMGCPInterface_PowerLimitationFactor_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_PowerLimitationFactor_Call) Return(_a0 float64, _a1 error) *MaMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_PowerLimitationFactor_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMGCPInterface_PowerLimitationFactor_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *MaMGCPInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// MaMGCPInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type MaMGCPInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *MaMGCPInterface_Expecter) RemoteEntitiesScenarios() *MaMGCPInterface_RemoteEntitiesScenarios_Call { + return &MaMGCPInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *MaMGCPInterface_RemoteEntitiesScenarios_Call) Run(run func()) *MaMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMGCPInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *MaMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMGCPInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *MaMGCPInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *MaMGCPInterface) RemoveUseCase() { + _m.Called() +} + +// MaMGCPInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type MaMGCPInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *MaMGCPInterface_Expecter) RemoveUseCase() *MaMGCPInterface_RemoveUseCase_Call { + return &MaMGCPInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *MaMGCPInterface_RemoveUseCase_Call) Run(run func()) *MaMGCPInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMGCPInterface_RemoveUseCase_Call) Return() *MaMGCPInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMGCPInterface_RemoveUseCase_Call) RunAndReturn(run func()) *MaMGCPInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *MaMGCPInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// MaMGCPInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type MaMGCPInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *MaMGCPInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *MaMGCPInterface_UpdateUseCaseAvailability_Call { + return &MaMGCPInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *MaMGCPInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *MaMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *MaMGCPInterface_UpdateUseCaseAvailability_Call) Return() *MaMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMGCPInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *MaMGCPInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// VoltagePerPhase provides a mock function with given fields: entity +func (_m *MaMGCPInterface) VoltagePerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for VoltagePerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMGCPInterface_VoltagePerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VoltagePerPhase' +type MaMGCPInterface_VoltagePerPhase_Call struct { + *mock.Call +} + +// VoltagePerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMGCPInterface_Expecter) VoltagePerPhase(entity interface{}) *MaMGCPInterface_VoltagePerPhase_Call { + return &MaMGCPInterface_VoltagePerPhase_Call{Call: _e.mock.On("VoltagePerPhase", entity)} +} + +func (_c *MaMGCPInterface_VoltagePerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMGCPInterface_VoltagePerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMGCPInterface_VoltagePerPhase_Call) Return(_a0 []float64, _a1 error) *MaMGCPInterface_VoltagePerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMGCPInterface_VoltagePerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *MaMGCPInterface_VoltagePerPhase_Call { + _c.Call.Return(run) + return _c +} + +// NewMaMGCPInterface creates a new instance of MaMGCPInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMaMGCPInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MaMGCPInterface { + mock := &MaMGCPInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMPCInterface.go b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMPCInterface.go new file mode 100644 index 0000000..a3e5b8f --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/mocks/MaMPCInterface.go @@ -0,0 +1,752 @@ +// Code generated by mockery v2.43.2. DO NOT EDIT. + +package mocks + +import ( + eebus_goapi "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" + + spine_goapi "github.com/enbility/spine-go/api" +) + +// MaMPCInterface is an autogenerated mock type for the MaMPCInterface type +type MaMPCInterface struct { + mock.Mock +} + +type MaMPCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MaMPCInterface) EXPECT() *MaMPCInterface_Expecter { + return &MaMPCInterface_Expecter{mock: &_m.Mock} +} + +// AddFeatures provides a mock function with given fields: +func (_m *MaMPCInterface) AddFeatures() { + _m.Called() +} + +// MaMPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' +type MaMPCInterface_AddFeatures_Call struct { + *mock.Call +} + +// AddFeatures is a helper method to define mock.On call +func (_e *MaMPCInterface_Expecter) AddFeatures() *MaMPCInterface_AddFeatures_Call { + return &MaMPCInterface_AddFeatures_Call{Call: _e.mock.On("AddFeatures")} +} + +func (_c *MaMPCInterface_AddFeatures_Call) Run(run func()) *MaMPCInterface_AddFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMPCInterface_AddFeatures_Call) Return() *MaMPCInterface_AddFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMPCInterface_AddFeatures_Call) RunAndReturn(run func()) *MaMPCInterface_AddFeatures_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCase provides a mock function with given fields: +func (_m *MaMPCInterface) AddUseCase() { + _m.Called() +} + +// MaMPCInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' +type MaMPCInterface_AddUseCase_Call struct { + *mock.Call +} + +// AddUseCase is a helper method to define mock.On call +func (_e *MaMPCInterface_Expecter) AddUseCase() *MaMPCInterface_AddUseCase_Call { + return &MaMPCInterface_AddUseCase_Call{Call: _e.mock.On("AddUseCase")} +} + +func (_c *MaMPCInterface_AddUseCase_Call) Run(run func()) *MaMPCInterface_AddUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMPCInterface_AddUseCase_Call) Return() *MaMPCInterface_AddUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMPCInterface_AddUseCase_Call) RunAndReturn(run func()) *MaMPCInterface_AddUseCase_Call { + _c.Call.Return(run) + return _c +} + +// AvailableScenariosForEntity provides a mock function with given fields: entity +func (_m *MaMPCInterface) AvailableScenariosForEntity(entity spine_goapi.EntityRemoteInterface) []uint { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for AvailableScenariosForEntity") + } + + var r0 []uint + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []uint); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uint) + } + } + + return r0 +} + +// MaMPCInterface_AvailableScenariosForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AvailableScenariosForEntity' +type MaMPCInterface_AvailableScenariosForEntity_Call struct { + *mock.Call +} + +// AvailableScenariosForEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) AvailableScenariosForEntity(entity interface{}) *MaMPCInterface_AvailableScenariosForEntity_Call { + return &MaMPCInterface_AvailableScenariosForEntity_Call{Call: _e.mock.On("AvailableScenariosForEntity", entity)} +} + +func (_c *MaMPCInterface_AvailableScenariosForEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_AvailableScenariosForEntity_Call) Return(_a0 []uint) *MaMPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMPCInterface_AvailableScenariosForEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) []uint) *MaMPCInterface_AvailableScenariosForEntity_Call { + _c.Call.Return(run) + return _c +} + +// CurrentPerPhase provides a mock function with given fields: entity +func (_m *MaMPCInterface) CurrentPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for CurrentPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_CurrentPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentPerPhase' +type MaMPCInterface_CurrentPerPhase_Call struct { + *mock.Call +} + +// CurrentPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) CurrentPerPhase(entity interface{}) *MaMPCInterface_CurrentPerPhase_Call { + return &MaMPCInterface_CurrentPerPhase_Call{Call: _e.mock.On("CurrentPerPhase", entity)} +} + +func (_c *MaMPCInterface_CurrentPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_CurrentPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_CurrentPerPhase_Call) Return(_a0 []float64, _a1 error) *MaMPCInterface_CurrentPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_CurrentPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *MaMPCInterface_CurrentPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// EnergyConsumed provides a mock function with given fields: entity +func (_m *MaMPCInterface) EnergyConsumed(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyConsumed") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_EnergyConsumed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyConsumed' +type MaMPCInterface_EnergyConsumed_Call struct { + *mock.Call +} + +// EnergyConsumed is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) EnergyConsumed(entity interface{}) *MaMPCInterface_EnergyConsumed_Call { + return &MaMPCInterface_EnergyConsumed_Call{Call: _e.mock.On("EnergyConsumed", entity)} +} + +func (_c *MaMPCInterface_EnergyConsumed_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_EnergyConsumed_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_EnergyConsumed_Call) Return(_a0 float64, _a1 error) *MaMPCInterface_EnergyConsumed_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_EnergyConsumed_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMPCInterface_EnergyConsumed_Call { + _c.Call.Return(run) + return _c +} + +// EnergyProduced provides a mock function with given fields: entity +func (_m *MaMPCInterface) EnergyProduced(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for EnergyProduced") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_EnergyProduced_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyProduced' +type MaMPCInterface_EnergyProduced_Call struct { + *mock.Call +} + +// EnergyProduced is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) EnergyProduced(entity interface{}) *MaMPCInterface_EnergyProduced_Call { + return &MaMPCInterface_EnergyProduced_Call{Call: _e.mock.On("EnergyProduced", entity)} +} + +func (_c *MaMPCInterface_EnergyProduced_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_EnergyProduced_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_EnergyProduced_Call) Return(_a0 float64, _a1 error) *MaMPCInterface_EnergyProduced_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_EnergyProduced_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMPCInterface_EnergyProduced_Call { + _c.Call.Return(run) + return _c +} + +// Frequency provides a mock function with given fields: entity +func (_m *MaMPCInterface) Frequency(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Frequency") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_Frequency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Frequency' +type MaMPCInterface_Frequency_Call struct { + *mock.Call +} + +// Frequency is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) Frequency(entity interface{}) *MaMPCInterface_Frequency_Call { + return &MaMPCInterface_Frequency_Call{Call: _e.mock.On("Frequency", entity)} +} + +func (_c *MaMPCInterface_Frequency_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_Frequency_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_Frequency_Call) Return(_a0 float64, _a1 error) *MaMPCInterface_Frequency_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_Frequency_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMPCInterface_Frequency_Call { + _c.Call.Return(run) + return _c +} + +// IsCompatibleEntityType provides a mock function with given fields: entity +func (_m *MaMPCInterface) IsCompatibleEntityType(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsCompatibleEntityType") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MaMPCInterface_IsCompatibleEntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsCompatibleEntityType' +type MaMPCInterface_IsCompatibleEntityType_Call struct { + *mock.Call +} + +// IsCompatibleEntityType is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) IsCompatibleEntityType(entity interface{}) *MaMPCInterface_IsCompatibleEntityType_Call { + return &MaMPCInterface_IsCompatibleEntityType_Call{Call: _e.mock.On("IsCompatibleEntityType", entity)} +} + +func (_c *MaMPCInterface_IsCompatibleEntityType_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_IsCompatibleEntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_IsCompatibleEntityType_Call) Return(_a0 bool) *MaMPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMPCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *MaMPCInterface_IsCompatibleEntityType_Call { + _c.Call.Return(run) + return _c +} + +// IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario +func (_m *MaMPCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { + ret := _m.Called(entity, scenario) + + if len(ret) == 0 { + panic("no return value specified for IsScenarioAvailableAtEntity") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface, uint) bool); ok { + r0 = rf(entity, scenario) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MaMPCInterface_IsScenarioAvailableAtEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsScenarioAvailableAtEntity' +type MaMPCInterface_IsScenarioAvailableAtEntity_Call struct { + *mock.Call +} + +// IsScenarioAvailableAtEntity is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +// - scenario uint +func (_e *MaMPCInterface_Expecter) IsScenarioAvailableAtEntity(entity interface{}, scenario interface{}) *MaMPCInterface_IsScenarioAvailableAtEntity_Call { + return &MaMPCInterface_IsScenarioAvailableAtEntity_Call{Call: _e.mock.On("IsScenarioAvailableAtEntity", entity, scenario)} +} + +func (_c *MaMPCInterface_IsScenarioAvailableAtEntity_Call) Run(run func(entity spine_goapi.EntityRemoteInterface, scenario uint)) *MaMPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface), args[1].(uint)) + }) + return _c +} + +func (_c *MaMPCInterface_IsScenarioAvailableAtEntity_Call) Return(_a0 bool) *MaMPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMPCInterface_IsScenarioAvailableAtEntity_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface, uint) bool) *MaMPCInterface_IsScenarioAvailableAtEntity_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: entity +func (_m *MaMPCInterface) Power(entity spine_goapi.EntityRemoteInterface) (float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) (float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) float64); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type MaMPCInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) Power(entity interface{}) *MaMPCInterface_Power_Call { + return &MaMPCInterface_Power_Call{Call: _e.mock.On("Power", entity)} +} + +func (_c *MaMPCInterface_Power_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_Power_Call) Return(_a0 float64, _a1 error) *MaMPCInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_Power_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) (float64, error)) *MaMPCInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// PowerPerPhase provides a mock function with given fields: entity +func (_m *MaMPCInterface) PowerPerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for PowerPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_PowerPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerPerPhase' +type MaMPCInterface_PowerPerPhase_Call struct { + *mock.Call +} + +// PowerPerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) PowerPerPhase(entity interface{}) *MaMPCInterface_PowerPerPhase_Call { + return &MaMPCInterface_PowerPerPhase_Call{Call: _e.mock.On("PowerPerPhase", entity)} +} + +func (_c *MaMPCInterface_PowerPerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_PowerPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_PowerPerPhase_Call) Return(_a0 []float64, _a1 error) *MaMPCInterface_PowerPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_PowerPerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *MaMPCInterface_PowerPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// RemoteEntitiesScenarios provides a mock function with given fields: +func (_m *MaMPCInterface) RemoteEntitiesScenarios() []eebus_goapi.RemoteEntityScenarios { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteEntitiesScenarios") + } + + var r0 []eebus_goapi.RemoteEntityScenarios + if rf, ok := ret.Get(0).(func() []eebus_goapi.RemoteEntityScenarios); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]eebus_goapi.RemoteEntityScenarios) + } + } + + return r0 +} + +// MaMPCInterface_RemoteEntitiesScenarios_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteEntitiesScenarios' +type MaMPCInterface_RemoteEntitiesScenarios_Call struct { + *mock.Call +} + +// RemoteEntitiesScenarios is a helper method to define mock.On call +func (_e *MaMPCInterface_Expecter) RemoteEntitiesScenarios() *MaMPCInterface_RemoteEntitiesScenarios_Call { + return &MaMPCInterface_RemoteEntitiesScenarios_Call{Call: _e.mock.On("RemoteEntitiesScenarios")} +} + +func (_c *MaMPCInterface_RemoteEntitiesScenarios_Call) Run(run func()) *MaMPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMPCInterface_RemoteEntitiesScenarios_Call) Return(_a0 []eebus_goapi.RemoteEntityScenarios) *MaMPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MaMPCInterface_RemoteEntitiesScenarios_Call) RunAndReturn(run func() []eebus_goapi.RemoteEntityScenarios) *MaMPCInterface_RemoteEntitiesScenarios_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCase provides a mock function with given fields: +func (_m *MaMPCInterface) RemoveUseCase() { + _m.Called() +} + +// MaMPCInterface_RemoveUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCase' +type MaMPCInterface_RemoveUseCase_Call struct { + *mock.Call +} + +// RemoveUseCase is a helper method to define mock.On call +func (_e *MaMPCInterface_Expecter) RemoveUseCase() *MaMPCInterface_RemoveUseCase_Call { + return &MaMPCInterface_RemoveUseCase_Call{Call: _e.mock.On("RemoveUseCase")} +} + +func (_c *MaMPCInterface_RemoveUseCase_Call) Run(run func()) *MaMPCInterface_RemoveUseCase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MaMPCInterface_RemoveUseCase_Call) Return() *MaMPCInterface_RemoveUseCase_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMPCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *MaMPCInterface_RemoveUseCase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateUseCaseAvailability provides a mock function with given fields: available +func (_m *MaMPCInterface) UpdateUseCaseAvailability(available bool) { + _m.Called(available) +} + +// MaMPCInterface_UpdateUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateUseCaseAvailability' +type MaMPCInterface_UpdateUseCaseAvailability_Call struct { + *mock.Call +} + +// UpdateUseCaseAvailability is a helper method to define mock.On call +// - available bool +func (_e *MaMPCInterface_Expecter) UpdateUseCaseAvailability(available interface{}) *MaMPCInterface_UpdateUseCaseAvailability_Call { + return &MaMPCInterface_UpdateUseCaseAvailability_Call{Call: _e.mock.On("UpdateUseCaseAvailability", available)} +} + +func (_c *MaMPCInterface_UpdateUseCaseAvailability_Call) Run(run func(available bool)) *MaMPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *MaMPCInterface_UpdateUseCaseAvailability_Call) Return() *MaMPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *MaMPCInterface_UpdateUseCaseAvailability_Call) RunAndReturn(run func(bool)) *MaMPCInterface_UpdateUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// VoltagePerPhase provides a mock function with given fields: entity +func (_m *MaMPCInterface) VoltagePerPhase(entity spine_goapi.EntityRemoteInterface) ([]float64, error) { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for VoltagePerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) ([]float64, error)); ok { + return rf(entity) + } + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) []float64); ok { + r0 = rf(entity) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func(spine_goapi.EntityRemoteInterface) error); ok { + r1 = rf(entity) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MaMPCInterface_VoltagePerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VoltagePerPhase' +type MaMPCInterface_VoltagePerPhase_Call struct { + *mock.Call +} + +// VoltagePerPhase is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *MaMPCInterface_Expecter) VoltagePerPhase(entity interface{}) *MaMPCInterface_VoltagePerPhase_Call { + return &MaMPCInterface_VoltagePerPhase_Call{Call: _e.mock.On("VoltagePerPhase", entity)} +} + +func (_c *MaMPCInterface_VoltagePerPhase_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *MaMPCInterface_VoltagePerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *MaMPCInterface_VoltagePerPhase_Call) Return(_a0 []float64, _a1 error) *MaMPCInterface_VoltagePerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MaMPCInterface_VoltagePerPhase_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) ([]float64, error)) *MaMPCInterface_VoltagePerPhase_Call { + _c.Call.Return(run) + return _c +} + +// NewMaMPCInterface creates a new instance of MaMPCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMaMPCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MaMPCInterface { + mock := &MaMPCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/usecase/events.go b/src/eebus-bridge/third_party/eebus-go/usecases/usecase/events.go new file mode 100644 index 0000000..0bab5b4 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/usecase/events.go @@ -0,0 +1,123 @@ +package usecase + +import ( + "slices" + + "github.com/enbility/eebus-go/usecases/internal" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// handle SPINE events +func (u *UseCaseBase) HandleEvent(payload spineapi.EventPayload) { + if u.deviceOrEntityRemoved(payload) { + return + } + + switch payload.Data.(type) { + case *model.NodeManagementUseCaseDataType, + *model.NodeManagementDetailedDiscoveryDataType: + u.useCaseDataUpdate(payload) + default: + return + } +} + +func (u *UseCaseBase) deviceOrEntityRemoved(payload spineapi.EventPayload) bool { + if internal.IsDeviceDisconnected(payload) || internal.IsEntityDisconnected(payload) { + u.removeEntityFromAvailableEntityScenarios(payload.Entity) + return true + } + + return false +} + +func (u *UseCaseBase) useCaseDataUpdate( + payload spineapi.EventPayload, +) { + remoteDevice := payload.Device + + // go over the use cases and check which entity of the remote device supports the usecase + ucs := remoteDevice.UseCases() + for _, uc := range ucs { + if uc.Actor == nil || !slices.Contains(u.validActorTypes, *uc.Actor) { + continue + } + + for _, support := range uc.UseCaseSupport { + // UseCaseAvailable should only be checkd for client functionality + // of a use acse. But as there are devices (e.g. Porsche PMCC) that + // also use it for the server side, we need to check it always. + if support.UseCaseName == nil || + *support.UseCaseName != u.UseCaseName || + support.ScenarioSupport == nil && + len(support.ScenarioSupport) == 0 || + (support.UseCaseAvailable != nil && !*support.UseCaseAvailable) { + continue + } + + // TODO: check the version and compare them for compatibility, it may be required to provide a minimmal compatible version + // but then also the question is what to do if the version is newer + + entitiesToCheck := []spineapi.EntityRemoteInterface{} + + // if the address is given, use that for further checks + if uc.Address != nil { + ucEntity := remoteDevice.Entity(uc.Address.Entity) + // the PMCP EVSE reports EV use cases with the address of the EVSE + if *uc.Actor == model.UseCaseActorTypeEV && len(uc.Address.Entity) == 1 { + // add the EV subentity to the address + evAddress := append(uc.Address.Entity, 1) + ucEntity = remoteDevice.Entity(evAddress) + } + if ucEntity != nil { + entitiesToCheck = append(entitiesToCheck, ucEntity) + } + } + + // if no entity was defined/found, go over all known entities and search for one or multiple + if len(entitiesToCheck) == 0 { + entitiesToCheck = remoteDevice.Entities() + } + + for _, entity := range entitiesToCheck { + if !slices.Contains(u.validEntityTypes, entity.EntityType()) { + continue + } + + supportedScenarios := []model.UseCaseScenarioSupportType{} + + // go over each scenario this use case supports and check if the required server features are available + for _, scenario := range u.useCaseScenarios { + if !slices.Contains(support.ScenarioSupport, scenario.Scenario) { + continue + } + + // check if the required server features are available + requiredServerFeatures := u.requiredServerFeaturesForScenario(scenario.Scenario) + foundMatchingServerFeatures := []model.FeatureTypeType{} + for _, feature := range entity.Features() { + if feature.Role() != model.RoleTypeServer || + !slices.Contains(requiredServerFeatures, feature.Type()) { + continue + } + + foundMatchingServerFeatures = append(foundMatchingServerFeatures, feature.Type()) + } + + // check if the minimum required server features are available + slices.Sort(foundMatchingServerFeatures) + slices.Sort(requiredServerFeatures) + + if slices.Compare(requiredServerFeatures, foundMatchingServerFeatures) != 0 { + continue + } + + supportedScenarios = append(supportedScenarios, scenario.Scenario) + } + + u.updateRemoteEntityScenarios(entity, supportedScenarios) + } + } + } +} diff --git a/src/eebus-bridge/third_party/eebus-go/usecases/usecase/usecase.go b/src/eebus-bridge/third_party/eebus-go/usecases/usecase/usecase.go new file mode 100644 index 0000000..863f7b0 --- /dev/null +++ b/src/eebus-bridge/third_party/eebus-go/usecases/usecase/usecase.go @@ -0,0 +1,200 @@ +package usecase + +import ( + "reflect" + "slices" + "sync" + + "github.com/enbility/eebus-go/api" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" +) + +type UseCaseBase struct { + LocalEntity spineapi.EntityLocalInterface + + UseCaseActor model.UseCaseActorType + UseCaseName model.UseCaseNameType + useCaseVersion model.SpecificationVersionType + useCaseDocumentSubVersion string + useCaseScenarios []api.UseCaseScenario + + EventCB api.EntityEventCallback + useCaseUpdateEvent api.EventType + + availableEntityScenarios []api.RemoteEntityScenarios // map of scenarios and their availability for each compatible remote entity + + validActorTypes []model.UseCaseActorType // valid remote actor types for this use case + validEntityTypes []model.EntityTypeType // valid remote entity types for this use case + + mux sync.Mutex +} + +var _ api.UseCaseBaseInterface = (*UseCaseBase)(nil) + +func NewUseCaseBase( + localEntity spineapi.EntityLocalInterface, + usecaseActor model.UseCaseActorType, + usecaseName model.UseCaseNameType, + useCaseVersion string, + useCaseDocumentSubVersion string, + useCaseScenarios []api.UseCaseScenario, + eventCB api.EntityEventCallback, + useCaseUpdateEvent api.EventType, + validActorTypes []model.UseCaseActorType, + validEntityTypes []model.EntityTypeType, +) *UseCaseBase { + ucb := &UseCaseBase{ + LocalEntity: localEntity, + UseCaseActor: usecaseActor, + UseCaseName: usecaseName, + useCaseVersion: model.SpecificationVersionType(useCaseVersion), + useCaseDocumentSubVersion: useCaseDocumentSubVersion, + useCaseScenarios: useCaseScenarios, + EventCB: eventCB, + useCaseUpdateEvent: useCaseUpdateEvent, + validActorTypes: validActorTypes, + validEntityTypes: validEntityTypes, + } + + _ = spine.Events.Subscribe(ucb) + + return ucb +} + +func (u *UseCaseBase) AddUseCase() { + useCaseScenarios := []model.UseCaseScenarioSupportType{} + for _, scenario := range u.useCaseScenarios { + useCaseScenarios = append(useCaseScenarios, scenario.Scenario) + } + + u.LocalEntity.AddUseCaseSupport( + u.UseCaseActor, + u.UseCaseName, + u.useCaseVersion, + u.useCaseDocumentSubVersion, + true, + useCaseScenarios) +} + +func (u *UseCaseBase) RemoveUseCase() { + u.LocalEntity.RemoveUseCaseSupport(u.UseCaseActor, u.UseCaseName) +} + +func (u *UseCaseBase) UpdateUseCaseAvailability(available bool) { + u.LocalEntity.SetUseCaseAvailability(u.UseCaseActor, u.UseCaseName, available) +} + +func (u *UseCaseBase) IsCompatibleEntityType(entity spineapi.EntityRemoteInterface) bool { + if entity == nil { + return false + } + + return slices.Contains(u.validEntityTypes, entity.EntityType()) +} + +// return the current list of compatible remote entities and their scenarios +func (u *UseCaseBase) RemoteEntitiesScenarios() []api.RemoteEntityScenarios { + u.mux.Lock() + defer u.mux.Unlock() + + return u.availableEntityScenarios +} + +// return the currently available scenarios for the use case for a remote entity +func (u *UseCaseBase) AvailableScenariosForEntity(entity spineapi.EntityRemoteInterface) []uint { + _, scenarios := u.indexAndScenariosOfEntity(entity) + + return scenarios +} + +// check if the provided scenario are available at the remote entity +func (u *UseCaseBase) IsScenarioAvailableAtEntity( + entity spineapi.EntityRemoteInterface, + scenario uint, +) bool { + if _, scenarios := u.indexAndScenariosOfEntity(entity); scenarios != nil { + return slices.Contains(scenarios, scenario) + } + + return false +} + +// return the index and the scenarios of the entity in the available entity scenarios +// and return -1 and nil if not found +func (u *UseCaseBase) indexAndScenariosOfEntity(entity spineapi.EntityRemoteInterface) (int, []uint) { + u.mux.Lock() + defer u.mux.Unlock() + + for i, remoteEntity := range u.availableEntityScenarios { + if entity != nil && entity.Address() != nil && remoteEntity.Entity.Address() != nil && + reflect.DeepEqual(entity.Address().Device, remoteEntity.Entity.Address().Device) && + reflect.DeepEqual(entity.Address().Entity, remoteEntity.Entity.Address().Entity) { + return i, remoteEntity.Scenarios + } + } + + return -1, nil +} + +// set the scenarios of a remote entity +func (u *UseCaseBase) updateRemoteEntityScenarios( + entity spineapi.EntityRemoteInterface, + scenarios []model.UseCaseScenarioSupportType, +) { + updateEvent := false + + scenarioValues := []uint{} + for _, scenario := range scenarios { + scenarioValues = append(scenarioValues, uint(scenario)) + } + + i, _ := u.indexAndScenariosOfEntity(entity) + if i == -1 { + newItem := api.RemoteEntityScenarios{ + Entity: entity, + Scenarios: scenarioValues, + } + + u.mux.Lock() + u.availableEntityScenarios = append(u.availableEntityScenarios, newItem) + u.mux.Unlock() + + updateEvent = true + } else if i >= 0 && slices.Compare(u.availableEntityScenarios[i].Scenarios, scenarioValues) != 0 { + u.mux.Lock() + u.availableEntityScenarios[i].Scenarios = scenarioValues + u.mux.Unlock() + + updateEvent = true + } + + if updateEvent && u.EventCB != nil { + u.EventCB(entity.Device().Ski(), entity.Device(), entity, u.useCaseUpdateEvent) + } +} + +// remove a remote entity from the use case +func (u *UseCaseBase) removeEntityFromAvailableEntityScenarios(entity spineapi.EntityRemoteInterface) { + if i, _ := u.indexAndScenariosOfEntity(entity); i >= 0 { + u.mux.Lock() + u.availableEntityScenarios = append(u.availableEntityScenarios[:i], u.availableEntityScenarios[i+1:]...) + u.mux.Unlock() + + if u.EventCB != nil { + u.EventCB(entity.Device().Ski(), entity.Device(), entity, u.useCaseUpdateEvent) + } + } +} + +// return the required server features for a use case scenario +func (u *UseCaseBase) requiredServerFeaturesForScenario(scenario model.UseCaseScenarioSupportType) []model.FeatureTypeType { + for _, serverFeatures := range u.useCaseScenarios { + if serverFeatures.Scenario == scenario { + return serverFeatures.ServerFeatures + } + } + + return nil +} diff --git a/src/eebus-bridge/third_party/go.work b/src/eebus-bridge/third_party/go.work new file mode 100644 index 0000000..b2b3662 --- /dev/null +++ b/src/eebus-bridge/third_party/go.work @@ -0,0 +1,15 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as the +// modules here. +// The patched copies as one workspace, for their own tests (go test inside +// one of them builds it against the other two patched copies, not the +// published modules). The bridge itself uses them through its go.mod's +// replace; this file is not in its parent directories, so it doesn't apply +// to the bridge's build. + +go 1.22.0 + +use ( + ./eebus-go + ./ship-go + ./spine-go +) diff --git a/src/eebus-bridge/third_party/ship-go/LICENSE b/src/eebus-bridge/third_party/ship-go/LICENSE new file mode 100644 index 0000000..56a7aad --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/LICENSE @@ -0,0 +1,22 @@ +MIT license + +Copyright (c) 2022 Andreas Linde & Timo Vogel +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/eebus-bridge/third_party/ship-go/PATCHES.md b/src/eebus-bridge/third_party/ship-go/PATCHES.md new file mode 100644 index 0000000..eff2472 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/PATCHES.md @@ -0,0 +1,26 @@ +# ship-go v0.6.0, patched + +This directory is [enbility/ship-go](https://github.com/enbility/ship-go) at +v0.6.0 (the module as published, without its tests, mocks and CI files), with +the fixes below. The original is MIT-licensed (LICENSE, unchanged). The +modifications are Copyright © 2026 Setti Solutions S.R.L, www.setti.md, and +are published under the same MIT licence. The EEBUS bridge uses this copy +through a `replace` in its go.mod; drop it when a ship-go release has these +fixes (v0.6.0 is the latest release as of 2026-11-13; the `dev` branch +reworks these parts, unreleased). + +| File | Change | +|---|---| +| `ws/websocket.go` | `shipWriteChannel` is never closed; the write pump closes `writePumpDone` when it ends, and `WriteMessageToWebsocketConnection` selects on it. Before, a writer that had passed the closed check sent on the channel the pump had just closed (`panic: send on closed channel`, seen when a double connection was closed in mid-handshake), or blocked forever once the pump was gone. | +| `ws/websocket.go` | `close()` always closes the close channel and the socket once. Before, it returned early when a read or write error had already marked the connection closed, and the socket stayed open. | +| `ws/websocket.go` | The read and write pumps recover a panic (theirs or a handler's they called, e.g. SPINE's): logged, the connection closed and reported as a connection error, so only this connection ends. | +| `mdns/mdns.go` | The provider is read and used under a read lock, replaced under the write lock (Start, Shutdown). Before, `AnnounceMdnsEntry`/`UnannounceMdnsEntry` of a closing connection (`Hub.checkAutoReannounce`) could find the provider set to nil by `Shutdown` between the check and the call (nil pointer dereference), or use it after its own `Shutdown`. Nothing is reported after `Shutdown`; a `Shutdown` during `Start` shuts the new provider down. | +| `hub/hub_connections.go`, `hub/hub_shipconnection.go` | A registered connection whose data connection is already closed doesn't count as connected: `connectionForSKI` (and so `isSkiConnected`) drops it. A connection is registered after it starts running; one that ended at once (a double connection the remote closed in mid-handshake) reported its close while not yet registered, then stayed in the map: the SKI counted as connected for ever, was never dialled again, and its incoming connections were refused as double connections (a paired device that never came back). `HandleConnectionClosed` compares with the registered connection, closed or not; resets the attempt counter after a completed handshake even when the connection was already dropped from the map; and reports `RemoteSKIDisconnected` unless another connection set up the SKI's current SPINE device (`skiDevice`, recorded by `SetupRemoteDevice`; the decision, the setup and their callbacks under one lock per SKI, so a twin's close can't remove a device set up a moment before, and other SKIs' connections never wait for them). `SetupRemoteDevice` reports the SKI connected only when a close reported it disconnected since the last connected report (`ReportServiceShipID` answers it; otherwise connected came with the SHIP ID; an idle SKI's entry, with no device and no live connection, is dropped; before this, the device stayed offline after a twin's close mid-handshake): the closing side of a double connection made SPINE remove the device by SKI, with the kept connection's bindings and subscriptions (every later write refused: "write denied due to missing binding"). | +| `hub/hub.go` | `Shutdown` closes a copy of the connections taken under `muxCon` (before: the map was ranged without the lock while connections registered or removed themselves). | +| `ship/connection.go` | `sendSpineData` and `shipMessage` close the SHIP connection on a new goroutine when they find the data connection closed. Before, the close ran on the writer's goroutine: SPINE writes (a notify to subscribers) while holding its feature's locks, and the close, inside its `sync.Once`, reports up into SPINE (`HandleConnectionClosed`) on another goroutine that needed those locks: a deadlock (seen as a hang under load). And `CloseConnection`'s own close announcement reached `shipMessage` inside that `Once`. | +| `ship/hs_hello.go`, `ship/types.go` | A connection waiting for trust (hello `PENDING_LISTEN`) checks every 0.5 s whether the remote service has become trusted and then approves itself. `Hub.RegisterRemoteSKI` approves only the connection registered for the SKI; with a double connection that can be the other one, closed a moment later, and this one waited the whole hello timeout (60 s) with the device offline. Every transition out of `PENDING_LISTEN` and `READY_LISTEN` (the approval, the abort, the read pump's and the hello timer's) is a check-and-set of the state (`changeState`, `leaveState` in `handshake.go`): of several at once only the first moves on, "ready" is sent once, and an approval can't act after the remote's abort. The approval's HELLO_OK is that check-and-set from `READY_LISTEN` too. A handshake timer acts only if it is still the current one (a generation, bumped by every arming and stop): one that fired while an approval moved the state on no longer times the new state out. | +| `ship/handshake.go` | The handshake timer's goroutine recovers a panic: logged, the connection closed. | + +Tests: `ws/websocket_close_test.go`, `mdns/mdns_shutdown_test.go`, +`hub/hub_stale_test.go`, `ship/hs_hello_trust_test.go` +(`go test -race ./ws ./mdns ./hub ./ship` in this directory). diff --git a/src/eebus-bridge/third_party/ship-go/api/connectionstate.go b/src/eebus-bridge/third_party/ship-go/api/connectionstate.go new file mode 100644 index 0000000..f7b58da --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/connectionstate.go @@ -0,0 +1,71 @@ +package api + +import ( + "errors" + "sync" +) + +// connection state for global usage, e.g. UI +type ConnectionState uint + +const ( + ConnectionStateNone ConnectionState = iota // The initial state, when no pairing exists + ConnectionStateQueued // The connection request has been started and is pending connection initialization + ConnectionStateInitiated // This service initiated the connection process + ConnectionStateReceivedPairingRequest // A remote service initiated the connection process + ConnectionStateInProgress // The connection handshake is in progress + ConnectionStateTrusted // The connection is trusted on both ends + ConnectionStatePin // PIN processing, not supported right now! + ConnectionStateCompleted // The connection handshake is completed from both ends + ConnectionStateRemoteDeniedTrust // The remote service denied trust + ConnectionStateError // The connection handshake resulted in an error +) + +// the connection state of a service and error if applicable +type ConnectionStateDetail struct { + state ConnectionState + error error + + mux sync.Mutex +} + +func NewConnectionStateDetail(state ConnectionState, err error) *ConnectionStateDetail { + return &ConnectionStateDetail{ + state: state, + error: err, + } +} + +func (c *ConnectionStateDetail) State() ConnectionState { + c.mux.Lock() + defer c.mux.Unlock() + + return c.state +} + +func (c *ConnectionStateDetail) SetState(state ConnectionState) { + c.mux.Lock() + defer c.mux.Unlock() + + c.state = state +} + +func (c *ConnectionStateDetail) Error() error { + c.mux.Lock() + defer c.mux.Unlock() + + return c.error +} + +func (c *ConnectionStateDetail) SetError(err error) { + c.mux.Lock() + defer c.mux.Unlock() + + c.error = err +} + +// ErrServiceNotPaired if the given SKI is not paired yet +var ErrServiceNotPaired = errors.New("the provided SKI is not paired") + +// ErrConnectionNotFound that there was no active connection for a given SKI found +var ErrConnectionNotFound = errors.New("no connection for provided SKI found") diff --git a/src/eebus-bridge/third_party/ship-go/api/hub.go b/src/eebus-bridge/third_party/ship-go/api/hub.go new file mode 100644 index 0000000..75ccfe9 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/hub.go @@ -0,0 +1,68 @@ +package api + +//go:generate mockery +//go:generate mockgen -destination=../mocks/mockgen_api.go -package=mocks github.com/enbility/ship-go/api MdnsInterface,HubReaderInterface + +/* Hub */ + +// Interface for handling the server and remote connections +type HubInterface interface { + // Start the ConnectionsHub with all its services + Start() + + // close all connections + Shutdown() + + // return the service for a SKI + ServiceForSKI(ski string) *ServiceDetails + + // Provide the current pairing state for a SKI + PairingDetailForSki(ski string) *ConnectionStateDetail + + // Enables or disables to automatically accept incoming pairing and connection requests + // + // Default: false + SetAutoAccept(bool) + + // Pair with the SKI + RegisterRemoteSKI(ski string) + + // Unpair the SKI + UnregisterRemoteSKI(ski string) + + // Disconnect a connection to an SKI + DisconnectSKI(ski string, reason string) + + // Cancels the pairing process for a SKI + CancelPairingWithSKI(ski string) +} + +// Interface to pass information from the hub to the eebus service +// +// Implemented by eebus service implementation, used by Hub +type HubReaderInterface interface { + // report a connection to a SKI + RemoteSKIConnected(ski string) + + // report a disconnection to a SKI + RemoteSKIDisconnected(ski string) + + // report an approved handshake by a remote device + SetupRemoteDevice(ski string, writeI ShipConnectionDataWriterInterface) ShipConnectionDataReaderInterface + + // report all currently visible EEBUS services + VisibleRemoteServicesUpdated(entries []RemoteService) + + // Provides the SHIP ID the remote service reported during the handshake process + // This needs to be persisted and passed on for future remote service connections + // when using `PairRemoteService` + ServiceShipIDUpdate(ski string, shipdID string) + + // Provides the current pairing state for the remote service + // This is called whenever the state changes and can be used to + // provide user information for the pairing/connection process + ServicePairingDetailUpdate(ski string, detail *ConnectionStateDetail) + + // return if the user is still able to trust the connection + AllowWaitingForTrust(ski string) bool +} diff --git a/src/eebus-bridge/third_party/ship-go/api/mdns.go b/src/eebus-bridge/third_party/ship-go/api/mdns.go new file mode 100644 index 0000000..c4be081 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/mdns.go @@ -0,0 +1,45 @@ +package api + +import "net" + +/* Mdns */ + +type MdnsEntry struct { + Name string + Ski string + Identifier string // mandatory + Path string // mandatory + Register bool // mandatory + Brand string // optional + Type string // optional + Model string // optional + Host string // mandatory + Port int // mandatory + Addresses []net.IP // mandatory +} + +// implemented by Hub, used by mdns +type MdnsReportInterface interface { + ReportMdnsEntries(entries map[string]*MdnsEntry, newEntries bool) +} + +// implemented by mdns, used by Hub +type MdnsInterface interface { + Start(cb MdnsReportInterface) error + Shutdown() + AnnounceMdnsEntry() error + UnannounceMdnsEntry() + SetAutoAccept(bool) + RequestMdnsEntries() +} + +// implemented by mdns, used by Providers +type MdnsResolveCB func(elements map[string]string, name, host string, addresses []net.IP, port int, remove bool) + +// implemented by mdns providers, used by mdns +type MdnsProviderInterface interface { + Start(autoReconnect bool, cb MdnsResolveCB) bool + Shutdown() + Announce(serviceName string, port int, txt []string) error + Unannounce() +} diff --git a/src/eebus-bridge/third_party/ship-go/api/remoteservice.go b/src/eebus-bridge/third_party/ship-go/api/remoteservice.go new file mode 100644 index 0000000..cc6eb65 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/remoteservice.go @@ -0,0 +1,10 @@ +package api + +type RemoteService struct { + Name string `json:"name"` + Ski string `json:"ski"` + Identifier string `json:"identifier"` + Brand string `json:"brand"` + Type string `json:"type"` + Model string `json:"model"` +} diff --git a/src/eebus-bridge/third_party/ship-go/api/servicedetails.go b/src/eebus-bridge/third_party/ship-go/api/servicedetails.go new file mode 100644 index 0000000..2dc1094 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/servicedetails.go @@ -0,0 +1,143 @@ +package api + +import ( + "sync" + + "github.com/enbility/ship-go/util" +) + +// generic service details about the local or any remote service +type ServiceDetails struct { + // This is the SKI of the service + // This needs to be persisted + ski string + + // This is the IPv4 address of the device running the service + // This is optional only needed when this runs with + // zeroconf as mDNS and the remote device is using the latest + // avahi version and thus zeroconf can sometimes not detect + // the IPv4 address and not initiate a connection + ipv4 string + + // shipID is the SHIP identifier of the service + // This needs to be persisted + shipID string + + // The EEBUS device type of the device model + deviceType string + + // Flags if the service auto accepts other services + autoAccept bool + + // Flags if the service is trusted and should be reconnected to + // Should be enabled after the connection process resulted + // ConnectionStateDetail == ConnectionStateTrusted the first time + trusted bool + + // the current connection state details + connectionStateDetail *ConnectionStateDetail + + mux sync.Mutex +} + +// create a new ServiceDetails record with a SKI +func NewServiceDetails(ski string) *ServiceDetails { + connState := NewConnectionStateDetail(ConnectionStateNone, nil) + service := &ServiceDetails{ + ski: util.NormalizeSKI(ski), // standardize the provided SKI strings + connectionStateDetail: connState, + } + + return service +} + +func (s *ServiceDetails) SKI() string { + s.mux.Lock() + defer s.mux.Unlock() + + return s.ski +} + +func (s *ServiceDetails) IPv4() string { + s.mux.Lock() + defer s.mux.Unlock() + + return s.ipv4 +} + +func (s *ServiceDetails) SetIPv4(ipv4 string) { + s.mux.Lock() + defer s.mux.Unlock() + + s.ipv4 = ipv4 +} + +func (s *ServiceDetails) ShipID() string { + s.mux.Lock() + defer s.mux.Unlock() + + return s.shipID +} + +func (s *ServiceDetails) SetShipID(shipid string) { + s.mux.Lock() + defer s.mux.Unlock() + + s.shipID = shipid +} + +func (s *ServiceDetails) DeviceType() string { + s.mux.Lock() + defer s.mux.Unlock() + + return s.deviceType +} + +func (s *ServiceDetails) SetDeviceType(deviceType string) { + s.mux.Lock() + defer s.mux.Unlock() + + s.deviceType = deviceType +} + +func (s *ServiceDetails) AutoAccept() bool { + s.mux.Lock() + defer s.mux.Unlock() + + return s.autoAccept +} + +func (s *ServiceDetails) SetAutoAccept(value bool) { + s.mux.Lock() + defer s.mux.Unlock() + + s.autoAccept = value +} + +func (s *ServiceDetails) Trusted() bool { + s.mux.Lock() + defer s.mux.Unlock() + + return s.trusted +} + +func (s *ServiceDetails) SetTrusted(trust bool) { + s.mux.Lock() + defer s.mux.Unlock() + + s.trusted = trust +} + +func (s *ServiceDetails) ConnectionStateDetail() *ConnectionStateDetail { + s.mux.Lock() + defer s.mux.Unlock() + + return s.connectionStateDetail +} + +func (s *ServiceDetails) SetConnectionStateDetail(detail *ConnectionStateDetail) { + s.mux.Lock() + defer s.mux.Unlock() + + s.connectionStateDetail = detail +} diff --git a/src/eebus-bridge/third_party/ship-go/api/shipconnection.go b/src/eebus-bridge/third_party/ship-go/api/shipconnection.go new file mode 100644 index 0000000..2ddc207 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/shipconnection.go @@ -0,0 +1,56 @@ +package api + +import ( + "github.com/enbility/ship-go/model" +) + +/* ShipConnection */ + +type ShipConnectionInterface interface { + DataHandler() WebsocketDataWriterInterface + CloseConnection(safe bool, code int, reason string) + RemoteSKI() string + ApprovePendingHandshake() + AbortPendingHandshake() + ShipHandshakeState() (model.ShipMessageExchangeState, error) +} + +// interface for getting service wide information +// +// implemented by Hub, used by shipConnection +type ShipConnectionInfoProviderInterface interface { + // check if the SKI is paired + IsRemoteServiceForSKIPaired(string) bool + + // check if auto accept is true + IsAutoAcceptEnabled() bool + + // report closing of a connection and if handshake did complete + HandleConnectionClosed(ShipConnectionInterface, bool) + + // report the ship ID provided during the handshake + ReportServiceShipID(string, string) + + // check if the user is still able to trust the connection + AllowWaitingForTrust(string) bool + + // report the updated SHIP handshake state and optional error message for a SKI + HandleShipHandshakeStateUpdate(string, model.ShipState) + + // report an approved handshake by a remote device + SetupRemoteDevice(ski string, writeI ShipConnectionDataWriterInterface) ShipConnectionDataReaderInterface +} + +// Used to pass an outgoing SPINE message from a DeviceLocal to the SHIP connection +// +// Implemented by ShipConnection, used by spine DeviceLocal +type ShipConnectionDataWriterInterface interface { + WriteShipMessageWithPayload(message []byte) +} + +// Used to pass an incoming SPINE message from a SHIP connection to the proper DeviceRemote +// +// Implemented by spine DeviceRemote, used by ShipConnection +type ShipConnectionDataReaderInterface interface { + HandleShipPayloadMessage(message []byte) +} diff --git a/src/eebus-bridge/third_party/ship-go/api/websocket.go b/src/eebus-bridge/third_party/ship-go/api/websocket.go new file mode 100644 index 0000000..208e659 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/api/websocket.go @@ -0,0 +1,34 @@ +package api + +/* WebsocketConnection */ + +// interface for handling the actual remote device data connection +// +// implemented by websocketConnection, used by ShipConnection +type WebsocketDataWriterInterface interface { + // initialize data processing + InitDataProcessing(WebsocketDataReaderInterface) + + // send data via the connection to the remote device + WriteMessageToWebsocketConnection([]byte) error + + // close the data connection + CloseDataConnection(closeCode int, reason string) + + // report if the data connection is closed and the error if availab le + IsDataConnectionClosed() (bool, error) +} + +// interface for handling incoming data +// +// implemented by shipConnection, used by websocketConnection +type WebsocketDataReaderInterface interface { + // called for each incoming message + HandleIncomingWebsocketMessage([]byte) + + // called if the data connection is closed unsafe + // e.g. due to connection issues + ReportConnectionError(error) +} + +const ShipWebsocketSubProtocol = "ship" // SHIP 10.2: sub protocol is required for websocket connections diff --git a/src/eebus-bridge/third_party/ship-go/cert/cert.go b/src/eebus-bridge/third_party/ship-go/cert/cert.go new file mode 100644 index 0000000..c396115 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/cert/cert.go @@ -0,0 +1,94 @@ +package cert + +//nolint:gosec +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/sha1" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "errors" + "fmt" + "math/big" + "time" +) // #nosec G505 + +// SHIP 9.1: the ciphers are reported insecure but are defined to be used by SHIP +var CipherSuites = []uint16{ + tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, // SHIP 9.1: required cipher suite + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, // SHIP 9.1: optional cipher suite +} + +// Create a ship compatible self signed certificate +// organizationalUnit is the OU of the certificate +// organization is the O of the certificate +// country is the C of the certificate +// commonName is the CN of the certificate +// Example for commonName: "deviceModel-deviceSerialNumber" +func CreateCertificate(organizationalUnit, organization, country, commonName string) (tls.Certificate, error) { + privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if err != nil { + return tls.Certificate{}, err + } + + // Create the EEBUS service SKI using the public key + publicKey, err := privateKey.PublicKey.ECDH() + if err != nil { + return tls.Certificate{}, err + } + // SHIP 12.2: Required to be created according to RFC 3280 4.2.1.2 + // #nosec G401 + ski := sha1.Sum(publicKey.Bytes()) + + subject := pkix.Name{ + OrganizationalUnit: []string{organizationalUnit}, + Organization: []string{organization}, + Country: []string{country}, + CommonName: commonName, + } + + // Create a random serial big int value + maxValue := new(big.Int) + maxValue.Exp(big.NewInt(2), big.NewInt(130), nil).Sub(maxValue, big.NewInt(1)) + serialNumber, err := rand.Int(rand.Reader, maxValue) + if err != nil { + return tls.Certificate{}, err + } + + template := x509.Certificate{ + SignatureAlgorithm: x509.ECDSAWithSHA256, + SerialNumber: serialNumber, + Subject: subject, + NotBefore: time.Now(), // Valid starting now + NotAfter: time.Now().Add(time.Hour * 24 * 365 * 10), // Valid for 10 years + KeyUsage: x509.KeyUsageDigitalSignature, + BasicConstraintsValid: true, + IsCA: true, + SubjectKeyId: ski[:], + } + + certBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &privateKey.PublicKey, privateKey) + if err != nil { + return tls.Certificate{}, err + } + + tlsCertificate := tls.Certificate{ + Certificate: [][]byte{certBytes}, + PrivateKey: privateKey, + SupportedSignatureAlgorithms: []tls.SignatureScheme{tls.ECDSAWithP256AndSHA256}, + } + + return tlsCertificate, nil +} + +func SkiFromCertificate(cert *x509.Certificate) (string, error) { + // check if the clients certificate provides a SKI + subjectKeyId := cert.SubjectKeyId + if len(subjectKeyId) != 20 { + return "", errors.New("Client certificate does not provide a SKI") + } + + return fmt.Sprintf("%0x", subjectKeyId), nil +} diff --git a/src/eebus-bridge/third_party/ship-go/go.mod b/src/eebus-bridge/third_party/ship-go/go.mod new file mode 100644 index 0000000..7b8903c --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/go.mod @@ -0,0 +1,26 @@ +module github.com/enbility/ship-go + +go 1.22.0 + +require ( + github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a + github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 + github.com/gorilla/websocket v1.5.3 + github.com/stretchr/testify v1.9.0 + gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a + go.uber.org/mock v0.4.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/godbus/dbus/v5 v5.1.0 // indirect + github.com/miekg/dns v1.1.62 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/tools v0.25.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/src/eebus-bridge/third_party/ship-go/go.sum b/src/eebus-bridge/third_party/ship-go/go.sum new file mode 100644 index 0000000..c1c7b07 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/go.sum @@ -0,0 +1,36 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a h1:foChWb8lhzqa6lWDRs6COYMdp649YlUirFP8GqoT0JQ= +github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a/go.mod h1:H64mhYcAQUGUUnVqMdZQf93kPecH4M79xwH95Lddt3U= +github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 h1:XOYvxKtT1oxT37w/5oEiRLuPbm9FuJPt3fiYhX0h8Po= +github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6/go.mod h1:BszP9qFV14mPXgyIREbgIdQtWxbAj3OKqvK02HihMoM= +github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= +github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= +github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a h1:DxppxFKRqJ8WD6oJ3+ZXKDY0iMONQDl5UTg2aTyHh8k= +gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a/go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= +golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub.go b/src/eebus-bridge/third_party/ship-go/hub/hub.go new file mode 100644 index 0000000..9a669f3 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub.go @@ -0,0 +1,187 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: Shutdown closes a copy of the connections taken under their lock; +// deviceOwner. + +package hub + +import ( + "context" + "crypto/tls" + "net/http" + "sync" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/util" +) + +// used for randomizing the connection initiation delay +// this limits the possibility of concurrent connection attempts from both sides +type connectionInitiationDelayTimeRange struct { + // defines the minimum and maximum wait time for when to try to initate an connection + min, max int +} + +// defines the delay timeframes in seconds depening on the connection attempt counter +// the last item will be re-used for higher attempt counter values +var connectionInitiationDelayTimeRanges = []connectionInitiationDelayTimeRange{ + {min: 0, max: 3}, + {min: 3, max: 10}, + {min: 10, max: 20}, +} + +// handling the server and all connections to remote services +type Hub struct { + connections map[string]api.ShipConnectionInterface + + // which attempt is it to initate an connection to the remote SKI + connectionAttemptCounter map[string]int + connectionAttemptRunning map[string]bool + + port int + certifciate tls.Certificate + + localService *api.ServiceDetails + + hubReader api.HubReaderInterface + + autoaccept bool + + // The list of known remote services + remoteServices map[string]*api.ServiceDetails + + // The web server for handling incoming websocket connections + httpServer *http.Server + + // Handling mDNS related tasks + mdns api.MdnsInterface + + // list of currently known/reported mDNS entries + knownMdnsEntries []*api.MdnsEntry + + hasStarted bool + + muxCon sync.Mutex + muxConAttempt sync.Mutex + muxReg sync.Mutex + muxMdns sync.Mutex + muxStarted sync.Mutex + + // per SKI: the connection whose SPINE device is current, with its own + // lock around SetupRemoteDevice and HandleConnectionClosed (muxDevice + // guards only the map) + deviceOwner map[string]*skiDevice + muxDevice sync.Mutex +} + +func NewHub(hubReader api.HubReaderInterface, + mdns api.MdnsInterface, + port int, + certificate tls.Certificate, + localService *api.ServiceDetails) *Hub { + hub := &Hub{ + connections: make(map[string]api.ShipConnectionInterface), + connectionAttemptCounter: make(map[string]int), + connectionAttemptRunning: make(map[string]bool), + remoteServices: make(map[string]*api.ServiceDetails), + knownMdnsEntries: make([]*api.MdnsEntry, 0), + hubReader: hubReader, + port: port, + certifciate: certificate, + localService: localService, + mdns: mdns, + } + + return hub +} + +var _ api.HubInterface = (*Hub)(nil) + +// Start the ConnectionsHub with all its services +func (h *Hub) Start() { + h.muxStarted.Lock() + h.hasStarted = true + h.muxStarted.Unlock() + + // start the websocket server + if err := h.startWebsocketServer(); err != nil { + logging.Log().Debug("error during websocket server starting:", err) + } + + // start mDNS + err := h.mdns.Start(h) + if err != nil { + logging.Log().Debug("error during mdns setup:", err) + } +} + +// close all connections +func (h *Hub) Shutdown() { + h.mdns.Shutdown() + // a copy: closing a connection removes it from the map (and others + // may still register or close meanwhile) + h.muxCon.Lock() + connections := make([]api.ShipConnectionInterface, 0, len(h.connections)) + for _, c := range h.connections { + connections = append(connections, c) + } + h.muxCon.Unlock() + for _, c := range connections { + c.CloseConnection(false, 0, "") + } + if h.httpServer == nil { + return + } + if err := h.httpServer.Shutdown(context.Background()); err != nil { + logging.Log().Error("HTTP server shutdown:", err) + } +} + +// return the service for a SKI +func (h *Hub) ServiceForSKI(ski string) *api.ServiceDetails { + h.muxReg.Lock() + defer h.muxReg.Unlock() + + ski = util.NormalizeSKI(ski) + + service, ok := h.remoteServices[ski] + if !ok { + service = api.NewServiceDetails(ski) + service.ConnectionStateDetail().SetState(api.ConnectionStateNone) + h.remoteServices[ski] = service + } + + return service +} + +// return the number of paired services +func (h *Hub) numberPairedServices() int { + amount := 0 + + h.muxReg.Lock() + for _, service := range h.remoteServices { + if service.Trusted() { + amount++ + } + } + h.muxReg.Unlock() + + return amount +} + +// startup mDNS if a paired service is not connected +func (h *Hub) checkAutoReannounce() { + countPairedServices := h.numberPairedServices() + h.muxCon.Lock() + countConnections := len(h.connections) + h.muxCon.Unlock() + + if countPairedServices > countConnections { + _ = h.mdns.AnnounceMdnsEntry() + + // also check currently known mDNS entries to see if they + // already contain the not connected remote service + h.mdns.RequestMdnsEntries() + } +} diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub_connections.go b/src/eebus-bridge/third_party/ship-go/hub/hub_connections.go new file mode 100644 index 0000000..b39172f --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub_connections.go @@ -0,0 +1,508 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: a registered connection that is already closed doesn't count as +// connected (it is dropped when looked up). + +package hub + +import ( + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "math/rand" + "net" + "net/http" + "slices" + "strconv" + "time" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/cert" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/ship" + "github.com/enbility/ship-go/ws" + "github.com/gorilla/websocket" +) + +// Websocket connection handling +func (h *Hub) verifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { + skiFound := false + for _, v := range rawCerts { + cerificate, err := x509.ParseCertificate(v) + if err != nil { + return err + } + + if _, err := cert.SkiFromCertificate(cerificate); err == nil { + skiFound = true + break + } + } + if !skiFound { + return errors.New("no valid SKI provided in certificate") + } + + return nil +} + +// start the ship websocket server +func (h *Hub) startWebsocketServer() error { + addr := fmt.Sprintf(":%d", h.port) + logging.Log().Debug("starting websocket server on", addr) + + h.httpServer = &http.Server{ + Addr: addr, + Handler: h, + ReadHeaderTimeout: time.Duration(time.Second * 10), + TLSConfig: &tls.Config{ + Certificates: []tls.Certificate{h.certifciate}, + ClientAuth: tls.RequireAnyClientCert, // SHIP 9: Client authentication is required + CipherSuites: cert.CipherSuites, // #nosec G402 // SHIP 9.1: the ciphers are reported insecure but are defined to be used by SHIP + VerifyPeerCertificate: h.verifyPeerCertificate, + MinVersion: tls.VersionTLS12, // SHIP 9: Mandatory TLS version + }, + } + + go func() { + if err := h.httpServer.ListenAndServeTLS("", ""); err != nil { + logging.Log().Error("websocket server error:", err) + // TODO: decide how to handle this case + } + }() + + return nil +} + +// Connection Handling + +// HTTP Server callback for handling incoming connection requests +func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request) { + upgrader := websocket.Upgrader{ + ReadBufferSize: ws.MaxMessageSize, + WriteBufferSize: ws.MaxMessageSize, + CheckOrigin: func(r *http.Request) bool { return true }, + Subprotocols: []string{api.ShipWebsocketSubProtocol}, // SHIP 10.2: Sub protocol "ship" is required + } + + conn, err := upgrader.Upgrade(w, r, nil) + if err != nil { + logging.Log().Debug("error during connection upgrading:", err) + return + } + + // check if the client supports the ship sub protocol + if conn.Subprotocol() != api.ShipWebsocketSubProtocol { + logging.Log().Debug("client does not support the ship sub protocol") + _ = conn.Close() + return + } + + // check if the clients certificate provides a SKI + if r.TLS == nil || len(r.TLS.PeerCertificates) == 0 { + logging.Log().Debug("client does not provide a certificate") + _ = conn.Close() + return + } + + ski, err := cert.SkiFromCertificate(r.TLS.PeerCertificates[0]) + if err != nil { + logging.Log().Debug(err) + _ = conn.Close() + return + } + + // normalize the incoming SKI + remoteService := api.NewServiceDetails(ski) + logging.Log().Debug("incoming connection request from", remoteService.SKI()) + + // Check if the remote service is paired + service := h.ServiceForSKI(remoteService.SKI()) + connectionStateDetail := service.ConnectionStateDetail() + if connectionStateDetail.State() == api.ConnectionStateQueued { + connectionStateDetail.SetState(api.ConnectionStateReceivedPairingRequest) + h.hubReader.ServicePairingDetailUpdate(ski, connectionStateDetail) + } + + remoteService = service + + // don't allow a second connection + if !h.keepThisConnection(conn, true, remoteService) { + _ = conn.Close() + return + } + + dataHandler := ws.NewWebsocketConnection(conn, remoteService.SKI()) + shipConnection := ship.NewConnectionHandler(h, dataHandler, ship.ShipRoleServer, + h.localService.ShipID(), remoteService.SKI(), remoteService.ShipID()) + shipConnection.Run() + + h.registerConnection(shipConnection) +} + +// return if there is a connection for a SKI +func (h *Hub) isSkiConnected(ski string) bool { + // The connection with the higher SKI should retain the connection + return h.connectionForSKI(ski) != nil +} + +// Connect to another EEBUS service +// +// returns error contains a reason for failing the connection or nil if no further tries should be processed +func (h *Hub) connectFoundService(remoteService *api.ServiceDetails, host, port, path string) error { + if h.isSkiConnected(remoteService.SKI()) { + return nil + } + + logging.Log().Debugf("initiating connection to %s at %s:%s%s", remoteService.SKI(), host, port, path) + + dialer := &websocket.Dialer{ + Proxy: http.ProxyFromEnvironment, + HandshakeTimeout: 5 * time.Second, + TLSClientConfig: &tls.Config{ + Certificates: []tls.Certificate{h.certifciate}, + // SHIP 12.1: all certificates are locally signed + InsecureSkipVerify: true, // #nosec G402 + // SHIP 9.1: the ciphers are reported insecure but are defined to be used by SHIP + CipherSuites: cert.CipherSuites, // #nosec G402 + }, + Subprotocols: []string{api.ShipWebsocketSubProtocol}, + } + + address := fmt.Sprintf("wss://%s:%s%s", host, port, path) + conn, resp, err := dialer.Dial(address, nil) + if err == nil { + defer resp.Body.Close() + } else { + address = fmt.Sprintf("wss://%s:%s", host, port) + conn, resp, err = dialer.Dial(address, nil) + if err != nil { + return err + } + defer resp.Body.Close() + } + + tlsConn := conn.UnderlyingConn().(*tls.Conn) + remoteCerts := tlsConn.ConnectionState().PeerCertificates + + if len(remoteCerts) == 0 || remoteCerts[0].SubjectKeyId == nil { + // Close connection as we couldn't get the remote SKI + errorString := fmt.Sprintf("closing connection to %s: could not get remote SKI from certificate", remoteService.SKI()) + _ = conn.Close() + return errors.New(errorString) + } + + if _, err := cert.SkiFromCertificate(remoteCerts[0]); err != nil { + // Close connection as the remote SKI can't be correct + errorString := fmt.Sprintf("closing connection to %s: %s", remoteService.SKI(), err) + _ = conn.Close() + return errors.New(errorString) + } + + remoteSKI := fmt.Sprintf("%0x", remoteCerts[0].SubjectKeyId) + + if remoteSKI != remoteService.SKI() { + errorString := fmt.Sprintf("closing connection to %s: SKI does not match %s", remoteService.SKI(), remoteSKI) + _ = conn.Close() + return errors.New(errorString) + } + + if !h.keepThisConnection(conn, false, remoteService) { + errorString := fmt.Sprintf("closing connection to %s: ignoring this connection", remoteService.SKI()) + return errors.New(errorString) + } + + dataHandler := ws.NewWebsocketConnection(conn, remoteService.SKI()) + shipConnection := ship.NewConnectionHandler(h, dataHandler, ship.ShipRoleClient, + h.localService.ShipID(), remoteService.SKI(), remoteService.ShipID()) + shipConnection.Run() + + h.registerConnection(shipConnection) + + return nil +} + +// prevent double connections +// only keep the connection initiated by the higher SKI +// +// returns true if this connection is fine to be continue +// returns false if this connection should not be established or kept +func (h *Hub) keepThisConnection(conn *websocket.Conn, incomingRequest bool, remoteService *api.ServiceDetails) bool { + // SHIP 12.2.2 defines: + // prevent double connections with SKI Comparison + // the node with the hight SKI value kees the most recent connection and + // and closes all other connections to the same SHIP node + // + // This is hard to implement without any flaws. Therefor I chose a + // different approach: The connection initiated by the higher SKI will be kept + + remoteSKI := remoteService.SKI() + existingC := h.connectionForSKI(remoteSKI) + if existingC == nil { + return true + } + + keep := false + if incomingRequest { + keep = remoteSKI > h.localService.SKI() + } else { + keep = h.localService.SKI() > remoteSKI + } + + if keep { + // we have an existing connection + // so keep the new (most recent) and close the old one + logging.Log().Debug("closing existing double connection") + go existingC.CloseConnection(false, 0, "") + } else { + connType := "incoming" + if !incomingRequest { + connType = "outgoing" + } + logging.Log().Debugf("closing %s double connection, as the existing connection will be used", connType) + if conn != nil { + go h.sendWSCloseMessage(conn) + } + } + + return keep +} + +func (h *Hub) sendWSCloseMessage(conn *websocket.Conn) { + _ = conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "double connection")) + <-time.After(time.Millisecond * 100) + _ = conn.Close() +} + +// coordinate connection initiation attempts to a remove service +func (h *Hub) coordinateConnectionInitations(ski string, entry *api.MdnsEntry) { + if h.isConnectionAttemptRunning(ski) { + return + } + + h.setConnectionAttemptRunning(ski, true) + + counter, duration := h.getConnectionInitiationDelayTime(ski) + + service := h.ServiceForSKI(ski) + if service.ConnectionStateDetail().State() == api.ConnectionStateQueued { + go h.prepareConnectionInitation(ski, counter, entry) + return + } + + logging.Log().Debugf("delaying connection to %s by %s to minimize double connection probability", ski, duration) + + // we do not stop this thread and just let the timer run out + // otherwise we would need a stop channel for each ski + go func() { + // wait + <-time.After(duration) + + h.prepareConnectionInitation(ski, counter, entry) + }() +} + +// invoked by coordinateConnectionInitations either with a delay or directly +// when initating a pairing process +func (h *Hub) prepareConnectionInitation(ski string, counter int, entry *api.MdnsEntry) { + h.setConnectionAttemptRunning(ski, false) + + // check if the current counter is still the same, otherwise this counter is irrelevant + currentCounter, exists := h.getCurrentConnectionAttemptCounter(ski) + if !exists || currentCounter != counter { + return + } + + // connection attempt is not relevant if the device is no longer paired + // or it is not queued for pairing + pairingState := h.ServiceForSKI(ski).ConnectionStateDetail().State() + if !h.IsRemoteServiceForSKIPaired(ski) && pairingState != api.ConnectionStateQueued { + return + } + + // connection attempt is not relevant if the device is already connected + if h.isSkiConnected(ski) { + return + } + + // now initiate the connection + // check if the remoteService still exists + service := h.ServiceForSKI(ski) + + if success := h.initateConnection(service, entry); !success { + h.checkAutoReannounce() + } +} + +// attempt to establish a connection to a remote service +// returns true if successful +func (h *Hub) initateConnection(remoteService *api.ServiceDetails, entry *api.MdnsEntry) bool { + var err error + + // connection attempt is not relevant if the device is no longer paired + // or it is not queued for pairing + pairingState := h.ServiceForSKI(remoteService.SKI()).ConnectionStateDetail().State() + if !h.IsRemoteServiceForSKIPaired(remoteService.SKI()) && pairingState != api.ConnectionStateQueued { + return false + } + + // try connetion via hostname + if len(entry.Host) > 0 { + logging.Log().Debug("trying to connect to", remoteService.SKI(), "at", entry.Host) + if err = h.connectFoundService(remoteService, entry.Host, strconv.Itoa(entry.Port), entry.Path); err != nil { + logging.Log().Debugf("connection to %s failed: %s", remoteService.SKI(), err) + } else { + return true + } + } + + // try IPv4 addresses before IPv6 addresses + slices.SortFunc(entry.Addresses, func(a, b net.IP) int { + if a.To4() != nil && b.To4() == nil { + return -1 + } + if a.To4() == nil && b.To4() != nil { + return 1 + } + return 0 + }) + + // try connecting via the provided IP addresses + for _, address := range entry.Addresses { + logging.Log().Debug("trying to connect to", remoteService.SKI(), "at", address) + // IPv4 + addressValue := address.String() + if address.To4() == nil { + // IPv6 + addressValue = "[" + address.String() + "]" + } + if err = h.connectFoundService(remoteService, addressValue, strconv.Itoa(entry.Port), entry.Path); err != nil { + logging.Log().Debug("connection to", remoteService.SKI(), "failed: ", err) + } else { + return true + } + } + + // no connection could be estabished via any of the provided addresses + // because no service was reachable at any of the addresses + return false +} + +// increase the connection attempt counter for the given ski +func (h *Hub) increaseConnectionAttemptCounter(ski string) int { + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + currentCounter := 0 + if counter, exists := h.connectionAttemptCounter[ski]; exists { + currentCounter = counter + 1 + + if currentCounter >= len(connectionInitiationDelayTimeRanges)-1 { + currentCounter = len(connectionInitiationDelayTimeRanges) - 1 + } + } + + h.connectionAttemptCounter[ski] = currentCounter + + return currentCounter +} + +// remove the connection attempt counter for the given ski +func (h *Hub) removeConnectionAttemptCounter(ski string) { + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + delete(h.connectionAttemptCounter, ski) +} + +// get the current attempt counter +func (h *Hub) getCurrentConnectionAttemptCounter(ski string) (int, bool) { + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + counter, exists := h.connectionAttemptCounter[ski] + + return counter, exists +} + +// get the connection initiation delay time range for a given ski +// returns the current counter and the duration +func (h *Hub) getConnectionInitiationDelayTime(ski string) (int, time.Duration) { + counter := h.increaseConnectionAttemptCounter(ski) + + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + timeRange := connectionInitiationDelayTimeRanges[counter] + + // get range in Milliseconds + min := timeRange.min * 1000 + max := timeRange.max * 1000 + + // #nosec G404 + duration := rand.Intn(max-min) + min + + return counter, time.Duration(duration) * time.Millisecond +} + +// set if a connection attempt is running/in progress +func (h *Hub) setConnectionAttemptRunning(ski string, active bool) { + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + h.connectionAttemptRunning[ski] = active +} + +// return if a connection attempt is runnning/in progress +func (h *Hub) isConnectionAttemptRunning(ski string) bool { + h.muxConAttempt.Lock() + defer h.muxConAttempt.Unlock() + + running, exists := h.connectionAttemptRunning[ski] + if !exists { + return false + } + + return running +} + +// register a new ship Connection +func (h *Hub) registerConnection(connection api.ShipConnectionInterface) { + h.muxCon.Lock() + defer h.muxCon.Unlock() + + h.connections[connection.RemoteSKI()] = connection +} + +// return the live connection for a specific SKI +// +// A registered connection whose data connection is already closed is +// dropped here: a connection is registered after it started running, so +// one that ended at once (a double connection the remote closed in +// mid-handshake) reported its close before it was registered and stayed +// in the map. Then the SKI counted as connected for ever: never dialled +// again, and its incoming connections refused as double connections. +func (h *Hub) connectionForSKI(ski string) api.ShipConnectionInterface { + h.muxCon.Lock() + defer h.muxCon.Unlock() + + con, ok := h.connections[ski] + if !ok { + return nil + } + if dataHandler := con.DataHandler(); dataHandler != nil { + if closed, _ := dataHandler.IsDataConnectionClosed(); closed { + delete(h.connections, ski) + return nil + } + } + return con +} + +// return the registered connection for a specific SKI, closed or not +func (h *Hub) registeredConnectionForSKI(ski string) api.ShipConnectionInterface { + h.muxCon.Lock() + defer h.muxCon.Unlock() + + return h.connections[ski] +} diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub_mdns.go b/src/eebus-bridge/third_party/ship-go/hub/hub_mdns.go new file mode 100644 index 0000000..0e262d5 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub_mdns.go @@ -0,0 +1,74 @@ +package hub + +import ( + "net" + "sort" + "strings" + + "github.com/enbility/ship-go/api" +) + +var _ api.MdnsReportInterface = (*Hub)(nil) + +// Process reported mDNS services +func (h *Hub) ReportMdnsEntries(entries map[string]*api.MdnsEntry, newEntries bool) { + var mdnsEntries []*api.MdnsEntry + + for ski, entry := range entries { + mdnsEntries = append(mdnsEntries, entry) + + // check if this ski is already connected + if h.isSkiConnected(ski) { + continue + } + + // Check if the remote service is paired or queued for connection + service := h.ServiceForSKI(ski) + if !h.IsRemoteServiceForSKIPaired(ski) && + service.ConnectionStateDetail().State() != api.ConnectionStateQueued { + continue + } + + service.SetAutoAccept(entry.Register) + + // patch the addresses list if an IPv4 address was provided + if service.IPv4() != "" { + if ip := net.ParseIP(service.IPv4()); ip != nil { + entry.Addresses = []net.IP{ip} + } + } + + h.coordinateConnectionInitations(ski, entry) + } + + sort.Slice(mdnsEntries, func(i, j int) bool { + item1 := mdnsEntries[i] + item2 := mdnsEntries[j] + a := strings.ToLower(item1.Brand + item1.Model + item1.Ski) + b := strings.ToLower(item2.Brand + item2.Model + item2.Ski) + return a < b + }) + + if newEntries { + h.muxMdns.Lock() + h.knownMdnsEntries = mdnsEntries + h.muxMdns.Unlock() + } + + var remoteServices []api.RemoteService + + for _, entry := range entries { + remoteService := api.RemoteService{ + Name: entry.Name, + Ski: entry.Ski, + Identifier: entry.Identifier, + Brand: entry.Brand, + Type: entry.Type, + Model: entry.Model, + } + + remoteServices = append(remoteServices, remoteService) + } + + h.hubReader.VisibleRemoteServicesUpdated(remoteServices) +} diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub_pairing.go b/src/eebus-bridge/third_party/ship-go/hub/hub_pairing.go new file mode 100644 index 0000000..efabbbc --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub_pairing.go @@ -0,0 +1,166 @@ +package hub + +import ( + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/model" + "github.com/enbility/ship-go/util" +) + +// Provide the current pairing state for a SKI +// +// returns: +// +// ErrNotPaired if the SKI is not in the (to be) paired list +// ErrNoConnectionFound if no connection for the SKI was found +func (h *Hub) PairingDetailForSki(ski string) *api.ConnectionStateDetail { + service := h.ServiceForSKI(ski) + + if conn := h.connectionForSKI(ski); conn != nil { + shipState, shipError := conn.ShipHandshakeState() + state := h.mapShipMessageExchangeState(shipState, ski) + return api.NewConnectionStateDetail(state, shipError) + } + + return service.ConnectionStateDetail() +} + +// maps ShipMessageExchangeState to PairingState +func (h *Hub) mapShipMessageExchangeState(state model.ShipMessageExchangeState, _ string) api.ConnectionState { + var connState api.ConnectionState + + // map the SHIP states to a public ConnectionState + switch state { + case model.CmiStateInitStart: + connState = api.ConnectionStateQueued + case model.CmiStateClientSend, model.CmiStateClientWait, model.CmiStateClientEvaluate, + model.CmiStateServerWait, model.CmiStateServerEvaluate: + connState = api.ConnectionStateInitiated + case model.SmeHelloStateReadyInit, model.SmeHelloStateReadyListen, model.SmeHelloStateReadyTimeout, + model.SmeHelloStatePendingInit, model.SmeHelloStatePendingTimeout: + connState = api.ConnectionStateInProgress + case model.SmeHelloStatePendingListen: + connState = api.ConnectionStateReceivedPairingRequest + case model.SmeHelloStateOk: + connState = api.ConnectionStateTrusted + case model.SmeHelloStateAbort, model.SmeHelloStateAbortDone: + connState = api.ConnectionStateNone + case model.SmeHelloStateRemoteAbortDone, model.SmeHelloStateRejected: + connState = api.ConnectionStateRemoteDeniedTrust + case model.SmePinStateCheckInit, model.SmePinStateCheckListen, model.SmePinStateCheckError, + model.SmePinStateCheckBusyInit, model.SmePinStateCheckBusyWait, model.SmePinStateCheckOk, + model.SmePinStateAskInit, model.SmePinStateAskProcess, model.SmePinStateAskRestricted, + model.SmePinStateAskOk: + connState = api.ConnectionStatePin + case model.SmeAccessMethodsRequest, model.SmeStateApproved: + connState = api.ConnectionStateInProgress + case model.SmeStateComplete: + connState = api.ConnectionStateCompleted + case model.SmeStateError: + connState = api.ConnectionStateError + default: + connState = api.ConnectionStateInProgress + } + + return connState +} + +func (h *Hub) SetAutoAccept(autoaccept bool) { + h.muxReg.Lock() + defer h.muxReg.Unlock() + + h.autoaccept = autoaccept + + h.mdns.SetAutoAccept(autoaccept) +} + +// check if auto accept is true +func (h *Hub) IsAutoAcceptEnabled() bool { + h.muxReg.Lock() + defer h.muxReg.Unlock() + + return h.autoaccept +} + +func (h *Hub) checkHasStarted() bool { + h.muxStarted.Lock() + defer h.muxStarted.Unlock() + return h.hasStarted +} + +// Sets the SKI as being paired or not +// Should be used for services which completed the pairing process and +// which were stored as having the process completed +func (h *Hub) RegisterRemoteSKI(ski string) { + ski = util.NormalizeSKI(ski) + + // if the hub has not started, simply add it + if !h.checkHasStarted() { + service := h.ServiceForSKI(ski) + service.SetTrusted(true) + + h.checkAutoReannounce() + return + } + + // if the hub has started, trigger a search and connection attempt + conn := h.connectionForSKI(ski) + + service := h.ServiceForSKI(ski) + service.SetTrusted(true) + + // remotely initiated? + if conn != nil { + conn.ApprovePendingHandshake() + + return + } + + // locally initiated + service.ConnectionStateDetail().SetState(api.ConnectionStateQueued) + + h.hubReader.ServicePairingDetailUpdate(ski, service.ConnectionStateDetail()) + + h.mdns.RequestMdnsEntries() +} + +// Remove pairing for the SKI +func (h *Hub) UnregisterRemoteSKI(ski string) { + service := h.ServiceForSKI(ski) + service.SetTrusted(false) + + h.removeConnectionAttemptCounter(ski) + + service.ConnectionStateDetail().SetState(api.ConnectionStateNone) + + h.hubReader.ServicePairingDetailUpdate(ski, service.ConnectionStateDetail()) + + if existingC := h.connectionForSKI(ski); existingC != nil { + existingC.CloseConnection(true, 4500, "User close") + } +} + +// Disconnect a connection to an SKI, used by a service implementation +// e.g. if heartbeats go wrong +func (h *Hub) DisconnectSKI(ski string, reason string) { + con := h.connectionForSKI(ski) + if con == nil { + return + } + + con.CloseConnection(true, 0, reason) +} + +// Cancels the pairing process for a SKI +func (h *Hub) CancelPairingWithSKI(ski string) { + h.removeConnectionAttemptCounter(ski) + + if existingC := h.connectionForSKI(ski); existingC != nil { + existingC.AbortPendingHandshake() + } + + service := h.ServiceForSKI(ski) + service.ConnectionStateDetail().SetState(api.ConnectionStateNone) + service.SetTrusted(false) + + h.hubReader.ServicePairingDetailUpdate(ski, service.ConnectionStateDetail()) +} diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub_shipconnection.go b/src/eebus-bridge/third_party/ship-go/hub/hub_shipconnection.go new file mode 100644 index 0000000..61dc581 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub_shipconnection.go @@ -0,0 +1,212 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: HandleConnectionClosed compares with the registered connection +// even when it is closed, and reports the SKI disconnected unless another +// connection set up the current device; SetupRemoteDevice records the +// device's connection and, after such a close, reports the SKI connected +// again (skiDevice, one lock per SKI). + +package hub + +import ( + "errors" + "sync" + "time" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/model" +) + +var _ api.ShipConnectionInfoProviderInterface = (*Hub)(nil) + +// check if the SKI is paired +func (h *Hub) IsRemoteServiceForSKIPaired(ski string) bool { + service := h.ServiceForSKI(ski) + + return service.Trusted() +} + +// report closing of a connection and if handshake did complete +func (h *Hub) HandleConnectionClosed(connection api.ShipConnectionInterface, handshakeCompleted bool) { + remoteSki := connection.RemoteSKI() + + // only remove this connection if it is the registered one for the ski! + // as we can have double connections but only one can be registered + // (the registered one even though it is closed: it is the one closing) + if existingC := h.registeredConnectionForSKI(remoteSki); existingC != nil && + existingC.DataHandler() == connection.DataHandler() { + h.muxCon.Lock() + delete(h.connections, connection.RemoteSKI()) + h.muxCon.Unlock() + } + + // connection close was after a completed handshake, so we can reset the + // attempt counter (also when the connection is no longer registered: a + // lookup (connectionForSKI) may already have dropped it as closed) + if handshakeCompleted { + h.removeConnectionAttemptCounter(connection.RemoteSKI()) + } + + // the SKI is reported disconnected (in SPINE: its device removed, by SKI) + // unless another connection to it set up the current device: the closing + // one of a double connection must not tear down the device, bindings and + // subscriptions of the one kept. Decided and reported under the SKI's own + // lock (skiDevice), which SetupRemoteDevice takes too: a twin that + // completes its handshake either set up its device before (then this + // close is not reported) or after (then it sets up a new device and, as + // this close reported the SKI disconnected, reports it connected again). + // Per SKI: other devices' connections never wait for these callbacks. + sd := h.acquireSkiDevice(remoteSki) + sd.mu.Lock() + if sd.owner != nil && sd.owner != connection.DataHandler() { + sd.mu.Unlock() + h.releaseSkiDevice(remoteSki, sd) + return + } + sd.owner = nil + sd.reportedDown = true + h.hubReader.RemoteSKIDisconnected(connection.RemoteSKI()) + sd.mu.Unlock() + h.releaseSkiDevice(remoteSki, sd) + + // Do not automatically reconnect if handshake failed and not already paired + remoteService := h.ServiceForSKI(connection.RemoteSKI()) + if !handshakeCompleted && !remoteService.Trusted() { + return + } + + h.checkAutoReannounce() +} + +// report the ship ID provided during the handshake +func (h *Hub) ReportServiceShipID(ski string, shipdID string) { + // connected reported here: a disconnect reported before is answered + // (the setup reports it again only after a close since) + sd := h.acquireSkiDevice(ski) + sd.mu.Lock() + sd.reportedDown = false + h.hubReader.RemoteSKIConnected(ski) + sd.mu.Unlock() + h.releaseSkiDevice(ski, sd) + + h.hubReader.ServiceShipIDUpdate(ski, shipdID) +} + +// check if the user is still able to trust the connection +func (h *Hub) AllowWaitingForTrust(ski string) bool { + if service := h.ServiceForSKI(ski); service != nil { + if service.Trusted() { + return true + } + } + + return h.hubReader.AllowWaitingForTrust(ski) +} + +// report the updated SHIP handshake state and optional error message for a SKI +func (h *Hub) HandleShipHandshakeStateUpdate(ski string, state model.ShipState) { + // overwrite service Paired value + if state.State == model.SmeHelloStateOk { + service := h.ServiceForSKI(ski) + service.SetTrusted(true) + } + + pairingState := h.mapShipMessageExchangeState(state.State, ski) + if state.Error != nil && !errors.Is(state.Error, api.ErrConnectionNotFound) { + pairingState = api.ConnectionStateError + } + + pairingDetail := api.NewConnectionStateDetail(pairingState, state.Error) + + service := h.ServiceForSKI(ski) + + existingDetails := service.ConnectionStateDetail() + existingState := existingDetails.State() + if existingState != pairingState || !errors.Is(existingDetails.Error(), state.Error) { + service.SetConnectionStateDetail(pairingDetail) + + // always send a delayed update, as the processing of the new state has to be done + // and the SHIP message has to be received by the other service before + // acting upon the new state is safe + go func() { + <-time.After(time.Millisecond * 500) + h.hubReader.ServicePairingDetailUpdate(ski, pairingDetail) + }() + } +} + +// report an approved handshake by a remote device +// +// The device belongs to this connection from now on (deviceOwner, under +// muxDevice with HandleConnectionClosed), and the SKI is reported connected +// again: a twin connection's close may have reported it disconnected while +// this one was still in its handshake, and nothing else would report it +// connected (RemoteSKIConnected otherwise only comes with the SHIP ID). +func (h *Hub) SetupRemoteDevice(ski string, writeI api.ShipConnectionDataWriterInterface) api.ShipConnectionDataReaderInterface { + sd := h.acquireSkiDevice(ski) + defer h.releaseSkiDevice(ski, sd) + sd.mu.Lock() + defer sd.mu.Unlock() + + reader := h.hubReader.SetupRemoteDevice(ski, writeI) + var owner any = writeI + if conn, ok := writeI.(api.ShipConnectionInterface); ok { + owner = conn.DataHandler() + } + sd.owner = owner + if sd.reportedDown { + // a twin's close reported the SKI disconnected meanwhile: connected + // again (otherwise RemoteSKIConnected came with the SHIP ID already) + sd.reportedDown = false + h.hubReader.RemoteSKIConnected(ski) + } + + return reader +} + +// skiDevice: the SPINE device state of one SKI (deviceOwner). +type skiDevice struct { + mu sync.Mutex + owner any // the data handler of the connection whose device is current + reportedDown bool // a close reported the SKI disconnected since its connected report + users int // acquired and not yet released (under muxDevice) +} + +// acquireSkiDevice: the SKI's state, held until releaseSkiDevice (an entry +// in use is never pruned, so all users of a SKI share one lock). +func (h *Hub) acquireSkiDevice(ski string) *skiDevice { + h.muxDevice.Lock() + defer h.muxDevice.Unlock() + + if h.deviceOwner == nil { + h.deviceOwner = make(map[string]*skiDevice) + } + sd := h.deviceOwner[ski] + if sd == nil { + sd = &skiDevice{} + h.deviceOwner[ski] = sd + } + sd.users++ + return sd +} + +// releaseSkiDevice: done with the SKI's state; the entry is dropped when +// nobody holds it, it owns no device and no connection to the SKI is live +// (the map doesn't keep every SKI ever seen). +func (h *Hub) releaseSkiDevice(ski string, sd *skiDevice) { + h.muxDevice.Lock() + defer h.muxDevice.Unlock() + + sd.users-- + if sd.users > 0 || h.deviceOwner[ski] != sd { + return + } + if !sd.mu.TryLock() { + return // (can't be: no users; never wait here) + } + idle := sd.owner == nil + sd.mu.Unlock() + if idle && h.connectionForSKI(ski) == nil { + delete(h.deviceOwner, ski) + } +} diff --git a/src/eebus-bridge/third_party/ship-go/hub/hub_stale_test.go b/src/eebus-bridge/third_party/ship-go/hub/hub_stale_test.go new file mode 100644 index 0000000..0ed2845 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/hub/hub_stale_test.go @@ -0,0 +1,246 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package hub + +import ( + "strings" + "sync" + "testing" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/model" +) + +type testDataHandler struct{ closed bool } + +func (d *testDataHandler) InitDataProcessing(api.WebsocketDataReaderInterface) {} +func (d *testDataHandler) WriteMessageToWebsocketConnection([]byte) error { return nil } +func (d *testDataHandler) CloseDataConnection(int, string) {} +func (d *testDataHandler) IsDataConnectionClosed() (bool, error) { return d.closed, nil } + +type testConnection struct { + ski string + data *testDataHandler +} + +func (c *testConnection) DataHandler() api.WebsocketDataWriterInterface { return c.data } +func (c *testConnection) CloseConnection(bool, int, string) {} +func (c *testConnection) RemoteSKI() string { return c.ski } +func (c *testConnection) ApprovePendingHandshake() {} +func (c *testConnection) AbortPendingHandshake() {} +func (c *testConnection) WriteShipMessageWithPayload([]byte) {} +func (c *testConnection) ShipHandshakeState() (model.ShipMessageExchangeState, error) { + return model.SmeStateComplete, nil +} + +// testReader records what the hub reports, in order ("+" connected, "-" +// disconnected, "setup"). +type testReader struct { + mu sync.Mutex + events []string +} + +func (r *testReader) add(e string) { + r.mu.Lock() + defer r.mu.Unlock() + r.events = append(r.events, e) +} + +func (r *testReader) count(e string) int { + r.mu.Lock() + defer r.mu.Unlock() + n := 0 + for _, x := range r.events { + if x == e { + n++ + } + } + return n +} + +func (r *testReader) last() string { + r.mu.Lock() + defer r.mu.Unlock() + if len(r.events) == 0 { + return "" + } + return r.events[len(r.events)-1] +} + +func (r *testReader) RemoteSKIConnected(string) { r.add("+") } +func (r *testReader) RemoteSKIDisconnected(string) { r.add("-") } +func (r *testReader) SetupRemoteDevice(string, api.ShipConnectionDataWriterInterface) api.ShipConnectionDataReaderInterface { + r.add("setup") + return nil +} +func (r *testReader) VisibleRemoteServicesUpdated([]api.RemoteService) {} +func (r *testReader) ServiceShipIDUpdate(string, string) {} +func (r *testReader) ServicePairingDetailUpdate(string, *api.ConnectionStateDetail) {} +func (r *testReader) AllowWaitingForTrust(string) bool { return false } + +func testHub(reader *testReader) *Hub { + return &Hub{ + connections: map[string]api.ShipConnectionInterface{}, + connectionAttemptCounter: map[string]int{}, + connectionAttemptRunning: map[string]bool{}, + remoteServices: map[string]*api.ServiceDetails{}, + hubReader: reader, + } +} + +// The closing side of a double connection doesn't report the SKI as +// disconnected while the connection kept has set up the current device: +// before, SPINE removed that device by SKI, with the kept connection's +// bindings ("write denied due to missing binding" on every later write). +func TestDoubleConnectionCloseKeepsTheSKIConnected(t *testing.T) { + reader := &testReader{} + h := testHub(reader) + kept := &testConnection{ski: "aa", data: &testDataHandler{}} + dropped := &testConnection{ski: "aa", data: &testDataHandler{closed: true}} + h.registerConnection(kept) + h.SetupRemoteDevice("aa", kept) + h.HandleConnectionClosed(dropped, false) + if reader.count("-") != 0 { + t.Fatal("the dropped connection reported the SKI as disconnected") + } + kept.data.closed = true + h.HandleConnectionClosed(kept, true) + if reader.count("-") != 1 || h.isSkiConnected("aa") { + t.Fatalf("the kept connection's close: %v", reader.events) + } +} + +// The twin closes while the other connection is still in its handshake: +// the twin's device is removed (reported disconnected), and when the other +// completes, it sets up its device and reports the SKI connected again +// (before, nothing did: the device stayed offline, the grid limit wasn't +// passed on). +func TestTwinClosedMidHandshakeThenTheOtherCompletes(t *testing.T) { + reader := &testReader{} + h := testHub(reader) + old := &testConnection{ski: "aa", data: &testDataHandler{}} + newer := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(old) + h.SetupRemoteDevice("aa", old) + h.registerConnection(newer) // in its handshake + old.data.closed = true + h.HandleConnectionClosed(old, true) + if reader.last() != "-" { + t.Fatalf("the old connection's device not removed: %v", reader.events) + } + h.SetupRemoteDevice("aa", newer) + if reader.last() != "+" { + t.Fatalf("not reported connected when the other completed: %v", reader.events) + } +} + +// A twin's close and the other's completion at once: the device the +// completing connection sets up is never removed by the twin's close, and +// the SKI ends connected (the decision and the setup are under one lock). +func TestTwinCloseRacingTheOthersSetup(t *testing.T) { + for i := 0; i < 500; i++ { + reader := &testReader{} + h := testHub(reader) + twin := &testConnection{ski: "aa", data: &testDataHandler{closed: true}} + other := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(other) + var wg sync.WaitGroup + wg.Add(2) + go func() { defer wg.Done(); h.HandleConnectionClosed(twin, false) }() + go func() { defer wg.Done(); h.SetupRemoteDevice("aa", other) }() + wg.Wait() + // either the setup came first (the twin's close isn't reported) or + // the close did (then the setup reports the SKI connected again) + if got := strings.Join(reader.events, " "); got != "setup" && got != "- setup +" { + t.Fatalf("round %d: %s", i, got) + } + } +} + +// Connected is reported once per connection: with the SHIP ID (the hub's +// ReportServiceShipID), and by the setup only after a twin's close reported +// the SKI disconnected in between. +func TestSetupReportsConnectedOnlyAfterADisconnect(t *testing.T) { + reader := &testReader{} + h := testHub(reader) + c := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(c) + h.SetupRemoteDevice("aa", c) + if reader.count("+") != 0 { + t.Fatalf("a plain setup reported connected: %v", reader.events) + } +} + +// A normal reconnect: connected once per connection (with the SHIP ID), the +// setup adds nothing; and the SKI's entry is dropped when it has no device +// and no live connection. +func TestReconnectReportsConnectedOnce(t *testing.T) { + reader := &testReader{} + h := testHub(reader) + a := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(a) + h.ReportServiceShipID("aa", "id") + h.SetupRemoteDevice("aa", a) + a.data.closed = true + h.HandleConnectionClosed(a, true) + if len(h.deviceOwner) != 0 { + t.Fatalf("an idle SKI's entry kept: %v", h.deviceOwner) + } + b := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(b) + h.ReportServiceShipID("aa", "id") + h.SetupRemoteDevice("aa", b) + if got := strings.Join(reader.events, " "); got != "+ setup - + setup" { + t.Fatalf("events: %s", got) + } + if len(h.deviceOwner) != 1 { + t.Fatalf("the live SKI's entry: %v", h.deviceOwner) + } +} + +// A completed connection's close resets the attempt counter (the back-off +// of connection attempts), also when a lookup already dropped it from the +// map as closed: before, the counter kept growing. +func TestCompletedCloseResetsTheAttemptCounter(t *testing.T) { + h := &Hub{ + connections: map[string]api.ShipConnectionInterface{}, + connectionAttemptCounter: map[string]int{}, + connectionAttemptRunning: map[string]bool{}, + remoteServices: map[string]*api.ServiceDetails{}, + hubReader: &testReader{}, + } + c := &testConnection{ski: "aa", data: &testDataHandler{closed: true}} + h.registerConnection(c) + h.increaseConnectionAttemptCounter("aa") + h.increaseConnectionAttemptCounter("aa") + if h.isSkiConnected("aa") { // the lookup drops it + t.Fatal("closed") + } + h.HandleConnectionClosed(c, true) + if _, exists := h.getCurrentConnectionAttemptCounter("aa"); exists { + t.Fatal("the attempt counter was not reset") + } +} + +// A connection that ended before it was registered (it closed at once in +// mid-handshake and reported that while it was not yet in the map) must not +// count as connected: before, the SKI was never dialled again and its +// incoming connections were refused as double connections. +func TestClosedRegisteredConnectionIsNotConnected(t *testing.T) { + h := &Hub{connections: map[string]api.ShipConnectionInterface{}} + live := &testConnection{ski: "aa", data: &testDataHandler{}} + h.registerConnection(live) + if !h.isSkiConnected("aa") || h.connectionForSKI("aa") != live { + t.Fatal("a live connection counts as connected") + } + + stale := &testConnection{ski: "aa", data: &testDataHandler{closed: true}} + h.registerConnection(stale) + if h.isSkiConnected("aa") || h.connectionForSKI("aa") != nil { + t.Fatal("a closed connection still counts as connected") + } + if len(h.connections) != 0 { + t.Fatalf("the closed connection is still registered: %v", h.connections) + } +} diff --git a/src/eebus-bridge/third_party/ship-go/logging/log.go b/src/eebus-bridge/third_party/ship-go/logging/log.go new file mode 100644 index 0000000..d5594b9 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/logging/log.go @@ -0,0 +1,52 @@ +package logging + +import "sync" + +//go:generate mockery + +// LoggingInterface needs to be implemented, if the internal logs should be printed +type LoggingInterface interface { + Trace(args ...interface{}) + Tracef(format string, args ...interface{}) + Debug(args ...interface{}) + Debugf(format string, args ...interface{}) + Info(args ...interface{}) + Infof(format string, args ...interface{}) + Error(args ...interface{}) + Errorf(format string, args ...interface{}) +} + +// NoLogging is an empty implementation of Logging which does nothing. +type NoLogging struct{} + +func (l *NoLogging) Trace(args ...interface{}) {} +func (l *NoLogging) Tracef(format string, args ...interface{}) {} +func (l *NoLogging) Debug(args ...interface{}) {} +func (l *NoLogging) Debugf(format string, args ...interface{}) {} +func (l *NoLogging) Info(args ...interface{}) {} +func (l *NoLogging) Infof(format string, args ...interface{}) {} +func (l *NoLogging) Error(args ...interface{}) {} +func (l *NoLogging) Errorf(format string, args ...interface{}) {} + +var log LoggingInterface = &NoLogging{} +var mux sync.Mutex + +// Sets a custom logging implementation +// By default NoLogging is used, so no logs are printed +// This is used by service.SetLogging() +func SetLogging(logger LoggingInterface) { + if logger == nil { + return + } + mux.Lock() + defer mux.Unlock() + + log = logger +} + +func Log() LoggingInterface { + mux.Lock() + defer mux.Unlock() + + return log +} diff --git a/src/eebus-bridge/third_party/ship-go/mdns/avahi.go b/src/eebus-bridge/third_party/ship-go/mdns/avahi.go new file mode 100644 index 0000000..6d47425 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/avahi.go @@ -0,0 +1,359 @@ +package mdns + +import ( + "fmt" + "net" + "sync" + "time" + + "github.com/enbility/go-avahi" + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" +) + +type mdnsServiceData struct { + // the service name + Name string + // the service port + Port int + // the service txt + Txt []string +} + +type AvahiProvider struct { + ifaceIndexes []int32 + + avServer avahi.ServerInterface + avEntryGroup avahi.EntryGroupInterface + avBrowser avahi.ServiceBrowserInterface + + autoReconnect bool + manualShutdown bool + setupSuccessful bool + listenerRunning bool + + mdnsServiceData *mdnsServiceData + + resolveCB api.MdnsResolveCB + + // Used to store the service elements for each service, so that we can recall them when a service is removed + serviceElements map[string]map[string]string + + shutdownChan chan struct{} + addServiceChan, removeServiceChan chan avahi.Service + + mux sync.Mutex + muxEl sync.RWMutex // used for serviceElements +} + +func NewAvahiProvider(ifaceIndexes []int32) *AvahiProvider { + return &AvahiProvider{ + avServer: avahi.ServerNew(), + setupSuccessful: false, + ifaceIndexes: ifaceIndexes, + serviceElements: make(map[string]map[string]string), + } +} + +var _ api.MdnsProviderInterface = (*AvahiProvider)(nil) + +func (a *AvahiProvider) Start(autoReconnect bool, cb api.MdnsResolveCB) bool { + a.mux.Lock() + defer a.mux.Unlock() + + a.autoReconnect = autoReconnect + a.resolveCB = cb + a.manualShutdown = false + + err := a.avServer.Setup(a.avahiCallback) + if err != nil { + return false + } + a.setupSuccessful = true + if a.shutdownChan == nil { + a.shutdownChan = make(chan struct{}) + } + if a.addServiceChan == nil { + a.addServiceChan = make(chan avahi.Service) + } + if a.removeServiceChan == nil { + a.removeServiceChan = make(chan avahi.Service) + } + + a.avServer.Start() + + if _, err := a.avServer.GetAPIVersion(); err != nil { + a.avServer.Shutdown() + return false + } + + // instead of limiting search on specific allowed interfaces, we allow all and filter the results + avBrowser, err := a.avServer.ServiceBrowserNew(a.addServiceChan, a.removeServiceChan, avahi.InterfaceUnspec, avahi.ProtoUnspec, shipZeroConfServiceType, shipZeroConfDomain, 0) + if err != nil || avBrowser == nil { + a.avServer.Shutdown() + return false + } + + a.avBrowser = avBrowser + + // autoReconnect is only called with false if the systems does not know if + // avahi should be used in the first place. + // but if it was found and therefor being used, it should automatically reconnect once disconnected + if !autoReconnect { + a.autoReconnect = true + } + + if !a.listenerRunning { + a.listenerRunning = true + go a.chanListener(cb) + } + + return true +} + +func (a *AvahiProvider) Shutdown() { + a.mux.Lock() + a.manualShutdown = true + + if !a.setupSuccessful { + a.mux.Unlock() + return + } + + // when shutting down on purpose, do not try to reconnect + a.autoReconnect = false + if a.avBrowser != nil { + a.avServer.ServiceBrowserFree(a.avBrowser) + a.avBrowser = nil + + if a.listenerRunning { + // stop the currently running resolve + a.shutdownChan <- struct{}{} + } + } + a.listenerRunning = false + if a.shutdownChan != nil { + close(a.shutdownChan) + a.shutdownChan = nil + } + if a.addServiceChan != nil { + close(a.addServiceChan) + a.addServiceChan = nil + } + if a.removeServiceChan != nil { + close(a.removeServiceChan) + a.removeServiceChan = nil + } + a.mux.Unlock() + + // Unannounce the service + a.Unannounce() + + a.mux.Lock() + defer a.mux.Unlock() + + a.avServer.Shutdown() + a.avEntryGroup = nil +} + +func (a *AvahiProvider) Announce(serviceName string, port int, txt []string) error { + a.mux.Lock() + defer a.mux.Unlock() + + // store the data for reconnection + a.mdnsServiceData = &mdnsServiceData{ + Name: serviceName, + Port: port, + Txt: txt, + } + + logging.Log().Debug("mdns: using avahi") + + var btxt [][]byte + for _, t := range txt { + btxt = append(btxt, []byte(t)) + } + + entryGroup, err := a.avServer.EntryGroupNew() + if err != nil { + return err + } + + for _, iface := range a.ifaceIndexes { + // conversion is safe, as port values are always positive + err = entryGroup.AddService(iface, avahi.ProtoUnspec, 0, serviceName, shipZeroConfServiceType, shipZeroConfDomain, "", uint16(port), btxt) // #nosec G115 + if err != nil { + return err + } + } + + err = entryGroup.Commit() + if err != nil { + return err + } + + a.avEntryGroup = entryGroup + + return nil +} + +func (a *AvahiProvider) Unannounce() { + a.mux.Lock() + defer a.mux.Unlock() + + // clean up the reconnection data + a.mdnsServiceData = nil + + if a.avEntryGroup == nil { + return + } + + a.avServer.EntryGroupFree(a.avEntryGroup) + a.avEntryGroup = nil +} + +func (a *AvahiProvider) avahiCallback(event avahi.Event) { + a.mux.Lock() + // if there is a manual shutdown, we do not want to reconnect + if a.manualShutdown || !a.autoReconnect || event != avahi.Disconnected { + a.mux.Unlock() + return + } + + logging.Log().Debug("mdns: avahi - disconnected") + + // the server was shutdown, set it to nil so we don't try to call free functions + // on shutting down a currently running resolve + cb := a.resolveCB + var serviceData *mdnsServiceData + if a.mdnsServiceData != nil { + serviceData = a.mdnsServiceData + } + a.mux.Unlock() + + // try to reconnect until successull + go a.attemptReconnect(cb, serviceData) +} + +// attempt to reconnect to the avahi daemon endlessly +func (a *AvahiProvider) attemptReconnect(cb api.MdnsResolveCB, serviceData *mdnsServiceData) { + for { + a.mux.Lock() + isManualShutdown := a.manualShutdown + a.mux.Unlock() + if isManualShutdown { + return + } + + <-time.After(time.Second) + + if !a.Start(true, cb) { + continue + } + + logging.Log().Debug("mdns: avahi - reconnected") + + if serviceData != nil { + if err := a.Announce(serviceData.Name, serviceData.Port, serviceData.Txt); err != nil { + logging.Log().Debug("mdns: avahi - error re-announcing service:", err) + } + } + + return + } +} + +// listen to service changes and shutdown +func (a *AvahiProvider) chanListener(cb api.MdnsResolveCB) { + for { + select { + case <-a.shutdownChan: + return + case service := <-a.addServiceChan: + if err := a.processService(service, false, cb); err != nil { + logging.Log().Debug("mdns: avahi -", err) + } + case service := <-a.removeServiceChan: + if err := a.processService(service, true, cb); err != nil { + logging.Log().Debug("mdns: avahi -", err) + } + } + } +} + +// process an avahi mDNS service +// as avahi returns a service per interface, we need to combine them +func (a *AvahiProvider) processService(service avahi.Service, remove bool, cb api.MdnsResolveCB) error { + // check if the service is within the allowed list + allow := false + if len(a.ifaceIndexes) == 1 && a.ifaceIndexes[0] == avahi.InterfaceUnspec { + allow = true + } else { + for _, iface := range a.ifaceIndexes { + if service.Interface == iface { + allow = true + break + } + } + } + + if !allow { + return fmt.Errorf("ignoring service as its interface is not in the allowed list: %s", service.Name) + } + + if remove { + return a.processRemovedService(service, cb) + } + + // resolve the new service + resolved, err := a.avServer.ResolveService(service.Interface, service.Protocol, service.Name, service.Type, service.Domain, avahi.ProtoUnspec, 0) + if err != nil { + return fmt.Errorf("error resolving service: %s error: %w", service.Name, err) + } + + return a.processAddedService(resolved, cb) +} + +func (a *AvahiProvider) processRemovedService(service avahi.Service, cb api.MdnsResolveCB) error { + logging.Log().Tracef("mdns: avahi - process remove service: %v", service) + + // get the elements for the service + a.muxEl.RLock() + elements := a.serviceElements[getServiceUniqueKey(service)] + a.muxEl.RUnlock() + + cb(elements, service.Name, service.Host, nil, -1, true) + + return nil +} + +func (a *AvahiProvider) processAddedService(service avahi.Service, cb api.MdnsResolveCB) error { + // convert [][]byte to []string manually + var txt []string + for _, element := range service.Txt { + txt = append(txt, string(element)) + } + elements := parseTxt(txt) + + logging.Log().Trace("mdns: avahi - process add service:", service.Name, service.Type, service.Domain, service.Host, service.Address, service.Port, elements) + + address := net.ParseIP(service.Address) + // if the address can not be used, ignore the entry + if address == nil || address.IsUnspecified() { + return fmt.Errorf("service provides unusable address: %s", service.Name) + } + + // add the elements to the map + a.muxEl.Lock() + a.serviceElements[getServiceUniqueKey(service)] = elements + a.muxEl.Unlock() + + cb(elements, service.Name, service.Host, []net.IP{address}, int(service.Port), false) + + return nil +} + +// Create a unique key for a ship service +func getServiceUniqueKey(service avahi.Service) string { + return fmt.Sprintf("%s-%s-%s-%d-%d", service.Name, service.Type, service.Domain, service.Protocol, service.Interface) +} diff --git a/src/eebus-bridge/third_party/ship-go/mdns/helper.go b/src/eebus-bridge/third_party/ship-go/mdns/helper.go new file mode 100644 index 0000000..c274428 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/helper.go @@ -0,0 +1,20 @@ +package mdns + +import ( + "strings" +) + +// parse mDNS text fields +func parseTxt(txt []string) map[string]string { + result := make(map[string]string) + + for _, item := range txt { + s := strings.Split(item, "=") + if len(s) != 2 { + continue + } + result[s[0]] = s[1] + } + + return result +} diff --git a/src/eebus-bridge/third_party/ship-go/mdns/mdns.go b/src/eebus-bridge/third_party/ship-go/mdns/mdns.go new file mode 100644 index 0000000..f21c631 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/mdns.go @@ -0,0 +1,495 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the provider is swapped and used under a lock (a closing +// connection's re-announcement during Shutdown dereferenced a nil +// provider), and nothing is reported after Shutdown. + +package mdns + +import ( + "errors" + "fmt" + "net" + "os" + "os/signal" + "sync" + "sync/atomic" + "syscall" + + "github.com/enbility/go-avahi" + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/util" +) + +const shipWebsocketPath = "/ship/" + +type MdnsProviderSelection uint + +const ( + MdnsProviderSelectionAll MdnsProviderSelection = iota // Automatically use avahi if available, otherwise use Go native Zeroconf, default + MdnsProviderSelectionAvahiOnly // Only use avahi + MdnsProviderSelectionGoZeroConfOnly // Only us Go native zeroconf +) + +type MdnsManager struct { + ski string + + // The deviceBrand of the device + deviceBrand string + + // The device model + deviceModel string + + // device type + deviceType string + + // the identifier to be used for mDNS and SHIP ID + identifier string + + // the name to be used as the mDNS service name + serviceName string + + // Network interface to use for the service + // Optional, if not set all detected interfaces will be used + ifaces []string + + // The port address of the websocket server + port int + + // Wether remote devices should be automatically accepted + autoaccept bool + + isAnnounced bool + + // the currently available mDNS entries with the SKI as the key in the map + entries map[string]*api.MdnsEntry + + // the registered callback, only connectionsHub is using this (under mux) + report api.MdnsReportInterface + + // read and used under muxProvider's read lock, replaced under its + // write lock (Start, Shutdown): an announcement never meets a provider + // that is being shut down, or a nil one after its check + mdnsProvider api.MdnsProviderInterface + muxProvider sync.RWMutex + + // set by Shutdown: no reports, no provider afterwards + isShutdown atomic.Bool + + shutdownOnce sync.Once + + providerSelection MdnsProviderSelection + + mux, + muxAnnounced sync.Mutex +} + +func NewMDNS( + ski, deviceBrand, deviceModel, deviceType, shipIdentifier, serviceName string, + port int, + ifaces []string, + providerSelection MdnsProviderSelection) *MdnsManager { + m := &MdnsManager{ + ski: ski, + deviceBrand: deviceBrand, + deviceModel: deviceModel, + deviceType: deviceType, + identifier: shipIdentifier, + serviceName: serviceName, + port: port, + ifaces: ifaces, + providerSelection: providerSelection, + entries: make(map[string]*api.MdnsEntry), + } + + return m +} + +// Return allowed interfaces for mDNS +func (m *MdnsManager) interfaces() ([]net.Interface, []int32, error) { + var ifaces []net.Interface + var ifaceIndexes []int32 + + if len(m.ifaces) > 0 { + ifaces = make([]net.Interface, len(m.ifaces)) + ifaceIndexes = make([]int32, len(m.ifaces)) + for i, ifaceName := range m.ifaces { + iface, err := net.InterfaceByName(ifaceName) + if err != nil { + return nil, nil, err + } + ifaces[i] = *iface + // conversion is safe, as the index is always positive and not higher than int32 + ifaceIndexes[i] = int32(iface.Index) // #nosec G115 + } + } + + if len(ifaces) == 0 { + ifaces = nil + ifaceIndexes = []int32{avahi.InterfaceUnspec} + } + + return ifaces, ifaceIndexes, nil +} + +var _ api.MdnsInterface = (*MdnsManager)(nil) + +func (m *MdnsManager) Start(cb api.MdnsReportInterface) error { + ifaces, ifaceIndexes, err := m.interfaces() + if err != nil { + return err + } + + var provider api.MdnsProviderInterface + switch m.providerSelection { + case MdnsProviderSelectionAll: + // First try avahi, if not available use zerconf + avahiProvider := NewAvahiProvider(ifaceIndexes) + if avahiProvider.Start(false, m.processMdnsEntry) { + provider = avahiProvider + } else { + avahiProvider.Shutdown() + + // Avahi is not availble, use Zeroconf + provider = NewZeroconfProvider(ifaces) + if !provider.Start(false, m.processMdnsEntry) { + return errors.New("No mDNS provider available") + } + } + case MdnsProviderSelectionAvahiOnly: + // Only use Avahi + provider = NewAvahiProvider(ifaceIndexes) + _ = provider.Start(true, m.processMdnsEntry) + case MdnsProviderSelectionGoZeroConfOnly: + // Only use Zeroconf + provider = NewZeroconfProvider(ifaces) + _ = provider.Start(true, m.processMdnsEntry) + } + + m.muxProvider.Lock() + if m.isShutdown.Load() { + // shut down while starting: this provider is not used + m.muxProvider.Unlock() + if provider != nil { + provider.Shutdown() + } + return nil + } + m.mdnsProvider = provider + m.muxProvider.Unlock() + + // on startup always start mDNS announcement + if err := m.AnnounceMdnsEntry(); err != nil { + return err + } + + m.mux.Lock() + m.report = cb + m.mux.Unlock() + + // catch signals + go func() { + signalC := make(chan os.Signal, 1) + signal.Notify(signalC, os.Interrupt, syscall.SIGTERM) + + <-signalC // wait for signal + + m.Shutdown() + }() + + return nil +} + +// Shutdown all of mDNS +func (m *MdnsManager) Shutdown() { + m.shutdownOnce.Do(func() { + m.UnannounceMdnsEntry() + + // under the provider lock: an announcement of a closing connection + // (Hub.checkAutoReannounce) either ends before or finds no provider + m.muxProvider.Lock() + defer m.muxProvider.Unlock() + + m.isShutdown.Store(true) + if m.mdnsProvider == nil { + return + } + + m.mdnsProvider.Shutdown() + m.mdnsProvider = nil + }) +} + +// Announces the service to the network via mDNS +// A CEM service should always invoke this on startup +// Any other service should only invoke this whenever it is not connected to a CEM service +func (m *MdnsManager) AnnounceMdnsEntry() error { + m.muxProvider.RLock() + defer m.muxProvider.RUnlock() + + if m.mdnsProvider == nil { + return nil + } + + serviceIdentifier := m.identifier + + txt := []string{ // SHIP 7.3.2 + "txtvers=1", + "path=" + shipWebsocketPath, + "id=" + serviceIdentifier, + "ski=" + m.ski, + "brand=" + m.deviceBrand, + "model=" + m.deviceModel, + "type=" + m.deviceType, + "register=" + fmt.Sprintf("%v", m.autoaccept), + } + + logging.Log().Debug("mdns: announce") + + serviceName := m.serviceName + + if err := m.mdnsProvider.Announce(serviceName, m.port, txt); err != nil { + logging.Log().Debug("mdns: failure announcing service", err) + return err + } + + m.mux.Lock() + defer m.mux.Unlock() + + m.setIsServiceAnnounce(true) + + return nil +} + +// Stop the mDNS announcement on the network +func (m *MdnsManager) UnannounceMdnsEntry() { + m.muxProvider.RLock() + defer m.muxProvider.RUnlock() + + if !m.isServiceAnnounced() || m.mdnsProvider == nil { + return + } + + m.mdnsProvider.Unannounce() + logging.Log().Debug("mdns: stop announcement") + + m.setIsServiceAnnounce(false) +} + +func (m *MdnsManager) isServiceAnnounced() bool { + m.muxAnnounced.Lock() + defer m.muxAnnounced.Unlock() + + return m.isAnnounced +} + +func (m *MdnsManager) setIsServiceAnnounce(value bool) { + m.muxAnnounced.Lock() + defer m.muxAnnounced.Unlock() + + m.isAnnounced = value +} + +func (m *MdnsManager) SetAutoAccept(accept bool) { + m.autoaccept = accept + + // if announcement is off, don't enforce a new announcement + if !m.isServiceAnnounced() { + return + } + + // Update the announcement as autoaccept changed + if err := m.AnnounceMdnsEntry(); err != nil { + logging.Log().Debug("mdns: changing mdns entry failed", err) + } +} + +func (m *MdnsManager) mdnsEntries() map[string]*api.MdnsEntry { + m.mux.Lock() + defer m.mux.Unlock() + + return m.entries +} + +func (m *MdnsManager) copyMdnsEntries() map[string]*api.MdnsEntry { + m.mux.Lock() + defer m.mux.Unlock() + + mdnsEntries := make(map[string]*api.MdnsEntry) + for k, v := range m.entries { + newEntry := &api.MdnsEntry{} + util.DeepCopy[*api.MdnsEntry](v, newEntry) + mdnsEntries[k] = newEntry + } + + return mdnsEntries +} + +func (m *MdnsManager) mdnsEntry(ski string) (*api.MdnsEntry, bool) { + m.mux.Lock() + defer m.mux.Unlock() + + entry, ok := m.entries[ski] + return entry, ok +} + +func (m *MdnsManager) setMdnsEntry(ski string, entry *api.MdnsEntry) { + m.mux.Lock() + defer m.mux.Unlock() + + m.entries[ski] = entry +} + +func (m *MdnsManager) removeMdnsEntry(ski string) { + m.mux.Lock() + defer m.mux.Unlock() + + delete(m.entries, ski) +} + +// process an mDNS entry and manage mDNS entries map +func (m *MdnsManager) processMdnsEntry(elements map[string]string, name, host string, addresses []net.IP, port int, remove bool) { + // check for mandatory text elements + mapItems := []string{"txtvers", "id", "path", "ski", "register"} + for _, item := range mapItems { + if _, ok := elements[item]; !ok { + logging.Log().Debug("mdns: txt - missing mandatory element", item) + return + } + } + + txtvers := elements["txtvers"] + // value of mandatory txtvers has to be 1 or the response be ignored: SHIP 7.3.2 + if txtvers != "1" { + logging.Log().Debug("mdns: txt - unknown txtvers", txtvers) + return + } + + identifier := elements["id"] + path := elements["path"] + ski := elements["ski"] + + // ignore own service + if ski == m.ski { + return + } + + register := elements["register"] + // register has to be a boolean + if register != "true" && register != "false" { + logging.Log().Debug("mdns: txt - register value is not a text boolean", register) + return + } + + // remove IPv6 local link addresses + var newAddresses []net.IP + for _, address := range addresses { + if address.To4() == nil && address.IsLinkLocalUnicast() { + continue + } + newAddresses = append(newAddresses, address) + } + addresses = newAddresses + + var deviceType, model, brand string + + if _, ok := elements["brand"]; ok { + brand = elements["brand"] + } + if _, ok := elements["type"]; ok { + deviceType = elements["type"] + } + if _, ok := elements["model"]; ok { + model = elements["model"] + } + + updated := false + + entry, exists := m.mdnsEntry(ski) + + if remove && exists { + updated = true + // remove + // there will be a remove for each address with avahi, but we'll delete it right away + m.removeMdnsEntry(ski) + + logging.Log().Debug("mdns: remove - ski:", ski, "name:", name, "brand:", brand, "model:", model, "typ:", deviceType, "identifier:", identifier, "register:", register, "host:", host, "port:", port, "addresses:", addresses) + } else if exists { + // avahi sends an item for each network address, merge them + + // we assume only network addresses are added + for _, address := range addresses { + // only add if it is not added yet + isNewElement := true + + for _, item := range entry.Addresses { + if item.String() == address.String() { + isNewElement = false + break + } + } + + if isNewElement { + entry.Addresses = append(entry.Addresses, address) + updated = true + } + } + + if updated { + m.setMdnsEntry(ski, entry) + + logging.Log().Debug("mdns: update - ski:", ski, "name:", name, "brand:", brand, "model:", model, "typ:", deviceType, "identifier:", identifier, "register:", register, "host:", host, "port:", port, "addresses:", addresses) + } + } else if !exists && !remove { + updated = true + // new + newEntry := &api.MdnsEntry{ + Name: name, + Ski: ski, + Identifier: identifier, + Path: path, + Register: register == "true", + Brand: brand, + Type: deviceType, + Model: model, + Host: host, + Port: port, + Addresses: addresses, + } + m.setMdnsEntry(ski, newEntry) + + logging.Log().Debug("mdns: new - ski:", ski, "name:", name, "brand:", brand, "model:", model, "typ:", deviceType, "identifier:", identifier, "register:", register, "host:", host, "port:", port, "addresses:", addresses) + } + + report := m.reportTarget() + if report == nil || !updated { + return + } + + entries := m.copyMdnsEntries() + go report.ReportMdnsEntries(entries, true) +} + +func (m *MdnsManager) RequestMdnsEntries() { + report := m.reportTarget() + if report == nil { + return + } + + entries := m.copyMdnsEntries() + go report.ReportMdnsEntries(entries, false) +} + +// the report callback, nil after Shutdown (not muxProvider: a provider's +// listener reports while Shutdown holds that lock and waits for it) +func (m *MdnsManager) reportTarget() api.MdnsReportInterface { + if m.isShutdown.Load() { + return nil + } + + m.mux.Lock() + defer m.mux.Unlock() + + return m.report +} diff --git a/src/eebus-bridge/third_party/ship-go/mdns/mdns_shutdown_test.go b/src/eebus-bridge/third_party/ship-go/mdns/mdns_shutdown_test.go new file mode 100644 index 0000000..18ff1b3 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/mdns_shutdown_test.go @@ -0,0 +1,92 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package mdns + +import ( + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/enbility/ship-go/api" +) + +// testProvider: counts calls, and any call after its Shutdown. +type testProvider struct { + down, late atomic.Int32 +} + +func (p *testProvider) Start(bool, api.MdnsResolveCB) bool { return true } +func (p *testProvider) Shutdown() { time.Sleep(time.Millisecond); p.down.Add(1) } +func (p *testProvider) Announce(string, int, []string) error { + if p.down.Load() > 0 { + p.late.Add(1) + } + time.Sleep(10 * time.Microsecond) + return nil +} +func (p *testProvider) Unannounce() { + if p.down.Load() > 0 { + p.late.Add(1) + } +} + +type testReport struct{ n atomic.Int32 } + +func (r *testReport) ReportMdnsEntries(map[string]*api.MdnsEntry, bool) { r.n.Add(1) } + +// Connections closing while the service shuts down announce again +// (Hub.checkAutoReannounce): before, the provider could turn nil between +// the check and the call (a nil dereference), or be used after its own +// Shutdown. Now an announcement ends before Shutdown takes the provider, +// or finds none; nothing is reported afterwards. +func TestAnnounceWhileShuttingDown(t *testing.T) { + for i := 0; i < 300; i++ { + p := &testProvider{} + rep := &testReport{} + m := NewMDNS("ski", "brand", "model", "type", "id", "name", 4711, nil, MdnsProviderSelectionGoZeroConfOnly) + m.mdnsProvider = p + m.report = rep + + var wg sync.WaitGroup + stop := make(chan struct{}) + for g := 0; g < 4; g++ { + wg.Add(1) + go func() { + defer wg.Done() + for { + select { + case <-stop: + return + default: + } + _ = m.AnnounceMdnsEntry() + m.RequestMdnsEntries() + m.UnannounceMdnsEntry() + } + }() + } + time.Sleep(time.Duration(i%5) * 50 * time.Microsecond) + m.Shutdown() + after := rep.n.Load() + time.Sleep(time.Millisecond) + close(stop) + wg.Wait() + + if p.late.Load() != 0 { + t.Fatalf("round %d: the provider was used %d times after its Shutdown", i, p.late.Load()) + } + if p.down.Load() != 1 { + t.Fatalf("round %d: provider shut down %d times", i, p.down.Load()) + } + // a report already started may still arrive; none is requested after + time.Sleep(time.Millisecond) + if n := rep.n.Load(); n > after+4 { + t.Fatalf("round %d: %d reports after Shutdown", i, n-after) + } + if err := m.AnnounceMdnsEntry(); err != nil { + t.Fatal(err) + } + } +} diff --git a/src/eebus-bridge/third_party/ship-go/mdns/types.go b/src/eebus-bridge/third_party/ship-go/mdns/types.go new file mode 100644 index 0000000..b331744 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/types.go @@ -0,0 +1,4 @@ +package mdns + +const shipZeroConfServiceType = "_ship._tcp" +const shipZeroConfDomain = "local." diff --git a/src/eebus-bridge/third_party/ship-go/mdns/zeroconf.go b/src/eebus-bridge/third_party/ship-go/mdns/zeroconf.go new file mode 100644 index 0000000..b94aae6 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/mdns/zeroconf.go @@ -0,0 +1,120 @@ +package mdns + +import ( + "context" + "net" + "sync" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/zeroconf/v2" +) + +type ZeroconfProvider struct { + ifaces []net.Interface + + zc *zeroconf.Server + + ctx context.Context + cancel context.CancelFunc + + mux sync.Mutex +} + +func NewZeroconfProvider(ifaces []net.Interface) *ZeroconfProvider { + return &ZeroconfProvider{ + ifaces: ifaces, + } +} + +var _ api.MdnsProviderInterface = (*ZeroconfProvider)(nil) + +func (z *ZeroconfProvider) Start(autoReconnect bool, cb api.MdnsResolveCB) bool { + go z.chanListener(cb) + + return true +} + +func (z *ZeroconfProvider) Shutdown() { + z.Unannounce() + + z.mux.Lock() + defer z.mux.Unlock() + + if z.cancel != nil { + z.cancel() + } +} + +func (z *ZeroconfProvider) Announce(serviceName string, port int, txt []string) error { + logging.Log().Debug("mdns: using zeroconf") + + // use Zeroconf library if avahi is not available + // Set TTL to 2 minutes as defined in SHIP chapter 7 + mDNSServer, err := zeroconf.Register(serviceName, shipZeroConfServiceType, shipZeroConfDomain, port, txt, z.ifaces, zeroconf.TTL(120)) + if err != nil { + return err + } + + z.mux.Lock() + defer z.mux.Unlock() + + z.zc = mDNSServer + + return nil +} + +func (z *ZeroconfProvider) Unannounce() { + z.mux.Lock() + defer z.mux.Unlock() + + if z.zc == nil { + return + } + + z.zc.Shutdown() + z.zc = nil +} + +func (z *ZeroconfProvider) chanListener(cb api.MdnsResolveCB) { + zcEntries := make(chan *zeroconf.ServiceEntry) + zcRemoved := make(chan *zeroconf.ServiceEntry) + + z.mux.Lock() + // for Zeroconf we need a context + z.ctx, z.cancel = context.WithCancel(context.Background()) + z.mux.Unlock() + + go func() { + _ = zeroconf.Browse(z.ctx, shipZeroConfServiceType, shipZeroConfDomain, zcEntries, zcRemoved) + }() + + for { + select { + case <-z.ctx.Done(): + return + case service := <-zcRemoved: + // Zeroconf has issues with merging mDNS data and sometimes reports incomplete records + if service == nil || len(service.Text) == 0 { + continue + } + + elements := parseTxt(service.Text) + + addresses := service.AddrIPv4 + cb(elements, service.Instance, service.HostName, addresses, service.Port, true) + + case service := <-zcEntries: + // Zeroconf has issues with merging mDNS data and sometimes reports incomplete records + if service == nil || len(service.Text) == 0 { + continue + } + + elements := parseTxt(service.Text) + + addresses := service.AddrIPv4 + addresses = append(addresses, service.AddrIPv6...) + cb(elements, service.Instance, service.HostName, addresses, service.Port, false) + } + } +} diff --git a/src/eebus-bridge/third_party/ship-go/model/model.go b/src/eebus-bridge/third_party/ship-go/model/model.go new file mode 100644 index 0000000..2eb8710 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/model/model.go @@ -0,0 +1,189 @@ +package model + +import "encoding/json" + +const ( + MsgTypeInit byte = 0 + MsgTypeControl byte = 1 + MsgTypeData byte = 2 + MsgTypeEnd byte = 3 +) + +const ( + ShipProtocolId = "ee1.0" +) + +type ConnectionHelloPhaseType string + +const ( + ConnectionHelloPhaseTypePending ConnectionHelloPhaseType = "pending" + ConnectionHelloPhaseTypeReady ConnectionHelloPhaseType = "ready" + ConnectionHelloPhaseTypeAborted ConnectionHelloPhaseType = "aborted" +) + +type ConnectionHello struct { + ConnectionHello ConnectionHelloType `json:"connectionHello"` +} + +type ConnectionHelloType struct { + Phase ConnectionHelloPhaseType `json:"phase"` + Waiting *uint `json:"waiting,omitempty"` + ProlongationRequest *bool `json:"prolongationRequest,omitempty"` +} + +type MessageProtocolFormatType string + +const ( + MessageProtocolFormatTypeUTF8 MessageProtocolFormatType = "JSON-UTF8" + MessageProtocolFormatTypeUTF16 MessageProtocolFormatType = "JSON-UTF16" +) + +type MessageProtocolFormatsType struct { + Format []MessageProtocolFormatType `json:"format"` +} + +type ProtocolHandshakeTypeType string + +const ( + ProtocolHandshakeTypeTypeAnnounceMax ProtocolHandshakeTypeType = "announceMax" + ProtocolHandshakeTypeTypeSelect ProtocolHandshakeTypeType = "select" +) + +type Version struct { + Major uint8 `json:"major"` + Minor uint8 `json:"minor"` +} + +type MessageProtocolHandshakeType struct { + HandshakeType ProtocolHandshakeTypeType `json:"handshakeType"` + Version Version `json:"version"` + Formats MessageProtocolFormatsType `json:"formats"` +} + +type MessageProtocolHandshake struct { + MessageProtocolHandshake MessageProtocolHandshakeType `json:"messageProtocolHandshake"` +} + +type MessageProtocolHandshakeErrorErrorType uint8 + +const ( + MessageProtocolHandshakeErrorErrorTypeRFU MessageProtocolHandshakeErrorErrorType = 0 + MessageProtocolHandshakeErrorErrorTypeTimeout MessageProtocolHandshakeErrorErrorType = 1 + MessageProtocolHandshakeErrorErrorTypeUnexpectedMessage MessageProtocolHandshakeErrorErrorType = 2 + MessageProtocolHandshakeErrorErrorTypeSelectionMismatch MessageProtocolHandshakeErrorErrorType = 3 +) + +type MessageProtocolHandshakeErrorType struct { + Error MessageProtocolHandshakeErrorErrorType `json:"error"` +} + +type PinStateType string + +const ( + PinStateTypeRequired PinStateType = "required" + PinStateTypeOptional PinStateType = "optional" + PinStateTypePinOk PinStateType = "pinOk" + PinStateTypeNone PinStateType = "none" +) + +type PinInputPermissionType string + +const ( + PinInputPermissionTypeBusy PinInputPermissionType = "busy" + PinInputPermissionTypeOk PinInputPermissionType = "ok" +) + +type MessageProtocolHandshakeError struct { + Error MessageProtocolHandshakeErrorErrorType `json:"error"` +} + +type ConnectionPinStateType struct { + PinState PinStateType `json:"pinState"` + InputPermission *PinInputPermissionType `json:"inputPermission,omitempty"` +} + +type ConnectionPinState struct { + ConnectionPinState ConnectionPinStateType `json:"connectionPinState"` +} + +type PinValueType string + +type ConnectionPinInputType struct { + Pin PinValueType `json:"pin"` +} + +type ConnectionPinErrorErrorType uint8 + +type ConnectionPinErrorType struct { + Error ConnectionPinErrorErrorType `json:"error"` +} + +type ProtocolIdType string + +type HeaderType struct { + ProtocolId ProtocolIdType `json:"protocolId"` +} + +type ExtensionType struct { + ExtensionId *string `json:"extensionId,omitempty"` + Binary *byte `json:"binary,omitempty"` // HexBinary + String *string `json:"string,omitempty"` +} + +type ShipData struct { + Data DataType `json:"data"` +} + +type DataType struct { + Header HeaderType `json:"header"` + Payload json.RawMessage `json:"payload"` + Extension *ExtensionType `json:"extension,omitempty"` +} + +type ConnectionClosePhaseType string + +const ( + ConnectionClosePhaseTypeAnnounce ConnectionClosePhaseType = "announce" + ConnectionClosePhaseTypeConfirm ConnectionClosePhaseType = "confirm" +) + +type ConnectionCloseReasonType string + +const ( + ConnectionCloseReasonTypeUnspecific ConnectionCloseReasonType = "unspecific" + ConnectionCloseReasonTypeRemovedconnection ConnectionCloseReasonType = "removedConnection" +) + +type ConnectionClose struct { + ConnectionClose ConnectionCloseType `json:"connectionClose"` +} + +type ConnectionCloseType struct { + Phase ConnectionClosePhaseType `json:"phase"` + MaxTime *uint `json:"maxTime,omitempty"` + Reason *ConnectionCloseReasonType `json:"reason,omitempty"` +} + +type AccessMethodsRequest struct { + AccessMethodsRequest AccessMethodsRequestType `json:"accessMethodsRequest"` +} + +type AccessMethodsRequestType struct{} + +type Dns struct { + Uri string `json:"uri"` +} + +type DnsSdMDns struct { +} + +type AccessMethods struct { + AccessMethods AccessMethodsType `json:"accessMethods"` +} + +type AccessMethodsType struct { + Id *string `json:"id"` + DnsSdMDns *DnsSdMDns `json:"dnsSd_mDns,omitempty"` + // According to the Spec Dns should be of type *Dns, but the SHM 2.0 only uses a string and would cause a crash + Dns *string `json:"dns,omitempty"` +} diff --git a/src/eebus-bridge/third_party/ship-go/model/types.go b/src/eebus-bridge/third_party/ship-go/model/types.go new file mode 100644 index 0000000..8df34e3 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/model/types.go @@ -0,0 +1,66 @@ +package model + +type ShipState struct { + State ShipMessageExchangeState + Error error +} + +type ShipMessageExchangeState uint + +// set the values manually instead of using iota, so log data can be associated easier +const ( + // Connection Mode Initialisation (CMI) SHIP 13.4.3 + CmiStateInitStart ShipMessageExchangeState = 0 + CmiStateClientSend ShipMessageExchangeState = 1 + CmiStateClientWait ShipMessageExchangeState = 2 + CmiStateClientEvaluate ShipMessageExchangeState = 3 + CmiStateServerWait ShipMessageExchangeState = 4 + CmiStateServerEvaluate ShipMessageExchangeState = 5 + // Connection Data Preparation SHIP 13.4.4 + SmeHelloState ShipMessageExchangeState = 6 + SmeHelloStateReadyInit ShipMessageExchangeState = 7 + SmeHelloStateReadyListen ShipMessageExchangeState = 8 + SmeHelloStateReadyTimeout ShipMessageExchangeState = 9 + SmeHelloStatePendingInit ShipMessageExchangeState = 10 + SmeHelloStatePendingListen ShipMessageExchangeState = 11 + SmeHelloStatePendingTimeout ShipMessageExchangeState = 12 + SmeHelloStateOk ShipMessageExchangeState = 13 + SmeHelloStateAbort ShipMessageExchangeState = 14 // Sent abort to remote + SmeHelloStateAbortDone ShipMessageExchangeState = 15 // Sending abort to remote is done + SmeHelloStateRemoteAbortDone ShipMessageExchangeState = 16 // Received abort from remote + SmeHelloStateRejected ShipMessageExchangeState = 17 // Connection closed after remote pending: "4452: Node rejected by application" + + // Connection State Protocol Handhsake SHIP 13.4.4.2 + SmeProtHStateServerInit ShipMessageExchangeState = 18 + SmeProtHStateClientInit ShipMessageExchangeState = 19 + SmeProtHStateServerListenProposal ShipMessageExchangeState = 20 + SmeProtHStateServerListenConfirm ShipMessageExchangeState = 21 + SmeProtHStateClientListenChoice ShipMessageExchangeState = 22 + SmeProtHStateTimeout ShipMessageExchangeState = 23 + SmeProtHStateClientOk ShipMessageExchangeState = 24 + SmeProtHStateServerOk ShipMessageExchangeState = 25 + // Connection PIN State 13.4.5 + SmePinStateCheckInit ShipMessageExchangeState = 26 + SmePinStateCheckListen ShipMessageExchangeState = 27 + SmePinStateCheckError ShipMessageExchangeState = 28 + SmePinStateCheckBusyInit ShipMessageExchangeState = 29 + SmePinStateCheckBusyWait ShipMessageExchangeState = 30 + SmePinStateCheckOk ShipMessageExchangeState = 31 + SmePinStateAskInit ShipMessageExchangeState = 32 + SmePinStateAskProcess ShipMessageExchangeState = 33 + SmePinStateAskRestricted ShipMessageExchangeState = 34 + SmePinStateAskOk ShipMessageExchangeState = 35 + // ConnectionAccess Methods Identification 13.4.6 + SmeAccessMethodsRequest ShipMessageExchangeState = 36 + + // Handshake approved on both ends + SmeStateApproved ShipMessageExchangeState = 37 + + // Handshake process is successfully completed + SmeStateComplete ShipMessageExchangeState = 38 + + // Handshake ended with an error + SmeStateError ShipMessageExchangeState = 39 +) + +var ShipInit []byte = []byte{MsgTypeInit, 0x00} diff --git a/src/eebus-bridge/third_party/ship-go/ship/connection.go b/src/eebus-bridge/third_party/ship-go/ship/connection.go new file mode 100644 index 0000000..98e8d7b --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/connection.go @@ -0,0 +1,451 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: a write that finds the data connection closed closes the SHIP +// connection on its own goroutine (it deadlocked with SPINE's locks, or +// with the close's own Once); approving or aborting a pending handshake is a +// check-and-set of the state. + +package ship + +import ( + "bytes" + "encoding/json" + "errors" + "strings" + "sync" + "time" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/model" + "github.com/enbility/ship-go/util" +) + +// A ShipConnection handles the data connection and coordinates SHIP and SPINE messages i/o +type ShipConnection struct { + // The ship connection mode of this connection + role shipRole + + // The remote SKI + remoteSKI string + + // the remote SHIP Id + remoteShipID string + + // The local SHIP ID + localShipID string + + // data provider + infoProvider api.ShipConnectionInfoProviderInterface + + // Where to pass incoming SPINE messages to + dataReader api.ShipConnectionDataReaderInterface + + // the (web socket) handler for sending messages + dataWriter api.WebsocketDataWriterInterface + + // The current SHIP state + smeState model.ShipMessageExchangeState + + // the current error value if SHIP state is in error + smeError error + + // handles timeouts for the various states + // + // WaitForReady SHIP 13.4.4.1.3: The communication partner must send its "READY" state (or request for prolongation") before the timer expires. + // + // SendProlongationRequest SHIP 13.4.4.1.3: Local timer to request for prolongation at the communication partner in time (i.e. before the communication partner's Wait-For-Ready-Timer expires). + // + // ProlongationRequestReply SHIP 13.4.4.1.3: Detection of response timeout on prolongation request. + handshakeTimerRunning bool + handshakeTimerType timeoutTimerType + handshakeTimerStopChan chan struct{} + handshakeTimerMux sync.Mutex + handshakeTimerGen uint64 // the current timer's generation (handshakeTimerFired) + + lastReceivedWaitingValue time.Duration // required for Prolong-Request-Reply-Timer + + shutdownOnce sync.Once + + // buffer for SPINE messages that came in before the handshake was completed + spineBuffer [][]byte + + mux sync.Mutex + bufferMux sync.Mutex +} + +var _ api.ShipConnectionInterface = (*ShipConnection)(nil) + +func NewConnectionHandler( + dataProvider api.ShipConnectionInfoProviderInterface, + dataHandler api.WebsocketDataWriterInterface, + role shipRole, + localShipID, + remoteSki, + remoteShipId string) *ShipConnection { + ship := &ShipConnection{ + infoProvider: dataProvider, + dataWriter: dataHandler, + role: role, + localShipID: localShipID, + remoteSKI: remoteSki, + remoteShipID: remoteShipId, + smeState: model.CmiStateInitStart, + smeError: nil, + } + + ship.handshakeTimerStopChan = make(chan struct{}) + + if dataHandler != nil { + dataHandler.InitDataProcessing(ship) + } + + return ship +} + +func (c *ShipConnection) RemoteSKI() string { + return c.remoteSKI +} + +func (c *ShipConnection) DataHandler() api.WebsocketDataWriterInterface { + return c.dataWriter +} + +// start SHIP communication +func (c *ShipConnection) Run() { + c.handleShipMessage(false, nil) +} + +// provides the current ship state and error value if the state is in error +func (c *ShipConnection) ShipHandshakeState() (model.ShipMessageExchangeState, error) { + return c.getState(), c.smeError +} + +// invoked when pairing for a pending request is approved +func (c *ShipConnection) ApprovePendingHandshake() { + // leave PENDING_LISTEN as one check-and-set: the trust + // (Hub.RegisterRemoteSKI), the connection's own check + // (approveWhenTrusted), the read pump and the hello timer may all try at + // once, and only the first moves on ("ready" is sent once) + if !c.changeState([]model.ShipMessageExchangeState{model.SmeHelloStatePendingListen}, model.SmeHelloStateReadyInit, nil) { + return + } + + // HELLO_OK + c.stopHandshakeTimer() + c.handleState(false, nil) + + // HELLO_OK from READY_LISTEN only, as a check-and-set like every other + // transition out of it: if the read pump or the timer moved on meanwhile + // (the remote aborted, a timeout), nothing more here + c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateOk) +} + +// invoked when pairing for a pending request is denied +func (c *ShipConnection) AbortPendingHandshake() { + if !c.changeState([]model.ShipMessageExchangeState{model.SmeHelloStatePendingListen, model.SmeHelloStateReadyListen}, + model.SmeHelloStateAbort, nil) { + return + } + + c.stopHandshakeTimer() + c.handleState(false, nil) +} + +// close this ship connection +func (c *ShipConnection) CloseConnection(safe bool, code int, reason string) { + c.shutdownOnce.Do(func() { + c.stopHandshakeTimer() + + // handshake is completed if approved or aborted + state := c.getState() + handshakeEnd := state == model.SmeStateComplete || + state == model.SmeHelloStateAbortDone || + state == model.SmeHelloStateRemoteAbortDone || + state == model.SmeHelloStateRejected + + // this may not be used for Connection Data Exchange is entered! + if safe && state == model.SmeStateComplete { + // SHIP 13.4.7: Connection Termination Announce + closeMessage := model.ConnectionClose{ + ConnectionClose: model.ConnectionCloseType{ + Phase: model.ConnectionClosePhaseTypeAnnounce, + MaxTime: util.Ptr(uint(500)), + Reason: util.Ptr(model.ConnectionCloseReasonType(reason)), + }, + } + + _ = c.sendShipModel(model.MsgTypeEnd, closeMessage) + + go func() { + // wait a bit to let it send + <-time.After(500 * time.Millisecond) + + // + c.dataWriter.CloseDataConnection(4001, "close") + c.infoProvider.HandleConnectionClosed(c, handshakeEnd) + }() + return + } + + closeCode := 4001 + if code != 0 { + closeCode = code + } + c.dataWriter.CloseDataConnection(closeCode, reason) + + c.infoProvider.HandleConnectionClosed(c, handshakeEnd) + }) +} + +var _ api.ShipConnectionDataWriterInterface = (*ShipConnection)(nil) + +// SpineDataConnection interface implementation +func (c *ShipConnection) WriteShipMessageWithPayload(message []byte) { + if err := c.sendSpineData(message); err != nil { + logging.Log().Debug(c.RemoteSKI(), "Error sending spine message: ", err) + return + } +} + +var _ api.WebsocketDataReaderInterface = (*ShipConnection)(nil) + +func (c *ShipConnection) shipModelFromMessage(message []byte) (*model.ShipData, error) { + _, jsonData := c.parseMessage(message, true) + + // Get the datagram from the message + data := model.ShipData{} + if err := json.Unmarshal(jsonData, &data); err != nil { + logging.Log().Debug(c.RemoteSKI(), "error unmarshalling message: ", err) + return nil, err + } + + if data.Data.Payload == nil { + errorMsg := "received no valid payload" + logging.Log().Debug(c.RemoteSKI(), errorMsg) + return nil, errors.New(errorMsg) + } + + return &data, nil +} + +// process any SPINE messages that came in before the handshake completed +// this will be called once the handshake is completed and +// spineDataProcessing is set +func (c *ShipConnection) processBufferedSpineMessages() { + c.bufferMux.Lock() + defer c.bufferMux.Unlock() + + for _, item := range c.spineBuffer { + c.dataReader.HandleShipPayloadMessage(item) + } + + c.spineBuffer = nil +} + +// route the incoming message to either SHIP or SPINE message handlers +func (c *ShipConnection) HandleIncomingWebsocketMessage(message []byte) { + // Check if this is a SHIP SME or SPINE message + if !c.hasSpineDatagram(message) { + c.handleShipMessage(false, message) + return + } + + data, err := c.shipModelFromMessage(message) + if err != nil { + return + } + + if c.dataReader == nil { + // buffer message for processing once the handshake is completed + c.bufferMux.Lock() + defer c.bufferMux.Unlock() + + c.spineBuffer = append(c.spineBuffer, []byte(data.Data.Payload)) + + return + } + + // pass the payload to the SPINE read handler + c.dataReader.HandleShipPayloadMessage([]byte(data.Data.Payload)) +} + +// checks wether the provided messages is a SHIP message +func (c *ShipConnection) hasSpineDatagram(message []byte) bool { + return bytes.Contains(message, []byte("datagram")) +} + +// the websocket data connection was closed from remote +func (c *ShipConnection) ReportConnectionError(err error) { + // if the handshake is aborted, a closed connection is no error + currentState := c.getState() + + // rejections are also received by sending `{"connectionHello":[{"phase":"pending"},{"waiting":60000}]}` + // and then closing the websocket connection with `4452: Node rejected by application.` + if currentState == model.SmeHelloStateReadyListen { + c.setState(model.SmeHelloStateRejected, nil) + c.CloseConnection(false, 0, "") + return + } + + if currentState == model.SmeHelloStateRemoteAbortDone { + // remote service should close the connection + c.CloseConnection(false, 0, "") + return + } + + if currentState == model.SmeHelloStateAbort || + currentState == model.SmeHelloStateAbortDone { + c.CloseConnection(false, 4452, "Node rejected by application") + return + } + + c.setState(model.SmeStateError, err) + + c.CloseConnection(false, 0, "") + + state := model.ShipState{ + State: model.SmeStateError, + Error: err, + } + c.infoProvider.HandleShipHandshakeStateUpdate(c.remoteSKI, state) +} + +const payloadPlaceholder = `{"place":"holder"}` + +func (c *ShipConnection) transformSpineDataIntoShipJson(data []byte) ([]byte, error) { + spineMsg, err := JsonIntoEEBUSJson(data) + if err != nil { + return nil, err + } + + payload := json.RawMessage([]byte(spineMsg)) + + // Workaround for the fact that SHIP payload is a json.RawMessage + // which would also be transformed into an array element but it shouldn't + // hence patching the payload into the message later after the SHIP + // and SPINE model are transformed independently + + // Create the message + shipMessage := model.ShipData{ + Data: model.DataType{ + Header: model.HeaderType{ + ProtocolId: model.ShipProtocolId, + }, + Payload: json.RawMessage([]byte(payloadPlaceholder)), + }, + } + + msg, err := json.Marshal(shipMessage) + if err != nil { + return nil, err + } + + eebusMsg, err := JsonIntoEEBUSJson(msg) + if err != nil { + return nil, err + } + + eebusMsg = strings.ReplaceAll(eebusMsg, `[`+payloadPlaceholder+`]`, string(payload)) + + return []byte(eebusMsg), nil +} + +func (c *ShipConnection) sendSpineData(data []byte) error { + eebusMsg, err := c.transformSpineDataIntoShipJson(data) + if err != nil { + return err + } + + if isClosed, err := c.dataWriter.IsDataConnectionClosed(); isClosed { + // not on the writer's goroutine: SPINE writes while holding its own + // locks, and the close reports up into SPINE (HandleConnectionClosed) + // while holding this connection's close Once: a lock-order deadlock + go c.CloseConnection(false, 0, "") + return err + } + + // Wrap the message into a binary message with the ship header + shipMsg := []byte{model.MsgTypeData} + shipMsg = append(shipMsg, eebusMsg...) + + err = c.dataWriter.WriteMessageToWebsocketConnection(shipMsg) + if err != nil { + logging.Log().Debug("error sending message: ", err) + return err + } + + return nil +} + +// send a json message for a provided model to the websocket connection +func (c *ShipConnection) sendShipModel(typ byte, model interface{}) error { + shipMsg, err := c.shipMessage(typ, model) + if err != nil { + return err + } + + err = c.dataWriter.WriteMessageToWebsocketConnection(shipMsg) + if err != nil { + return err + } + + return nil +} + +// Process a SHIP Json message +func (c *ShipConnection) processShipJsonMessage(message []byte, target any) error { + _, data := c.parseMessage(message, true) + + return json.Unmarshal(data, &target) +} + +// transform a SHIP model into EEBUS specific JSON +func (c *ShipConnection) shipMessage(typ byte, model interface{}) ([]byte, error) { + if isClosed, err := c.dataWriter.IsDataConnectionClosed(); isClosed { + // asynchronously: CloseConnection's own announce (safe close) comes + // here inside the close Once, which would wait for itself + go c.CloseConnection(false, 0, "") + return nil, err + } + + if model == nil { + return nil, errors.New("invalid data") + } + + msg, err := json.Marshal(model) + if err != nil { + return nil, err + } + + eebusMsg, err := JsonIntoEEBUSJson(msg) + if err != nil { + return nil, err + } + + // Wrap the message into a binary message with the ship header + shipMsg := []byte{typ} + shipMsg = append(shipMsg, eebusMsg...) + + return shipMsg, nil +} + +// return the SHIP message type, the SHIP message and an error +// +// enable jsonFormat if the return message is expected to be encoded in the eebus json format +func (c *ShipConnection) parseMessage(msg []byte, jsonFormat bool) (byte, []byte) { + if len(msg) == 0 { + return 0, nil + } + + // Extract the SHIP header byte + shipHeaderByte := msg[0] + // remove the SHIP header byte from the message + msg = msg[1:] + + if jsonFormat { + return shipHeaderByte, JsonFromEEBUSJson(msg) + } + + return shipHeaderByte, msg +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/handshake.go b/src/eebus-bridge/third_party/ship-go/ship/handshake.go new file mode 100644 index 0000000..828f7ef --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/handshake.go @@ -0,0 +1,361 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: a panic in the handshake timer's goroutine closes only its +// connection; a state change can be a check-and-set (changeState), used by +// every transition out of PENDING_LISTEN and READY_LISTEN; a handshake +// timer acts only if it is still the current one (its generation), so one +// that fired while the state moved on doesn't time out the new state. + +package ship + +import ( + "errors" + "runtime/debug" + "slices" + "time" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/model" +) + +// handle incoming SHIP messages and coordinate Handshake States +func (c *ShipConnection) handleShipMessage(timeout bool, message []byte) { + if len(message) > 2 { + var closeMsg model.ConnectionClose + err := c.processShipJsonMessage(message, &closeMsg) + if err == nil && closeMsg.ConnectionClose.Phase != "" { + switch closeMsg.ConnectionClose.Phase { + case model.ConnectionClosePhaseTypeAnnounce: + // SHIP 13.4.7: Connection Termination Confirm + closeMessage := model.ConnectionClose{ + ConnectionClose: model.ConnectionCloseType{ + Phase: model.ConnectionClosePhaseTypeConfirm, + }, + } + + _ = c.sendShipModel(model.MsgTypeEnd, closeMessage) + + // wait a bit to let it send + <-time.After(500 * time.Millisecond) + + // + c.dataWriter.CloseDataConnection(4001, "close") + c.infoProvider.HandleConnectionClosed(c, c.getState() == model.SmeStateComplete) + case model.ConnectionClosePhaseTypeConfirm: + // we got a confirmation so close this connection + c.dataWriter.CloseDataConnection(4001, "close") + c.infoProvider.HandleConnectionClosed(c, c.getState() == model.SmeStateComplete) + } + + return + } + } + + c.handleState(timeout, message) +} + +// set a new handshake state and handle timers if needed +func (c *ShipConnection) setState(newState model.ShipMessageExchangeState, err error) { + c.changeState(nil, newState, err) +} + +// leavePendingListen: the transitions out of SME_HELLO_STATE_PENDING_LISTEN +// (the read pump's and the hello timer's) as a check-and-set, like the +// approval's: of two at once, only the first moves on. +func (c *ShipConnection) leavePendingListen(newState model.ShipMessageExchangeState) { + c.leaveState(model.SmeHelloStatePendingListen, newState) +} + +// leaveState: a transition from the state it was decided in, as a +// check-and-set (nothing when the state moved on meanwhile), then handled. +func (c *ShipConnection) leaveState(from, newState model.ShipMessageExchangeState) { + if c.changeState([]model.ShipMessageExchangeState{from}, newState, nil) { + c.handleState(false, nil) + } +} + +// changeState: set the state if it is one of from (nil: any), as one check +// and set under the state's lock; false when it wasn't. +func (c *ShipConnection) changeState(from []model.ShipMessageExchangeState, newState model.ShipMessageExchangeState, err error) bool { + c.mux.Lock() + + if from != nil && !slices.Contains(from, c.smeState) { + c.mux.Unlock() + return false + } + + oldState := c.smeState + + c.smeState = newState + logging.Log().Trace(c.RemoteSKI(), "SHIP state changed to:", newState) + + switch newState { + case model.SmeHelloStateReadyInit: + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, tHelloInit) + case model.SmeHelloStatePendingInit: + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, tHelloInit) + case model.SmeHelloStateOk: + c.stopHandshakeTimer() + case model.SmeHelloStateAbort, model.SmeHelloStateAbortDone, model.SmeHelloStateRemoteAbortDone, model.SmeHelloStateRejected: + c.stopHandshakeTimer() + case model.SmeProtHStateClientListenChoice: + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, cmiTimeout) + case model.SmeProtHStateClientOk: + c.stopHandshakeTimer() + } + + c.smeError = nil + if oldState != newState { + c.smeError = err + state := model.ShipState{ + State: newState, + Error: err, + } + c.mux.Unlock() + c.infoProvider.HandleShipHandshakeStateUpdate(c.remoteSKI, state) + return true + } + c.mux.Unlock() + return true +} + +func (c *ShipConnection) getState() model.ShipMessageExchangeState { + c.mux.Lock() + defer c.mux.Unlock() + + return c.smeState +} + +// handle handshake state transitions +func (c *ShipConnection) handleState(timeout bool, message []byte) { + switch c.getState() { + case model.SmeStateError: + logging.Log().Debug(c.RemoteSKI(), "connection is in error state") + return + + // cmiStateInit + case model.CmiStateInitStart: + // triggered without a message received + c.handshakeInit_cmiStateInitStart() + + case model.CmiStateClientWait: + if timeout { + c.endHandshakeWithError(errors.New("ship client handshake timeout")) + return + } + + c.handshakeInit_cmiStateClientWait(message) + + case model.CmiStateServerWait: + if timeout { + c.endHandshakeWithError(errors.New("ship server handshake timeout")) + return + } + c.handshakeInit_cmiStateServerWait(message) + + // smeHello + + case model.SmeHelloState: + // check if the service is already trusted, auto accept is true or the role is client, + // which means it was initiated from this service usually by triggering the + // pairing service + // go to substate ready if so, otherwise to substate pending + + if c.infoProvider.IsRemoteServiceForSKIPaired(c.remoteSKI) || + c.infoProvider.IsAutoAcceptEnabled() || + c.role == ShipRoleClient { + c.setState(model.SmeHelloStateReadyInit, nil) + } else { + c.setState(model.SmeHelloStatePendingInit, nil) + } + c.handleState(timeout, message) + + case model.SmeHelloStateReadyInit: + c.handshakeHello_Init() + + case model.SmeHelloStateReadyListen: + c.handshakeHello_ReadyListen(timeout, message) + + case model.SmeHelloStatePendingInit: + c.handshakeHello_PendingInit() + + case model.SmeHelloStatePendingListen: + c.handshakeHello_PendingListen(timeout, message) + + case model.SmeHelloStateOk: + c.handshakeProtocol_Init() + + case model.SmeHelloStateAbort: + c.handshakeHello_Abort() + + case model.SmeHelloStateAbortDone, model.SmeHelloStateRemoteAbortDone: + go func() { + <-time.After(time.Second) + c.CloseConnection(false, 4452, "Node rejected by application") + }() + + // smeProtocol + + case model.SmeProtHStateServerListenProposal: + c.handshakeProtocol_smeProtHStateServerListenProposal(message) + + case model.SmeProtHStateServerListenConfirm: + c.handshakeProtocol_smeProtHStateServerListenConfirm(message) + + case model.SmeProtHStateClientListenChoice: + c.stopHandshakeTimer() + c.handshakeProtocol_smeProtHStateClientListenChoice(message) + + case model.SmeProtHStateClientOk: + c.setAndHandleState(model.SmePinStateCheckInit) + + case model.SmeProtHStateServerOk: + c.setAndHandleState(model.SmePinStateCheckInit) + + // smePinState + + case model.SmePinStateCheckInit: + c.handshakePin_Init() + + case model.SmePinStateCheckListen: + c.handshakePin_smePinStateCheckListen(message) + + case model.SmePinStateCheckOk: + c.handshakeAccessMethods_Init() + + // smeAccessMethods + + case model.SmeAccessMethodsRequest: + c.handshakeAccessMethods_Request(message) + } +} + +// set a state and trigger handling it +func (c *ShipConnection) setAndHandleState(state model.ShipMessageExchangeState) { + c.setState(state, nil) + c.handleState(false, nil) +} + +// SHIP handshake is approved, now set the new state and the SPINE read handler +func (c *ShipConnection) approveHandshake() { + // Report to SPINE local device about this remote device connection + c.dataReader = c.infoProvider.SetupRemoteDevice(c.remoteSKI, c) + c.stopHandshakeTimer() + c.setState(model.SmeStateComplete, nil) + c.processBufferedSpineMessages() +} + +// end the handshake process because of an error +func (c *ShipConnection) endHandshakeWithError(err error) { + c.stopHandshakeTimer() + + c.setState(model.SmeStateError, err) + + logging.Log().Debug(c.RemoteSKI(), "SHIP handshake error:", err) + + c.CloseConnection(true, 0, err.Error()) + + state := model.ShipState{ + State: model.SmeStateError, + Error: err, + } + c.infoProvider.HandleShipHandshakeStateUpdate(c.remoteSKI, state) +} + +// set the handshake timer to a new duration and start the channel +func (c *ShipConnection) setHandshakeTimer(timerType timeoutTimerType, duration time.Duration) { + c.stopHandshakeTimer() + + gen := c.nextHandshakeTimerGen() + c.setHandshakeTimerRunning(true) + c.setHandshakeTimerType(timerType) + + go func() { + defer func() { + if r := recover(); r != nil { + logging.Log().Error(c.remoteSKI, "panic in the handshake timer:", r, string(debug.Stack())) + c.CloseConnection(false, 0, "") + } + }() + + select { + case <-c.handshakeTimerStopChan: + return + case <-time.After(duration): + // only the timer armed last, and not stopped since: a timer + // that fired while the state moved on (e.g. an approval) is + // stale and must not time out the new state + if !c.handshakeTimerFired(gen) { + return + } + c.handleState(true, nil) + return + } + }() +} + +// stop the handshake timer and close the channel +func (c *ShipConnection) stopHandshakeTimer() { + // a new generation: the stopped timer can't act even if its stop signal + // below doesn't reach it (it may have fired already) + c.nextHandshakeTimerGen() + if !c.getHandshakeTimerRunning() { + return + } + + select { + case c.handshakeTimerStopChan <- struct{}{}: + default: + } + c.setHandshakeTimerRunning(false) +} + +// nextHandshakeTimerGen: a new timer generation (arming or stopping). +func (c *ShipConnection) nextHandshakeTimerGen() uint64 { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + c.handshakeTimerGen++ + return c.handshakeTimerGen +} + +// handshakeTimerFired: whether the timer of this generation is still the +// current one (then it is no longer running), as one check-and-set. +func (c *ShipConnection) handshakeTimerFired(gen uint64) bool { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + if gen != c.handshakeTimerGen { + return false + } + c.handshakeTimerRunning = false + return true +} + +func (c *ShipConnection) setHandshakeTimerRunning(value bool) { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + c.handshakeTimerRunning = value +} + +func (c *ShipConnection) getHandshakeTimerRunning() bool { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + return c.handshakeTimerRunning +} + +func (c *ShipConnection) setHandshakeTimerType(timerType timeoutTimerType) { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + c.handshakeTimerType = timerType +} + +func (c *ShipConnection) getHandshakeTimerType() timeoutTimerType { + c.handshakeTimerMux.Lock() + defer c.handshakeTimerMux.Unlock() + + return c.handshakeTimerType +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/helper.go b/src/eebus-bridge/third_party/ship-go/ship/helper.go new file mode 100644 index 0000000..fb527d3 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/helper.go @@ -0,0 +1,79 @@ +package ship + +import ( + "bytes" + "encoding/json" + "strings" + + "gitlab.com/c0b/go-ordered-json" +) + +// convert incoming EEBUS json format into standard json format +func JsonFromEEBUSJson(json []byte) []byte { + var result = bytes.ReplaceAll(json, []byte("[{"), []byte("{")) + result = bytes.ReplaceAll(result, []byte("},{"), []byte(",")) + result = bytes.ReplaceAll(result, []byte("}]"), []byte("}")) + result = bytes.ReplaceAll(result, []byte("[]"), []byte("{}")) + // The PMCP device mistakenly adds an `0x00` byte at the end of many messages. + result = bytes.Trim(result, "\x00") + return result +} + +// convert objects in json to be arrays with each field being an array alement as eebus expects it +func process_eebus_json_hierarchie_level(data interface{}) interface{} { + temp := data + switch temp.(type) { + case *ordered.OrderedMap: + var new_array []interface{} = make([]interface{}, 0) + + orderedData := data.(*ordered.OrderedMap) + iter := orderedData.EntriesIter() + for { + pair, ok := iter() + if !ok { + break + } + var new_value = process_eebus_json_hierarchie_level(pair.Value) + var new_object = map[string]interface{}{pair.Key: new_value} + new_array = append(new_array, new_object) + } + return new_array + + case []interface{}: + var new_array []interface{} = make([]interface{}, 0) + for _, value := range data.([]interface{}) { + var new_value = process_eebus_json_hierarchie_level(value) + new_array = append(new_array, new_value) + } + return new_array + default: + return data + } +} + +// convert json into the EEBUS json format +func JsonIntoEEBUSJson(data []byte) (string, error) { + // EEBUS defines the items to be ordered in the array, + // so we can't use map[string]interface{} as that would + // cause a random order when Unmarshalling + var temp *ordered.OrderedMap = ordered.NewOrderedMap() + + if err := json.Unmarshal(data, &temp); err != nil { + return "", err + } + + var result = process_eebus_json_hierarchie_level(temp) + + var b, err = json.Marshal(result) + if err != nil { + return "", err + } + + var json = string(b) + + // we are lazy: fix the first item being put into an array + json = strings.TrimPrefix(json, "[") + json = strings.TrimSuffix(json, "]") + + return json, nil +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_access.go b/src/eebus-bridge/third_party/ship-go/ship/hs_access.go new file mode 100644 index 0000000..c87a930 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_access.go @@ -0,0 +1,80 @@ +package ship + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + + "github.com/enbility/ship-go/model" +) + +// Handshake Access covers the states smeAccess... + +func (c *ShipConnection) handshakeAccessMethods_Init() { + // Access Methods + accessMethodsRequest := model.AccessMethodsRequest{ + AccessMethodsRequest: model.AccessMethodsRequestType{}, + } + + if err := c.sendShipModel(model.MsgTypeControl, accessMethodsRequest); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, cmiTimeout) + c.setState(model.SmeAccessMethodsRequest, nil) +} + +func (c *ShipConnection) handshakeAccessMethods_Request(message []byte) { + _, data := c.parseMessage(message, true) + + dataString := string(data) + + if strings.Contains(dataString, "\"accessMethodsRequest\":{") { + methodsId := c.localShipID + + accessMethods := model.AccessMethods{ + AccessMethods: model.AccessMethodsType{ + Id: &methodsId, + }, + } + if err := c.sendShipModel(model.MsgTypeControl, accessMethods); err != nil { + c.endHandshakeWithError(err) + } + return + } else if strings.Contains(dataString, "\"accessMethods\":{") { + // compare SHIP ID to stored value on pairing. SKI + SHIP ID should be verified on connection + // otherwise close connection with error "close 4450: SHIP id mismatch" + + var accessMethods model.AccessMethods + if err := json.Unmarshal([]byte(data), &accessMethods); err != nil { + c.endHandshakeWithError(err) + return + } + + if accessMethods.AccessMethods.Id == nil { + c.endHandshakeWithError(errors.New("Access methods response does not contain SHIP ID")) + return + } + + // if the ID string is empty, then we don't know it yet and can't be verified + if len(c.remoteShipID) > 0 && c.remoteShipID != *accessMethods.AccessMethods.Id { + c.endHandshakeWithError(errors.New("SHIP id mismatch")) + return + } + + // save and report the SHIP ID + if len(c.remoteShipID) == 0 { + c.remoteShipID = *accessMethods.AccessMethods.Id + + c.infoProvider.ReportServiceShipID(c.remoteSKI, c.remoteShipID) + } + } else { + c.endHandshakeWithError(fmt.Errorf("access methods: invalid response: %s", dataString)) + return + } + + c.setState(model.SmeStateApproved, nil) + c.approveHandshake() +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_approve_test.go b/src/eebus-bridge/third_party/ship-go/ship/hs_approve_test.go new file mode 100644 index 0000000..4d90aad --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_approve_test.go @@ -0,0 +1,41 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package ship + +import ( + "testing" + + "github.com/enbility/ship-go/model" +) + +// abortingInfo: the remote aborts the moment the connection reaches +// READY_LISTEN (the read pump winning against the approval's next step). +type abortingInfo struct { + trustInfo + c *ShipConnection +} + +func (i *abortingInfo) HandleShipHandshakeStateUpdate(ski string, s model.ShipState) { + i.trustInfo.HandleShipHandshakeStateUpdate(ski, s) + if s.State == model.SmeHelloStateReadyListen { + i.c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateRemoteAbortDone) + } +} + +// The approval moves on to HELLO_OK only from READY_LISTEN: when the read +// pump (or the timer) already left it, the approval does nothing more +// (before, it forced HELLO_OK after the remote's abort). +func TestApprovalDoesNotForceHelloOk(t *testing.T) { + info := &abortingInfo{} + c := NewConnectionHandler(info, &sink{}, ShipRoleServer, "local", "remoteski", "remote") + info.c = c + c.setState(model.SmeHelloStatePendingListen, nil) + c.ApprovePendingHandshake() + for _, s := range info.reported() { + if s == model.SmeHelloStateOk { + t.Fatalf("HELLO_OK after the remote's abort: %v", info.reported()) + } + } + c.CloseConnection(false, 0, "") +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_hello.go b/src/eebus-bridge/third_party/ship-go/ship/hs_hello.go new file mode 100644 index 0000000..868c6da --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_hello.go @@ -0,0 +1,295 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: a connection waiting for trust is approved once the remote +// service is trusted (approveWhenTrusted); every transition out of +// PENDING_LISTEN and READY_LISTEN is a check-and-set (leaveState). + +package ship + +import ( + "time" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/model" + "github.com/enbility/ship-go/util" +) + +// Handshake Hello covers the states smeHello... + +// SME_HELLO_STATE_READY_INIT +func (c *ShipConnection) handshakeHello_Init() { + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypeReady, tHelloInit, false); err != nil { + c.setAndHandleState(model.SmeHelloStateAbort) + return + } + + c.setState(model.SmeHelloStateReadyListen, nil) +} + +// SME_HELLO_STATE_READY_LISTEN +func (c *ShipConnection) handshakeHello_ReadyListen(timeout bool, message []byte) { + if timeout { + c.handshakeHello_ReadyTimeout() + return + } + + var helloReturnMsg model.ConnectionHello + if err := c.processShipJsonMessage(message, &helloReturnMsg); err != nil { + c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateAbort) + return + } + + hello := helloReturnMsg.ConnectionHello + + switch hello.Phase { + case model.ConnectionHelloPhaseTypeReady: + // HELLO_OK (from READY_LISTEN only: a check-and-set) + if !c.changeState([]model.ShipMessageExchangeState{model.SmeHelloStateReadyListen}, model.SmeHelloStateOk, nil) { + return + } + + case model.ConnectionHelloPhaseTypePending: + // the phase is still pending an no prolongationRequest is set, ignore the message + if hello.ProlongationRequest == nil { + return + } + + // if we got a prolongation request, accept it + if *hello.ProlongationRequest { + if c.infoProvider.AllowWaitingForTrust(c.remoteShipID) { + // re-init timer + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, tHelloInit) + } + + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypeReady, tHelloInit, false); err != nil { + c.endHandshakeWithError(err) + } + + return + } + + // we do get false, which is invalid, so ignore it + return + + case model.ConnectionHelloPhaseTypeAborted: + c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateRemoteAbortDone) + + return + + default: + // don't accept any other responses + logging.Log().Errorf("Unexpected connection hello phase: %s", hello.Phase) + c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateAbort) + return + } + + c.handleState(false, nil) +} + +func (c *ShipConnection) handshakeHello_ReadyTimeout() { + c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateAbort) +} + +// SME_HELLO_ABORT +func (c *ShipConnection) handshakeHello_Abort() { + c.stopHandshakeTimer() + + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypeAborted, 0, false); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setAndHandleState(model.SmeHelloStateAbortDone) +} + +// SME_HELLO_PENDING_INIT +func (c *ShipConnection) handshakeHello_PendingInit() { + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypePending, tHelloInit, false); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setState(model.SmeHelloStatePendingListen, nil) + + if !c.infoProvider.AllowWaitingForTrust(c.remoteSKI) { + c.leavePendingListen(model.SmeHelloStateAbort) + return + } + + go c.approveWhenTrusted() +} + +// approveWhenTrusted: while this connection waits for trust, approve it as +// soon as the remote service is trusted. The trust (Hub.RegisterRemoteSKI) +// approves only the connection registered for the SKI; with a double +// connection that can be the other one, closed a moment later, and this +// one waited for the whole hello timeout (60 s) before it gave up. +func (c *ShipConnection) approveWhenTrusted() { + ticker := time.NewTicker(pendingTrustCheckInterval) + defer ticker.Stop() + + for range ticker.C { + if c.getState() != model.SmeHelloStatePendingListen { + return + } + if closed, _ := c.dataWriter.IsDataConnectionClosed(); closed { + return + } + if c.infoProvider.IsRemoteServiceForSKIPaired(c.remoteSKI) { + c.ApprovePendingHandshake() + return + } + } +} + +// SME_HELLO_PENDING_LISTEN +func (c *ShipConnection) handshakeHello_PendingListen(timeout bool, message []byte) { + if timeout { + // The device needs to be in a state for the user to allow trusting the device + // e.g. either the web UI or by other means + if !c.infoProvider.AllowWaitingForTrust(c.remoteShipID) { + c.handshakeHello_PendingTimeout() + } else { + c.handshakeHello_PendingProlongationRequest() + } + + return + } + + var helloReturnMsg model.ConnectionHello + if err := c.processShipJsonMessage(message, &helloReturnMsg); err != nil { + c.leavePendingListen(model.SmeHelloStateAbort) + return + } + + hello := helloReturnMsg.ConnectionHello + + switch hello.Phase { + case model.ConnectionHelloPhaseTypeReady: + if hello.Waiting == nil { + c.leavePendingListen(model.SmeHelloStateAbort) + return + } + + c.stopHandshakeTimer() + + // conversion is safe + newDuration := time.Duration(*hello.Waiting) * time.Millisecond // #nosec G115 + duration := tHelloProlongThrInc + if newDuration >= duration { + // the duration has to be reduced + duration = newDuration - duration + + // check if it is less than T_hello_prolong_min + if newDuration >= tHelloProlongMin { + c.setHandshakeTimer(timeoutTimerTypeSendProlongationRequest, duration) + return + } + } + + if newDuration < tHelloProlongMin { + // I interpret 13.4.4.1.3 Page 64 Line 1550-1553 as this resulting in a timeout state + // TODO: verify this + c.leavePendingListen(model.SmeHelloStateAbort) + } + + case model.ConnectionHelloPhaseTypePending: + if hello.Waiting != nil && hello.ProlongationRequest == nil { + c.stopHandshakeTimer() + + // conversion is safe + newDuration := time.Duration(*hello.Waiting) * time.Millisecond // #nosec G115 + c.lastReceivedWaitingValue = newDuration + duration := tHelloProlongThrInc + if newDuration >= duration { + // the duration has to be reduced + duration = newDuration - duration + + // check if it is less than T_hello_prolong_min + if newDuration >= tHelloProlongMin { + c.setHandshakeTimer(timeoutTimerTypeSendProlongationRequest, duration) + return + } + } + + if newDuration < tHelloProlongMin { + // I interpret 13.4.4.1.3 Page 64 Line 1557-1560 as this resulting in a timeout state + // TODO: verify this + c.leavePendingListen(model.SmeHelloStateAbort) + } + + return + } + + if hello.Waiting == nil && hello.ProlongationRequest != nil && *hello.ProlongationRequest { + // if we got a prolongation request, accept it + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypePending, tHelloInit, false); err != nil { + c.endHandshakeWithError(err) + } + + return + } + + c.leavePendingListen(model.SmeHelloStateAbort) + + case model.ConnectionHelloPhaseTypeAborted: + c.leavePendingListen(model.SmeHelloStateRemoteAbortDone) + return + + default: + // don't accept any other responses + logging.Log().Errorf("Unexpected connection hello phase: %s", hello.Phase) + c.leavePendingListen(model.SmeHelloStateAbort) + return + } + + c.handleState(false, nil) +} + +func (c *ShipConnection) handshakeHello_PendingProlongationRequest() { + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypePending, 0, true); err != nil { + c.endHandshakeWithError(err) + return + } + + // TODO: we need to set the timer to the last received waiting value + c.setHandshakeTimer(timeoutTimerTypeProlongRequestReply, tHelloInit) +} + +func (c *ShipConnection) handshakeHello_PendingTimeout() { + if c.getHandshakeTimerType() != timeoutTimerTypeSendProlongationRequest { + c.leavePendingListen(model.SmeHelloStateAbort) + return + } + + if err := c.handshakeHelloSend(model.ConnectionHelloPhaseTypePending, 0, true); err != nil { + c.endHandshakeWithError(err) + return + } + + if c.lastReceivedWaitingValue == 0 { + newValue := float64(tHelloInit.Milliseconds()) * 1.1 + c.lastReceivedWaitingValue = time.Duration(newValue) + } + c.setHandshakeTimer(timeoutTimerTypeProlongRequestReply, c.lastReceivedWaitingValue) +} + +func (c *ShipConnection) handshakeHelloSend(phase model.ConnectionHelloPhaseType, waitingDuration time.Duration, prolongation bool) error { + helloMsg := model.ConnectionHello{ + ConnectionHello: model.ConnectionHelloType{ + Phase: phase, + }, + } + + if waitingDuration > 0 { + helloMsg.ConnectionHello.Waiting = util.Ptr(uint(waitingDuration.Milliseconds())) + } + if prolongation { + helloMsg.ConnectionHello.ProlongationRequest = &prolongation + } + + if err := c.sendShipModel(model.MsgTypeControl, helloMsg); err != nil { + return err + } + return nil +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_hello_trust_test.go b/src/eebus-bridge/third_party/ship-go/ship/hs_hello_trust_test.go new file mode 100644 index 0000000..7c414a1 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_hello_trust_test.go @@ -0,0 +1,152 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package ship + +import ( + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/model" +) + +type trustInfo struct { + trusted atomic.Bool + mu sync.Mutex + states []model.ShipMessageExchangeState +} + +func (i *trustInfo) reported() []model.ShipMessageExchangeState { + i.mu.Lock() + defer i.mu.Unlock() + return append([]model.ShipMessageExchangeState(nil), i.states...) +} + +func (i *trustInfo) IsRemoteServiceForSKIPaired(string) bool { return i.trusted.Load() } +func (i *trustInfo) IsAutoAcceptEnabled() bool { return false } +func (i *trustInfo) HandleConnectionClosed(api.ShipConnectionInterface, bool) {} +func (i *trustInfo) ReportServiceShipID(string, string) {} +func (i *trustInfo) AllowWaitingForTrust(string) bool { return true } +func (i *trustInfo) HandleShipHandshakeStateUpdate(_ string, s model.ShipState) { + i.mu.Lock() + defer i.mu.Unlock() + i.states = append(i.states, s.State) +} +func (i *trustInfo) SetupRemoteDevice(string, api.ShipConnectionDataWriterInterface) api.ShipConnectionDataReaderInterface { + return nil +} + +type sink struct { + mu sync.Mutex + sent int +} + +func (s *sink) InitDataProcessing(api.WebsocketDataReaderInterface) {} +func (s *sink) WriteMessageToWebsocketConnection([]byte) error { + s.mu.Lock() + defer s.mu.Unlock() + s.sent++ + return nil +} +func (s *sink) CloseDataConnection(int, string) {} +func (s *sink) IsDataConnectionClosed() (bool, error) { return false, nil } + +func pendingConnection(t *testing.T) (*ShipConnection, *sink) { + t.Helper() + s := &sink{} + c := NewConnectionHandler(&trustInfo{}, s, ShipRoleServer, "local", "remoteski", "remote") + c.setState(model.SmeHelloStatePendingInit, nil) + c.handshakeHello_PendingInit() + s.mu.Lock() + s.sent = 0 + s.mu.Unlock() + return c, s +} + +// The transitions out of PENDING_LISTEN (the approval, the read pump's and +// the hello timer's) are check-and-set: of several at once exactly one +// moves on. Before, each checked the state and then set it, so an approval +// could act after the remote's abort had already taken the connection out. +func TestPendingListenLeftOnce(t *testing.T) { + targets := []model.ShipMessageExchangeState{model.SmeHelloStateReadyInit, model.SmeHelloStateAbort, + model.SmeHelloStateRemoteAbortDone, model.SmeHelloStateAbort} + for i := 0; i < 500; i++ { + c := NewConnectionHandler(&trustInfo{}, &sink{}, ShipRoleServer, "local", "remoteski", "remote") + c.setState(model.SmeHelloStatePendingListen, nil) + var moved atomic.Int32 + var wg sync.WaitGroup + for _, to := range targets { + wg.Add(1) + go func() { + defer wg.Done() + if c.changeState([]model.ShipMessageExchangeState{model.SmeHelloStatePendingListen}, to, nil) { + moved.Add(1) + } + }() + } + wg.Wait() + c.CloseConnection(false, 0, "") + if moved.Load() != 1 { + t.Fatalf("round %d: %d transitions out of PENDING_LISTEN", i, moved.Load()) + } + } +} + +// The trust and the connection's own check approving at once: "ready" goes +// out once (the approval checks and acts under one lock). +func TestApprovalOnce(t *testing.T) { + c, s := pendingConnection(t) + c.ApprovePendingHandshake() + s.mu.Lock() + once := s.sent + s.mu.Unlock() + c.CloseConnection(false, 0, "") + if once == 0 { + t.Fatal("an approval sends") + } + for i := 0; i < 200; i++ { + c, s := pendingConnection(t) + var wg sync.WaitGroup + for g := 0; g < 2; g++ { + wg.Add(1) + go func() { + defer wg.Done() + c.ApprovePendingHandshake() + }() + } + wg.Wait() + s.mu.Lock() + sent := s.sent + s.mu.Unlock() + c.CloseConnection(false, 0, "") + if sent != once { + t.Fatalf("round %d: %d messages sent for two approvals at once, %d for one", i, sent, once) + } + } +} + +// A connection waiting for trust is approved once the remote service +// becomes trusted, even though the trust was given while another +// connection to the same service was the registered one (a double +// connection): before, it waited for the whole hello timeout. +func TestPendingConnectionApprovedWhenTrustedLater(t *testing.T) { + info := &trustInfo{} + c := NewConnectionHandler(info, &sink{}, ShipRoleServer, "local", "remoteski", "remote") + c.setState(model.SmeHelloStatePendingInit, nil) + c.handshakeHello_PendingInit() + if c.getState() != model.SmeHelloStatePendingListen { + t.Fatalf("state: %v", c.getState()) + } + info.trusted.Store(true) + deadline := time.Now().Add(5 * time.Second) + for c.getState() == model.SmeHelloStatePendingListen && time.Now().Before(deadline) { + time.Sleep(20 * time.Millisecond) + } + if c.getState() == model.SmeHelloStatePendingListen { + t.Fatal("still waiting for trust 5 s after the service was trusted") + } + c.CloseConnection(false, 0, "") +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_init.go b/src/eebus-bridge/third_party/ship-go/ship/hs_init.go new file mode 100644 index 0000000..5640ca3 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_init.go @@ -0,0 +1,72 @@ +package ship + +import ( + "fmt" + + "github.com/enbility/ship-go/model" +) + +// Handshake initialization covers the states cmiState... + +// CMI_STATE_INIT_START +func (c *ShipConnection) handshakeInit_cmiStateInitStart() { + switch c.role { + case ShipRoleClient: + // CMI_STATE_CLIENT_SEND + c.setState(model.CmiStateClientSend, nil) + if err := c.dataWriter.WriteMessageToWebsocketConnection(model.ShipInit); err != nil { + c.endHandshakeWithError(err) + return + } + c.setState(model.CmiStateClientWait, nil) + case ShipRoleServer: + c.setState(model.CmiStateServerWait, nil) + } + + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, cmiTimeout) +} + +// CMI_STATE_SERVER_WAIT +func (c *ShipConnection) handshakeInit_cmiStateServerWait(message []byte) { + c.setState(model.CmiStateServerEvaluate, nil) + + if !c.handshakeInit_cmiStateEvaluate(message) { + return + } + + if err := c.dataWriter.WriteMessageToWebsocketConnection(model.ShipInit); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setAndHandleState(model.SmeHelloState) +} + +// CMI_STATE_CLIENT_WAIT +func (c *ShipConnection) handshakeInit_cmiStateClientWait(message []byte) { + c.setState(model.CmiStateClientEvaluate, nil) + + if !c.handshakeInit_cmiStateEvaluate(message) { + return + } + + c.setAndHandleState(model.SmeHelloState) +} + +// CMI_STATE_SERVER_EVALUATE +// CMI_STATE_CLIENT_EVALUATE +// returns false in case of an error +func (c *ShipConnection) handshakeInit_cmiStateEvaluate(message []byte) bool { + msgType, data := c.parseMessage(message, false) + + if msgType != model.MsgTypeInit { + c.endHandshakeWithError(fmt.Errorf("Invalid SHIP MessageType, expected 0 and got %s", string(msgType))) + return false + } + if len(data) > 0 && data[0] != byte(0) { + c.endHandshakeWithError(fmt.Errorf("Invalid SHIP MessageValue, expected 0 and got %s", string(data))) + return false + } + + return true +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_pin.go b/src/eebus-bridge/third_party/ship-go/ship/hs_pin.go new file mode 100644 index 0000000..024d0e6 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_pin.go @@ -0,0 +1,50 @@ +package ship + +import ( + "encoding/json" + "errors" + + "github.com/enbility/ship-go/model" +) + +// Handshake Pin covers the states smePin... + +func (c *ShipConnection) handshakePin_Init() { + c.setState(model.SmePinStateCheckInit, nil) + + pinState := model.ConnectionPinState{ + ConnectionPinState: model.ConnectionPinStateType{ + PinState: model.PinStateTypeNone, + }, + } + + if err := c.sendShipModel(model.MsgTypeControl, pinState); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setState(model.SmePinStateCheckListen, nil) +} + +func (c *ShipConnection) handshakePin_smePinStateCheckListen(message []byte) { + _, data := c.parseMessage(message, true) + + var connectionPinState model.ConnectionPinState + if err := json.Unmarshal([]byte(data), &connectionPinState); err != nil { + c.endHandshakeWithError(err) + return + } + + switch connectionPinState.ConnectionPinState.PinState { + case model.PinStateTypeNone: + c.setAndHandleState(model.SmePinStateCheckOk) + case model.PinStateTypeRequired: + c.endHandshakeWithError(errors.New("Got pin state: required (unsupported)")) + case model.PinStateTypeOptional: + c.endHandshakeWithError(errors.New("Got pin state: optional (unsupported)")) + case model.PinStateTypePinOk: + c.endHandshakeWithError(errors.New("Got pin state: ok (unsupported)")) + default: + c.endHandshakeWithError(errors.New("Got invalid pin state")) + } +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_prot.go b/src/eebus-bridge/third_party/ship-go/ship/hs_prot.go new file mode 100644 index 0000000..e4b9a05 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_prot.go @@ -0,0 +1,175 @@ +package ship + +import ( + "encoding/json" + "errors" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/model" +) + +// Handshake Prot covers the states smeProt... + +func (c *ShipConnection) handshakeProtocol_Init() { + switch c.role { + case ShipRoleServer: + c.setState(model.SmeProtHStateServerInit, nil) + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, cmiTimeout) + c.setState(model.SmeProtHStateServerListenProposal, nil) + case ShipRoleClient: + c.setState(model.SmeProtHStateClientInit, nil) + c.handshakeProtocol_smeProtHStateClientInit() + } +} + +// provide a ship.MessageProtocolHandshake struct +func (c *ShipConnection) protocolHandshake() model.MessageProtocolHandshake { + protocolHandshake := model.MessageProtocolHandshake{ + MessageProtocolHandshake: model.MessageProtocolHandshakeType{ + Version: model.Version{Major: 1, Minor: 0}, + Formats: model.MessageProtocolFormatsType{ + Format: []model.MessageProtocolFormatType{model.MessageProtocolFormatTypeUTF8}, + }, + }, + } + + return protocolHandshake +} + +func (c *ShipConnection) handshakeProtocol_smeProtHStateServerListenProposal(message []byte) { + _, data := c.parseMessage(message, true) + + messageProtocolHandshake := model.MessageProtocolHandshake{} + if err := json.Unmarshal([]byte(data), &messageProtocolHandshake); err != nil { + c.endHandshakeWithError(err) + return + } + + if messageProtocolHandshake.MessageProtocolHandshake.HandshakeType != model.ProtocolHandshakeTypeTypeAnnounceMax { + c.endHandshakeWithError(errors.New("Invalid protocol handshake request")) + return + } + + c.stopHandshakeTimer() + + protocolHandshake := c.protocolHandshake() + protocolHandshake.MessageProtocolHandshake.HandshakeType = model.ProtocolHandshakeTypeTypeSelect + + if err := c.sendShipModel(model.MsgTypeControl, protocolHandshake); err != nil { + c.endHandshakeWithError(err) + } + + c.setHandshakeTimer(timeoutTimerTypeWaitForReady, cmiTimeout) + + c.setState(model.SmeProtHStateServerListenConfirm, nil) +} + +func (c *ShipConnection) handshakeProtocol_smeProtHStateServerListenConfirm(message []byte) { + _, data := c.parseMessage(message, true) + + var messageProtocolHandshake model.MessageProtocolHandshake + if err := json.Unmarshal([]byte(data), &messageProtocolHandshake); err != nil { + logging.Log().Debug(err) + c.abortProtocolHandshake(model.MessageProtocolHandshakeErrorErrorTypeUnexpectedMessage) + return + } + + if messageProtocolHandshake.MessageProtocolHandshake.HandshakeType != model.ProtocolHandshakeTypeTypeSelect { + logging.Log().Debug("invalid protocol handshake response") + c.abortProtocolHandshake(model.MessageProtocolHandshakeErrorErrorTypeSelectionMismatch) + return + } + + c.stopHandshakeTimer() + + c.setAndHandleState(model.SmeProtHStateServerOk) +} + +func (c *ShipConnection) handshakeProtocol_smeProtHStateClientInit() { + c.setState(model.SmeProtHStateClientInit, nil) + + protocolHandshake := c.protocolHandshake() + protocolHandshake.MessageProtocolHandshake.HandshakeType = model.ProtocolHandshakeTypeTypeAnnounceMax + + if err := c.sendShipModel(model.MsgTypeControl, protocolHandshake); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setState(model.SmeProtHStateClientListenChoice, nil) +} + +func (c *ShipConnection) handshakeProtocol_smeProtHStateClientListenChoice(message []byte) { + _, data := c.parseMessage(message, true) + + messageProtocolHandshake := model.MessageProtocolHandshake{} + if err := json.Unmarshal([]byte(data), &messageProtocolHandshake); err != nil { + logging.Log().Debug(err) + c.abortProtocolHandshake(model.MessageProtocolHandshakeErrorErrorTypeUnexpectedMessage) + return + } + + msgHandshake := messageProtocolHandshake.MessageProtocolHandshake + + abort := false + if msgHandshake.HandshakeType != model.ProtocolHandshakeTypeTypeSelect { + logging.Log().Debug("invalid protocol handshake response") + abort = true + } + + if msgHandshake.Version.Major != 1 { + logging.Log().Debug("unsupported protocol major version") + abort = true + } + + if msgHandshake.Version.Minor != 0 { + logging.Log().Debug("unsupported protocol minor version") + abort = true + } + + if len(msgHandshake.Formats.Format) == 0 { + logging.Log().Debug("format is missing") + abort = true + } + + if len(msgHandshake.Formats.Format) != 1 { + logging.Log().Debug("unsupported format response") + abort = true + } + + if msgHandshake.Formats.Format != nil && msgHandshake.Formats.Format[0] != model.MessageProtocolFormatTypeUTF8 { + logging.Log().Debug("unsupported format") + abort = true + } + + if abort { + c.abortProtocolHandshake(model.MessageProtocolHandshakeErrorErrorTypeSelectionMismatch) + return + } + + c.stopHandshakeTimer() + + protocolHandshake := c.protocolHandshake() + protocolHandshake.MessageProtocolHandshake.HandshakeType = model.ProtocolHandshakeTypeTypeSelect + + if err := c.sendShipModel(model.MsgTypeControl, protocolHandshake); err != nil { + c.endHandshakeWithError(err) + return + } + + c.setAndHandleState(model.SmeProtHStateClientOk) +} + +func (c *ShipConnection) abortProtocolHandshake(err model.MessageProtocolHandshakeErrorErrorType) { + c.stopHandshakeTimer() + + msg := model.MessageProtocolHandshakeError{ + Error: err, + } + + _ = c.sendShipModel(model.MsgTypeControl, msg) + + c.setState(model.SmeStateError, errors.New("handshake error")) + + c.CloseConnection(false, 0, "") +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/hs_timer_test.go b/src/eebus-bridge/third_party/ship-go/ship/hs_timer_test.go new file mode 100644 index 0000000..3df03e6 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/hs_timer_test.go @@ -0,0 +1,55 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package ship + +import ( + "sync" + "testing" + + "github.com/enbility/ship-go/model" +) + +// A hello timer that fired while the state moved on (an approval stopped it +// and armed the next one) is stale: it doesn't act. Before, it timed out the +// approved handshake. +func TestStaleHandshakeTimerDoesNotAct(t *testing.T) { + c := NewConnectionHandler(&trustInfo{}, &sink{}, ShipRoleServer, "local", "remoteski", "remote") + armed := c.nextHandshakeTimerGen() // the pending timer, firing + c.stopHandshakeTimer() // the approval stops it ... + next := c.nextHandshakeTimerGen() // ... and arms the next + if c.handshakeTimerFired(armed) { + t.Fatal("the stopped timer acted") + } + if !c.handshakeTimerFired(next) { + t.Fatal("the current timer didn't") + } + c.CloseConnection(false, 0, "") +} + +// READY_LISTEN is left once: the remote's "ready" (HELLO_OK) and a timeout +// at once never both act. +func TestReadyListenLeftOnce(t *testing.T) { + for i := 0; i < 300; i++ { + info := &trustInfo{} + c := NewConnectionHandler(info, &sink{}, ShipRoleServer, "local", "remoteski", "remote") + c.setState(model.SmeHelloStateReadyListen, nil) + var wg sync.WaitGroup + wg.Add(2) + go func() { defer wg.Done(); c.leaveState(model.SmeHelloStateReadyListen, model.SmeHelloStateAbort) }() + go func() { + defer wg.Done() + c.changeState([]model.ShipMessageExchangeState{model.SmeHelloStateReadyListen}, model.SmeHelloStateOk, nil) + }() + wg.Wait() + ok, aborted := false, false + for _, s := range info.reported() { + ok = ok || s == model.SmeHelloStateOk + aborted = aborted || s == model.SmeHelloStateAbort + } + c.CloseConnection(false, 0, "") + if ok && aborted { + t.Fatalf("round %d: both left READY_LISTEN: %v", i, info.reported()) + } + } +} diff --git a/src/eebus-bridge/third_party/ship-go/ship/types.go b/src/eebus-bridge/third_party/ship-go/ship/types.go new file mode 100644 index 0000000..735462d --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ship/types.go @@ -0,0 +1,41 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: pendingTrustCheckInterval. + +package ship + +import ( + "time" +) + +type shipRole string + +const ( + ShipRoleServer shipRole = "server" + ShipRoleClient shipRole = "client" +) + +const ( + cmiTimeout = 10 * time.Second // SHIP 4.2 + cmiCloseTimeout = 100 * time.Millisecond + tHelloInit = 60 * time.Second // SHIP 13.4.4.1.3 + tHelloInc = 60 * time.Second + tHelloProlongThrInc = 30 * time.Second + tHelloProlongWaitingGap = 15 * time.Second + tHelloProlongMin = 1 * time.Second + + // how often a connection waiting for trust checks whether the remote + // service became trusted meanwhile (approveWhenTrusted) + pendingTrustCheckInterval = 500 * time.Millisecond +) + +type timeoutTimerType uint + +const ( + // SHIP 13.4.4.1.3: The communication partner must send its "READY" state (or request for prolongation") before the timer expires. + timeoutTimerTypeWaitForReady timeoutTimerType = iota + // SHIP 13.4.4.1.3: Local timer to request for prolongation at the communication partner in time (i.e. before the communication partner's Wait-For-Ready-Timer expires). + timeoutTimerTypeSendProlongationRequest + // SHIP 13.4.4.1.3: Detection of response timeout on prolongation request. + timeoutTimerTypeProlongRequestReply +) diff --git a/src/eebus-bridge/third_party/ship-go/util/helper.go b/src/eebus-bridge/third_party/ship-go/util/helper.go new file mode 100644 index 0000000..2ef0ec7 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/util/helper.go @@ -0,0 +1,31 @@ +package util + +import ( + "encoding/json" + "os" + "strings" +) + +// used in tests +func IsRunningOnCI() bool { + return os.Getenv("ACTION_ENVIRONMENT") == "CI" +} + +func Ptr[T any](v T) *T { + return &v +} + +// quick way to a struct into another +func DeepCopy[A any](source, dest A) { + byt, _ := json.Marshal(source) + _ = json.Unmarshal(byt, dest) +} + +// standardize the provided SKI strings +func NormalizeSKI(ski string) string { + ski = strings.ReplaceAll(ski, " ", "") + ski = strings.ReplaceAll(ski, "-", "") + ski = strings.ToLower(ski) + + return ski +} diff --git a/src/eebus-bridge/third_party/ship-go/ws/types.go b/src/eebus-bridge/third_party/ship-go/ws/types.go new file mode 100644 index 0000000..747fd9e --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ws/types.go @@ -0,0 +1,15 @@ +package ws + +import "time" + +const ( + writeWait = 10 * time.Second + + // Time allowed to read the next pong message from the peer. + pongWait = 60 * time.Second // SHIP 4.2: ping interval + pong timeout + // Send pings to peer with this period. Must be less than pongWait. + pingPeriod = 50 * time.Second // SHIP 4.2: ping interval + + // SHIP 9.2: Set maximum fragment length to 1024 bytes + MaxMessageSize = 1024 +) diff --git a/src/eebus-bridge/third_party/ship-go/ws/websocket.go b/src/eebus-bridge/third_party/ship-go/ws/websocket.go new file mode 100644 index 0000000..f8fd889 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ws/websocket.go @@ -0,0 +1,354 @@ +// Modified from ship-go v0.6.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the write channel is never closed (a writer selects on the +// write pump's end instead: "send on closed channel"), a close always +// closes the socket, and a panic in a pump tears down only its connection. + +package ws + +import ( + "bytes" + "errors" + "fmt" + "runtime/debug" + "sync" + "time" + + "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/ship-go/model" + "github.com/gorilla/websocket" +) + +const connIsClosedError string = "connection is closed" + +// Handling of the actual websocket connection to a remote device +type WebsocketConnection struct { + // The actual websocket connection + conn *websocket.Conn + + // The implementation handling message processing + dataProcessing api.WebsocketDataReaderInterface + + // The connection was closed + closeChannel chan struct{} + + // The ship write channel for outgoing SHIP messages; never closed, as + // writers may still be sending when the write pump ends + shipWriteChannel chan []byte + + // closed when the write pump has ended: nothing reads shipWriteChannel + writePumpDone chan struct{} + + // internal handling of closed connections + connectionClosed bool + + // the error message received for the closed connection + connectionClosedError error + + remoteSki string + + muxConnClosed sync.Mutex + muxShipWrite sync.Mutex + muxConWrite sync.Mutex + shutdownOnce sync.Once +} + +// create a new websocket based shipDataProcessing implementation +func NewWebsocketConnection(conn *websocket.Conn, remoteSki string) *WebsocketConnection { + return &WebsocketConnection{ + conn: conn, + remoteSki: remoteSki, + connectionClosedError: nil, + } +} + +// sets the error message for the closed connection +func (w *WebsocketConnection) setConnClosedError(err error) { + w.muxConnClosed.Lock() + defer w.muxConnClosed.Unlock() + + w.connectionClosed = true + + if err != nil { + w.connectionClosedError = err + } +} + +func (w *WebsocketConnection) connClosedError() error { + w.muxConnClosed.Lock() + defer w.muxConnClosed.Unlock() + + return w.connectionClosedError +} + +// check if the websocket connection is closed +func (w *WebsocketConnection) isConnClosed() bool { + w.muxConnClosed.Lock() + defer w.muxConnClosed.Unlock() + + return w.connectionClosed +} + +func (w *WebsocketConnection) run() { + w.shipWriteChannel = make(chan []byte, 1) // Send outgoing ship messages + w.closeChannel = make(chan struct{}, 1) // Listen to close events + w.writePumpDone = make(chan struct{}) + + go w.readShipPump() + go w.writeShipPump() +} + +// recoverPump: a panic in a pump (or in a handler it called) tears down this +// connection only, reported as a connection error like a read error. +func (w *WebsocketConnection) recoverPump(pump string) { + r := recover() + if r == nil { + return + } + err := fmt.Errorf("panic in the %s pump: %v", pump, r) + logging.Log().Error(w.remoteSki, err, string(debug.Stack())) + closed := w.isConnClosed() + w.close() + if !closed { + w.setConnClosedError(err) + w.dataProcessing.ReportConnectionError(err) + } +} + +// writePump pumps messages from the SPINE and SHIP writeChannels to the websocket connection +func (w *WebsocketConnection) writeShipPump() { + ticker := time.NewTicker(pingPeriod) + defer func() { + ticker.Stop() + // shipWriteChannel stays open: a writer that passed its closed check + // may still send, and returns on writePumpDone + close(w.writePumpDone) + }() + defer w.recoverPump("write") + + for { + select { + case <-w.closeChannel: + return + + case message, ok := <-w.shipWriteChannel: + if w.isConnClosed() { + return + } + + if !ok { + logging.Log().Debug(w.remoteSki, "ship write channel closed") + // The write channel has been closed + _ = w.writeMessage(websocket.CloseMessage, []byte{}) + return + } + + w.muxConWrite.Lock() + _ = w.conn.SetWriteDeadline(time.Now().Add(writeWait)) + w.muxConWrite.Unlock() + + if !w.writeMessage(websocket.BinaryMessage, message) { + return + } + + text := w.textFromMessage(message) + logging.Log().Trace("Send:", w.remoteSki, text) + + case <-ticker.C: + w.handlePing() + } + } +} + +func (w *WebsocketConnection) handlePing() { + if w.isConnClosed() { + return + } + + w.muxConWrite.Lock() + _ = w.conn.SetWriteDeadline(time.Now().Add(writeWait)) + w.muxConWrite.Unlock() + _ = w.writeMessage(websocket.PingMessage, nil) +} + +func (w *WebsocketConnection) closeWithError(err error, reason string) { + logging.Log().Debug(w.remoteSki, reason, err) + w.setConnClosedError(err) + w.dataProcessing.ReportConnectionError(err) +} + +// readShipPump checks for messages from the websocket connection +func (w *WebsocketConnection) readShipPump() { + defer w.recoverPump("read") + + _ = w.conn.SetReadDeadline(time.Now().Add(pongWait)) + w.conn.SetPongHandler(func(string) error { _ = w.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil }) + + for { + select { + case <-w.closeChannel: + return + + default: + if w.isConnClosed() { + return + } + + message, err := w.readWebsocketMessage() + // ignore read errors if the connection got closed + if w.isConnClosed() { + return + } + + if err != nil { + logging.Log().Debug(w.remoteSki, "websocket read error: ", err) + w.close() + w.setConnClosedError(err) + w.dataProcessing.ReportConnectionError(err) + return + } + + text := w.textFromMessage(message) + logging.Log().Trace("Recv:", w.remoteSki, text) + + w.dataProcessing.HandleIncomingWebsocketMessage(message) + } + } +} + +func (w *WebsocketConnection) textFromMessage(msg []byte) string { + text := "unknown single byte" + if len(msg) > 2 { + text = string(msg[1:]) + } else if bytes.Equal(msg, model.ShipInit) { + text = "ship init" + } + + return text +} + +// read a message from the websocket connection +func (w *WebsocketConnection) readWebsocketMessage() ([]byte, error) { + if w.conn == nil { + return nil, errors.New("connection is not initialized") + } + + msgType, b, err := w.conn.ReadMessage() + if err != nil { + return nil, err + } + + if err := w.checkWebsocketMessage(msgType, b); err != nil { + return nil, err + } + + return b, nil +} + +func (w *WebsocketConnection) checkWebsocketMessage(msgType int, data []byte) error { + if msgType != websocket.BinaryMessage { + return errors.New("message is not a binary message") + } + + if len(data) < 2 { + return fmt.Errorf("invalid ship message length") + } + + return nil +} + +// close the current websocket connection +func (w *WebsocketConnection) close() { + w.shutdownOnce.Do(func() { + // also after a write or read error marked the connection closed: + // the pumps' close channel and the socket are closed once, here + w.setConnClosedError(nil) + + if w.closeChannel != nil { + close(w.closeChannel) + } + + if w.conn != nil { + _ = w.conn.Close() + } + }) +} + +var _ api.WebsocketDataWriterInterface = (*WebsocketConnection)(nil) + +func (w *WebsocketConnection) InitDataProcessing(dataProcessing api.WebsocketDataReaderInterface) { + w.dataProcessing = dataProcessing + + w.run() +} + +// write a message to the websocket connection +func (w *WebsocketConnection) WriteMessageToWebsocketConnection(message []byte) error { + w.muxShipWrite.Lock() + defer w.muxShipWrite.Unlock() + + if w.isConnClosed() || w.shipWriteChannel == nil { + return errors.New(connIsClosedError) + } + + // the write pump may end between the check above and the send: then + // nothing takes the message (and the channel is never closed) + select { + case w.shipWriteChannel <- message: + return nil + case <-w.writePumpDone: + return errors.New(connIsClosedError) + } +} + +// make sure websocket Write is only called once at a time +func (w *WebsocketConnection) writeMessage(messageType int, data []byte) bool { + if w.isConnClosed() { + return false + } + + err := w.writeMessageWithoutErrorHandling(messageType, data) + if err != nil { + // ignore write errors if the connection got closed + w.closeWithError(err, "error writing to websocket: ") + logging.Log().Debug("WRITE ERROR: ", err) + return false + } + + return true +} + +// make sure websocket Write is only called once at a time +func (w *WebsocketConnection) writeMessageWithoutErrorHandling(messageType int, data []byte) error { + if w.isConnClosed() { + return errors.New(connIsClosedError) + } + + w.muxConWrite.Lock() + defer w.muxConWrite.Unlock() + + return w.conn.WriteMessage(messageType, data) +} + +// shutdown the connection and all internals +func (w *WebsocketConnection) CloseDataConnection(closeCode int, reason string) { + // send a close message to the remote side if we have a reason + if reason != "" { + _ = w.writeMessageWithoutErrorHandling(websocket.CloseMessage, websocket.FormatCloseMessage(closeCode, reason)) + } + + w.close() +} + +// return if the connection is closed +func (w *WebsocketConnection) IsDataConnectionClosed() (bool, error) { + isClosed := w.isConnClosed() + err := w.connClosedError() + + if isClosed && err == nil { + err = errors.New("connection is closed") + } + + return isClosed, err +} diff --git a/src/eebus-bridge/third_party/ship-go/ws/websocket_close_test.go b/src/eebus-bridge/third_party/ship-go/ws/websocket_close_test.go new file mode 100644 index 0000000..d0641c4 --- /dev/null +++ b/src/eebus-bridge/third_party/ship-go/ws/websocket_close_test.go @@ -0,0 +1,136 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// ship-go (see LICENSE). + +package ws + +import ( + "net/http" + "net/http/httptest" + "strings" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/gorilla/websocket" +) + +type testReader struct { + errs atomic.Int32 + panic bool +} + +func (r *testReader) HandleIncomingWebsocketMessage([]byte) { + if r.panic { + panic("a handler's bug") + } +} + +func (r *testReader) ReportConnectionError(error) { r.errs.Add(1) } + +// wsPair: a client connection to a test server; the server side is +// returned too (its handler reads until the socket is closed, then closes +// gone). +func wsPair(t *testing.T) (client, server *websocket.Conn, gone chan struct{}) { + t.Helper() + got := make(chan *websocket.Conn, 1) + gone = make(chan struct{}) + up := websocket.Upgrader{CheckOrigin: func(*http.Request) bool { return true }} + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c, err := up.Upgrade(w, r, nil) + if err != nil { + return + } + got <- c + defer close(gone) + for { + if _, _, err := c.ReadMessage(); err != nil { + return + } + } + })) + t.Cleanup(srv.Close) + c, _, err := websocket.DefaultDialer.Dial("ws"+strings.TrimPrefix(srv.URL, "http"), nil) + if err != nil { + t.Fatal(err) + } + s := <-got + t.Cleanup(func() { _ = c.Close(); _ = s.Close() }) + return c, s, gone +} + +// Writers racing a close (a double connection closed in mid-handshake): +// before, a writer that passed the closed check sent on the channel the +// write pump had just closed ("send on closed channel"), or blocked for +// ever once the pump was gone. Now every write returns, nil or an error. +func TestWriteWhileClosing(t *testing.T) { + for i := 0; i < 200; i++ { + client, _, _ := wsPair(t) + w := NewWebsocketConnection(client, "ski") + w.InitDataProcessing(&testReader{}) + + var wg sync.WaitGroup + for g := 0; g < 8; g++ { + wg.Add(1) + go func() { + defer wg.Done() + for n := 0; n < 50; n++ { + _ = w.WriteMessageToWebsocketConnection([]byte{1, '{', '}'}) + } + }() + } + time.Sleep(time.Duration(i%7) * 100 * time.Microsecond) + w.CloseDataConnection(4001, "double connection") + + done := make(chan struct{}) + go func() { wg.Wait(); close(done) }() + select { + case <-done: + case <-time.After(10 * time.Second): + t.Fatalf("round %d: a writer still blocked 10 s after the close", i) + } + if err := w.WriteMessageToWebsocketConnection([]byte{1, '{', '}'}); err == nil { + t.Fatalf("round %d: a write after the close succeeded", i) + } + } +} + +// A read error marks the connection closed first; the close that follows +// must still close the socket (before, it returned early and left it open). +func TestCloseAfterReadErrorClosesTheSocket(t *testing.T) { + client, _, gone := wsPair(t) + r := &testReader{} + w := NewWebsocketConnection(client, "ski") + w.InitDataProcessing(r) + + w.setConnClosedError(nil) // as closeWithError does on a write error + w.close() + select { + case <-gone: + case <-time.After(5 * time.Second): + t.Fatal("the socket is still open 5 s after the close") + } +} + +// A panic in a handler on the read pump ends this connection, reported as +// a connection error, and leaves the process running. +func TestPanicInHandlerEndsOnlyThisConnection(t *testing.T) { + client, server, _ := wsPair(t) + r := &testReader{panic: true} + w := NewWebsocketConnection(client, "ski") + w.InitDataProcessing(r) + + if err := server.WriteMessage(websocket.BinaryMessage, []byte{1, '{', '}'}); err != nil { + t.Fatal(err) + } + deadline := time.Now().Add(5 * time.Second) + for r.errs.Load() == 0 && time.Now().Before(deadline) { + time.Sleep(10 * time.Millisecond) + } + if r.errs.Load() != 1 { + t.Fatalf("connection errors reported: %d", r.errs.Load()) + } + if closed, _ := w.IsDataConnectionClosed(); !closed { + t.Fatal("the connection is not closed") + } +} diff --git a/src/eebus-bridge/third_party/spine-go/LICENSE b/src/eebus-bridge/third_party/spine-go/LICENSE new file mode 100644 index 0000000..56a7aad --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/LICENSE @@ -0,0 +1,22 @@ +MIT license + +Copyright (c) 2022 Andreas Linde & Timo Vogel +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/eebus-bridge/third_party/spine-go/PATCHES.md b/src/eebus-bridge/third_party/spine-go/PATCHES.md new file mode 100644 index 0000000..1c87933 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/PATCHES.md @@ -0,0 +1,22 @@ +# spine-go v0.7.0, patched + +This directory is [enbility/spine-go](https://github.com/enbility/spine-go) at +v0.7.0 (the module as published, without its tests, test data and CI files), +with the fixes below. The original is MIT-licensed (LICENSE, unchanged). The +modifications are Copyright © 2026 Setti Solutions S.R.L, www.setti.md, and +are published under the same MIT licence. The EEBUS bridge uses this copy +through a `replace` in its go.mod; drop it when a spine-go release has these +fixes (v0.7.0 is the latest release as of 2026-11-13; the `dev` branch has +the first one, unreleased). + +| File | Change | +|---|---| +| `spine/events.go` | `Publish` ranges a copy of the handlers taken under `mu`. Before, `copy()` ran in the wrong direction (into the handlers from an empty slice) and the loop read `r.handlers` without the lock while a new remote device subscribed (`SetupRemoteDevice`): a data race on every connection set up while events are published. The handler lock (`muHandle`) is unlocked deferred: a core handler's panic that the caller recovers (a SHIP connection's read pump) left the bus locked, and every later `Publish` blocked: the whole service hung. | +| `spine/device_local.go` | `RemoveRemoteDevice` deletes from and counts `remoteDevices` under `mux`. Before, both ran without the lock while other connections added or looked up their devices: a concurrent map write when devices connect and disconnect at once. | +| `spine/function_data.go` | A partial update (`UpdateData` with filters or without `persist`) works on a copy of what it writes (`copyForUpdate`: the list fields' arrays, items by value; the update only sets item fields, never writes through pointers or into nested arrays; 2 µs for a 200-item list, a full deep copy cost 160 µs). `DataCopy` copies only the struct, so its readers shared the slices and items the update then changed in place (e.g. a cs/lpc limit approved while the application read `ConsumptionLimit()`): a data race. | +| `spine/feature_local.go` | `BindToRemote` and `SubscribeToRemote` record a remote feature once (check and append in one critical section, `addOnce`): a binding requested again (the remote lost it) added a duplicate each time. | +| `spine/device.go`, `spine/device_remote.go` | A device's description (address, type, feature set) under a lock: `UpdateDevice` (a detailed discovery reply, on that connection's goroutine) wrote it while `RemoteDeviceForAddress` (another connection's) read every remote device's address. | + +Tests: `spine/events_panic_test.go`, `spine/function_data_copy_test.go`, +`spine/feature_local_bind_test.go` (`go test -race ./spine`; in `../`, `go.work` +builds them against the other patched copies). diff --git a/src/eebus-bridge/third_party/spine-go/api/api.go b/src/eebus-bridge/third_party/spine-go/api/api.go new file mode 100644 index 0000000..d71b17b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/api.go @@ -0,0 +1,53 @@ +package api + +import ( + "github.com/enbility/spine-go/model" +) + +//go:generate mockery + +type EventHandlerInterface interface { + HandleEvent(EventPayload) +} + +/* Binding Manager */ + +// implemented by BindingManagerImpl +type BindingManagerInterface interface { + AddBinding(remoteDevice DeviceRemoteInterface, data model.BindingManagementRequestCallType) error + RemoveBinding(data model.BindingManagementDeleteCallType, remoteDevice DeviceRemoteInterface) error + RemoveBindingsForDevice(remoteDevice DeviceRemoteInterface) + RemoveBindingsForEntity(remoteEntity EntityRemoteInterface) + Bindings(remoteDevice DeviceRemoteInterface) []*BindingEntry + BindingsOnFeature(featureAddress model.FeatureAddressType) []*BindingEntry + HasLocalFeatureRemoteBinding(localAddress, remoteAddress *model.FeatureAddressType) bool +} + +/* Subscription Manager */ + +type SubscriptionManagerInterface interface { + AddSubscription(remoteDevice DeviceRemoteInterface, data model.SubscriptionManagementRequestCallType) error + RemoveSubscription(data model.SubscriptionManagementDeleteCallType, remoteDevice DeviceRemoteInterface) error + RemoveSubscriptionsForDevice(remoteDevice DeviceRemoteInterface) + RemoveSubscriptionsForEntity(remoteEntity EntityRemoteInterface) + Subscriptions(remoteDevice DeviceRemoteInterface) []*SubscriptionEntry + SubscriptionsOnFeature(featureAddress model.FeatureAddressType) []*SubscriptionEntry +} + +/* Heartbeats */ + +type HeartbeatManagerInterface interface { + IsHeartbeatRunning() bool + SetLocalFeature(entity EntityLocalInterface, feature FeatureLocalInterface) + StartHeartbeat() error + StopHeartbeat() +} + +type OperationsInterface interface { + Write() bool + WritePartial() bool + Read() bool + ReadPartial() bool + String() string + Information() *model.PossibleOperationsType +} diff --git a/src/eebus-bridge/third_party/spine-go/api/binding.go b/src/eebus-bridge/third_party/spine-go/api/binding.go new file mode 100644 index 0000000..e645e46 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/binding.go @@ -0,0 +1,7 @@ +package api + +type BindingEntry struct { + Id uint64 + ServerFeature FeatureLocalInterface + ClientFeature FeatureRemoteInterface +} diff --git a/src/eebus-bridge/third_party/spine-go/api/device.go b/src/eebus-bridge/third_party/spine-go/api/device.go new file mode 100644 index 0000000..3d51440 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/device.go @@ -0,0 +1,122 @@ +package api + +import ( + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/spine-go/model" +) + +/* Device */ + +// This interface defines the functions being common to local and remote devices +// A device corresponds to a SPINE device, see SPINE Introduction Chapter 2.2 +type DeviceInterface interface { + // Get the device address + Address() *model.AddressDeviceType + // Get the device type + DeviceType() *model.DeviceTypeType + // Get the device feature set + FeatureSet() *model.NetworkManagementFeatureSetType + // Get the device destination data + DestinationData() model.NodeManagementDestinationDataType +} + +// This interface defines all the required functions need to implement a local device +type DeviceLocalInterface interface { + DeviceInterface + // Setup a new remote device with a given SKI and triggers SPINE requesting device details + SetupRemoteDevice(ski string, writeI shipapi.ShipConnectionDataWriterInterface) shipapi.ShipConnectionDataReaderInterface + // Add a DeviceRemoteInterface implementation (used in SetupRemoteDevice and in tests) + AddRemoteDeviceForSki(ski string, rDevice DeviceRemoteInterface) + + // Request NodeManagementDetailedDiscovery Data from a remote device + RequestRemoteDetailedDiscoveryData(rDevice DeviceRemoteInterface) (*model.MsgCounterType, *model.ErrorType) + + // Remove a remote device and its connection + RemoveRemoteDeviceConnection(ski string) + // Remove a remote device (used in RemoveRemoteDeviceConnection and in tests) + RemoveRemoteDevice(ski string) + + // Get a list of connected remote devices DeviceRemoteInterface implementations + RemoteDevices() []DeviceRemoteInterface + // Get a connected remote device DeviceRemoteInterface implementation for a given device address + RemoteDeviceForAddress(address model.AddressDeviceType) DeviceRemoteInterface + // Get a connected remote device DeviceRemoteInterface implementation for a SKI + RemoteDeviceForSki(ski string) DeviceRemoteInterface + + // Add a new entity to the device + // It should trigger a notification of all remote devices about this new entity + AddEntity(entity EntityLocalInterface) + // Remove a entity from the device + // It should trigger a notification of all remote devices about this removed entity + RemoveEntity(entity EntityLocalInterface) + // Get a list of all entities EntityLocalInterface implementations + Entities() []EntityLocalInterface + // Get an entity EntityLocalInterface implementation for a given entity address + Entity(id []model.AddressEntityType) EntityLocalInterface + // Get the first entity EntityLocalInterface implementation for a given entity type + EntityForType(entityType model.EntityTypeType) EntityLocalInterface + + // Get a FeatureLocalInterface implementation for a given feature address + FeatureByAddress(address *model.FeatureAddressType) FeatureLocalInterface + + // Clean all entity specific caches + CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) + + // Process incoming SPINE datagram + ProcessCmd(datagram model.DatagramType, remoteDevice DeviceRemoteInterface) error + + // Get the node management + NodeManagement() NodeManagementInterface + + // Get the bindings manager + BindingManager() BindingManagerInterface + + // Get the subscription manager + SubscriptionManager() SubscriptionManagerInterface + // Send a notify message to remote device subscribing to a specific feature + NotifySubscribers(featureAddress *model.FeatureAddressType, cmd model.CmdType) + + // Get the SPINE data structure for NodeManagementDetailDiscoveryData messages for this device + Information() *model.NodeManagementDetailedDiscoveryDeviceInformationType +} + +// This interface defines all the required functions need to implement a remote device +type DeviceRemoteInterface interface { + DeviceInterface + // Get the SKI of a remote device + Ski() string + + // Add a new entity EntityRemoteInterface implementation + AddEntity(entity EntityRemoteInterface) + + // Remove an entity for a given address and return the entity that was removed + RemoveEntityByAddress(addr []model.AddressEntityType) EntityRemoteInterface + + // Get an entity EntityRemoteInterface implementation for a given address + Entity(id []model.AddressEntityType) EntityRemoteInterface + // Get all entities EntityRemoteInterface implementations + Entities() []EntityRemoteInterface + + // Get a feature FeatureRemoteInterface implementation for a given address + FeatureByAddress(address *model.FeatureAddressType) FeatureRemoteInterface + // Get a feature FeatureRemoteInterface implementation from a given entity EntityRemoteInterface implementation by the feature type and feature role + FeatureByEntityTypeAndRole(entity EntityRemoteInterface, featureType model.FeatureTypeType, role model.RoleType) FeatureRemoteInterface + + // Process incoming data payload + HandleSpineMesssage(message []byte) (*model.MsgCounterType, error) + + // Get the SenderInterface implementation + Sender() SenderInterface + + // Get the devices usecase data + UseCases() []model.UseCaseInformationDataType + + // Update the devices address, type and featureset based on NetworkManagementDeviceDescriptionData + UpdateDevice(description *model.NetworkManagementDeviceDescriptionDataType) + + // Add entities and their features using provided NodeManagementDetailedDiscoveryData + AddEntityAndFeatures(initialData bool, data *model.NodeManagementDetailedDiscoveryDataType) ([]EntityRemoteInterface, error) + + // Helper method for checking incoming NodeManagementDetailedDiscoveryEntityInformation data + CheckEntityInformation(initialData bool, entity model.NodeManagementDetailedDiscoveryEntityInformationType) error +} diff --git a/src/eebus-bridge/third_party/spine-go/api/entity.go b/src/eebus-bridge/third_party/spine-go/api/entity.go new file mode 100644 index 0000000..acec844 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/entity.go @@ -0,0 +1,98 @@ +package api + +import "github.com/enbility/spine-go/model" + +/* Entity */ + +// This interface defines the functions being common to local and remote entites +// An entity corresponds to a SPINE entity, see SPINE Introduction Chapter 2.2 +type EntityInterface interface { + // Get the entity address + Address() *model.EntityAddressType + // Get the entity type + EntityType() model.EntityTypeType + // Get the entity description + Description() *model.DescriptionType + // Set the entity description + SetDescription(d *model.DescriptionType) + // Get the next incremental feature id + NextFeatureId() uint +} + +// This interface defines all the required functions need to implement a local entity +type EntityLocalInterface interface { + EntityInterface + // Get the associated DeviceLocalInterface implementation + Device() DeviceLocalInterface + + // Get the hearbeat manager for this entity + HeartbeatManager() HeartbeatManagerInterface + + // Add a new feature with a given FeatureLocalInterface implementation + AddFeature(f FeatureLocalInterface) + // Get a FeatureLocalInterface implementation for a given feature type and role or create it if it does not exist yet and return it + GetOrAddFeature(featureType model.FeatureTypeType, role model.RoleType) FeatureLocalInterface + // Get a FeatureLocalInterface implementation for a given feature type and role + FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) FeatureLocalInterface + // Get a FeatureLocalInterface implementation for a given feature address + FeatureOfAddress(addressFeature *model.AddressFeatureType) FeatureLocalInterface + // Get all FeatureLocalInterface implementations + Features() []FeatureLocalInterface + + // Add a new usecase + AddUseCaseSupport( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType, + useCaseVersion model.SpecificationVersionType, + useCaseDocumemtSubRevision string, + useCaseAvailable bool, + scenarios []model.UseCaseScenarioSupportType, + ) + // Check if a use case is already added + HasUseCaseSupport( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType) bool + // Remove support for a usecase + RemoveUseCaseSupport( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType, + ) + // Set the availability of a usecase. This may only be used for usescases + // that act as a client within the usecase! + SetUseCaseAvailability(actor model.UseCaseActorType, useCaseName model.UseCaseNameType, available bool) + // Remove all usecases + RemoveAllUseCaseSupports() + + // Remove all subscriptions + RemoveAllSubscriptions() + + // Remove all bindings + RemoveAllBindings() + + // Get the SPINE data structure for NodeManagementDetailDiscoveryData messages for this entity + Information() *model.NodeManagementDetailedDiscoveryEntityInformationType +} + +// This interface defines all the required functions need to implement a remote entity +type EntityRemoteInterface interface { + EntityInterface + + // Get the associated DeviceRemoteInterface implementation + Device() DeviceRemoteInterface + + // Update the device address (only used for the DeviceInformation entity when receiving the DetailDiscovery reply) + UpdateDeviceAddress(address model.AddressDeviceType) + + // Add a new feature with a given FeatureLocalInterface implementation + AddFeature(f FeatureRemoteInterface) + + // Remove all features + RemoveAllFeatures() + + // Get a FeatureRemoteInterface implementation for a given feature type and role + FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) FeatureRemoteInterface + // Get a FeatureRemoteInterface implementation for a given feature address + FeatureOfAddress(addressFeature *model.AddressFeatureType) FeatureRemoteInterface + // Get all FeatureRemoteInterface implementations + Features() []FeatureRemoteInterface +} diff --git a/src/eebus-bridge/third_party/spine-go/api/events.go b/src/eebus-bridge/third_party/spine-go/api/events.go new file mode 100644 index 0000000..57a5d68 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/events.go @@ -0,0 +1,41 @@ +package api + +import "github.com/enbility/spine-go/model" + +type EventHandlerLevel uint + +const ( + EventHandlerLevelCore EventHandlerLevel = iota // Shall only be used by the core stack + EventHandlerLevelApplication // Shall only be used by applications +) + +type ElementChangeType uint16 + +const ( + ElementChangeAdd ElementChangeType = iota + ElementChangeUpdate + ElementChangeRemove +) + +type EventType uint16 + +const ( + EventTypeDeviceChange EventType = iota // Sent after successful response of NodeManagementDetailedDiscovery + EventTypeEntityChange // Sent after successful response of NodeManagementDetailedDiscovery + EventTypeSubscriptionChange // Sent after successful subscription request from remote + EventTypeBindingChange // Sent after successful binding request from remote + EventTypeDataChange // Sent after remote provided new data items for a function +) + +type EventPayload struct { + Ski string // required + EventType EventType // required + ChangeType ElementChangeType // required + Device DeviceRemoteInterface // required for DetailedDiscovery Call + Entity EntityRemoteInterface // required for DetailedDiscovery Call and Notify + Feature FeatureRemoteInterface + LocalFeature FeatureLocalInterface // required for write commands + Function model.FunctionType // required for write commands + CmdClassifier *model.CmdClassifierType // optional, used together with EventType EventTypeDataChange + Data any +} diff --git a/src/eebus-bridge/third_party/spine-go/api/feature.go b/src/eebus-bridge/third_party/spine-go/api/feature.go new file mode 100644 index 0000000..20173bb --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/feature.go @@ -0,0 +1,150 @@ +package api + +import ( + "time" + + "github.com/enbility/spine-go/model" +) + +/* Feature */ + +// This interface defines the functions being common to local and remote features +// A feature corresponds to a SPINE feature, see SPINE Introduction Chapter 2.2 +type FeatureInterface interface { + // Get the feature address + Address() *model.FeatureAddressType + // Get the feature type + Type() model.FeatureTypeType + // Get the feature role + Role() model.RoleType + // Get the feature operations + Operations() map[model.FunctionType]OperationsInterface + // Get the feature description + Description() *model.DescriptionType + // Set the feature description with a given type + SetDescription(desc *model.DescriptionType) + // Set the feature description with a given string + SetDescriptionString(s string) + // Return a descriptive feature summary as a string + String() string +} + +// Callback function used to verify if an incoming SPINE write message should be allowed or not +// The cb function has to be invoked within 1 minute, otherwise the stack will +// deny the write command +type WriteApprovalCallbackFunc func(msg *Message) + +// This interface defines all the required functions need to implement a local feature +type FeatureLocalInterface interface { + FeatureInterface + // Get the associated DeviceLocalInterface implementation + Device() DeviceLocalInterface + // Get the associated EntityLocalInterface implementation + Entity() EntityLocalInterface + + // Add a function type with allowed operations + AddFunctionType(function model.FunctionType, read, write bool) + // Add a callback function to be invoked when SPINE message comes in with a given msgCounterReference value + // + // Returns an error if there is already a callback for the msgCounter set + AddResponseCallback(msgCounterReference model.MsgCounterType, function func(msg ResponseMessage)) error + // Add a callback function to be invoked when a result message comes in for this feature + AddResultCallback(function func(msg ResponseMessage)) + + // Add a callback method for a server feature which is invoked to + // check wether an incoming write message shall be approved or denied + AddWriteApprovalCallback(function WriteApprovalCallbackFunc) error + // This function needs to be invoked within (default) 10 seconds after the via + // AddWriteApprovalCallback defined callback is being invoked. + // + // NOTE: To approve a write, ALL callbacks need to approve the write! + // + // ErrorType.ErrorNumber should be 0 if write is approved + ApproveOrDenyWrite(msg *Message, err model.ErrorType) + // Overwrite the default 1 minute timeout for write approvals + SetWriteApprovalTimeout(duration time.Duration) + + // Clean all write approval caches for a remote device ski + CleanWriteApprovalCaches(ski string) + // Clean all remote device specific caches + CleanRemoteDeviceCaches(remoteAddress *model.DeviceAddressType) + // Clean all remote entity specific caches + CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) + + // return all functions + Functions() []model.FunctionType + + // Get a copy of the features data for a given function type + DataCopy(function model.FunctionType) any + // Update the features data for a given function type + UpdateData(function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) *model.ErrorType + // Set the features data for a given function type + SetData(function model.FunctionType, data any) + + // Trigger a read request message for a given FeatureRemoteInterface implementation + RequestRemoteData( + function model.FunctionType, + selector any, + elements any, + destination FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType) + // Trigger a read request message for a remote ski and feature address + RequestRemoteDataBySenderAddress( + cmd model.CmdType, + sender SenderInterface, + destinationSki string, + destinationAddress *model.FeatureAddressType, + maxDelay time.Duration) (*model.MsgCounterType, *model.ErrorType) + + // Check if there already is a subscription to a given feature remote address + HasSubscriptionToRemote(remoteAddress *model.FeatureAddressType) bool + // Trigger a subscription request to a given feature remote address + SubscribeToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) + // Trigger a subscription removal request for a given feature remote address + RemoveRemoteSubscription(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) + // Trigger subscription removal requests for all subscriptions of this feature + RemoveAllRemoteSubscriptions() + + // Check if there already is a binding to a given feature remote address + HasBindingToRemote(remoteAddress *model.FeatureAddressType) bool + // Trigger a binding request to a given feature remote address + BindToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) + // Trigger a binding removal request for a given feature remote address + RemoveRemoteBinding(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) + // Trigger binding removal requests for all subscriptions of this feature + RemoveAllRemoteBindings() + + // Handle an incoming SPINE message for this feature + HandleMessage(message *Message) *model.ErrorType + + // Get the SPINE data structure for NodeManagementDetailDiscoveryData messages for this feature + Information() *model.NodeManagementDetailedDiscoveryFeatureInformationType +} + +// Interface for local NodeManagement feature +type NodeManagementInterface interface { + FeatureLocalInterface +} + +// This interface defines all the required functions need to implement a remote feature +type FeatureRemoteInterface interface { + FeatureInterface + + // Get the associated DeviceRemoteInterface implementation + Device() DeviceRemoteInterface + // Get the associated EntityRemoteInterface implementation + Entity() EntityRemoteInterface + + // Get a copy of the features data for a given function type + DataCopy(function model.FunctionType) any + // Set the features data for a given function type + // persist true will store the data, false will return the updated data without storing it + UpdateData(persist bool, function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) (any, *model.ErrorType) + + // Set the supported operations of the feature for a set of functions + SetOperations(functions []model.FunctionPropertyType) + + // Define the maximum response duration + SetMaxResponseDelay(delay *model.MaxResponseDelayType) + // Get the maximum allowed response duration + MaxResponseDelayDuration() time.Duration +} diff --git a/src/eebus-bridge/third_party/spine-go/api/function.go b/src/eebus-bridge/third_party/spine-go/api/function.go new file mode 100644 index 0000000..8f87d75 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/function.go @@ -0,0 +1,30 @@ +package api + +import "github.com/enbility/spine-go/model" + +/* Function */ + +type FunctionDataCmdInterface interface { + FunctionDataInterface + // Get the CmdType data for a read command + // + // Note: partialSelector and elements have to be pointers! + ReadCmdType(partialSelector any, elements any) model.CmdType + // Get the CmdType data for a reply command + ReplyCmdType(partial bool) model.CmdType + // Get the CmdType data for a notify or write command + // + // Note: partialSelector and elements have to be pointers! + NotifyOrWriteCmdType(deleteSelector, partialSelector any, partialWithoutSelector bool, deleteElements any) model.CmdType +} + +type FunctionDataInterface interface { + // Get the function type + FunctionType() model.FunctionType + // Return if this function supports partial writes + SupportsPartialWrite() bool + // Get a copy of the functions data + DataCopyAny() any + // Update the functions data, only persisted if persist is true, otherwise useful for creating full write datasets + UpdateDataAny(remoteWrite, persist bool, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) (any, *model.ErrorType) +} diff --git a/src/eebus-bridge/third_party/spine-go/api/message.go b/src/eebus-bridge/third_party/spine-go/api/message.go new file mode 100644 index 0000000..5d91b61 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/message.go @@ -0,0 +1,23 @@ +package api + +import "github.com/enbility/spine-go/model" + +type Message struct { + RequestHeader *model.HeaderType + CmdClassifier model.CmdClassifierType + Cmd model.CmdType + FilterPartial *model.FilterType + FilterDelete *model.FilterType + FeatureRemote FeatureRemoteInterface + EntityRemote EntityRemoteInterface + DeviceRemote DeviceRemoteInterface +} + +type ResponseMessage struct { + MsgCounterReference model.MsgCounterType // required + Data any // required + FeatureLocal FeatureLocalInterface // required + FeatureRemote FeatureRemoteInterface // required + EntityRemote EntityRemoteInterface // required + DeviceRemote DeviceRemoteInterface // required +} diff --git a/src/eebus-bridge/third_party/spine-go/api/sender.go b/src/eebus-bridge/third_party/spine-go/api/sender.go new file mode 100644 index 0000000..7aa5fa8 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/sender.go @@ -0,0 +1,37 @@ +package api + +import "github.com/enbility/spine-go/model" + +/* Sender */ + +type ComControlInterface interface { + // This must be connected to the correct remote device !! + SendSpineMessage(datagram model.DatagramType) error +} + +type SenderInterface interface { + // Process a received message, e.g. for handling caching data + ProcessResponseForMsgCounterReference(msgCounterRef *model.MsgCounterType) + // Sends a read cmd to request some data + Request(cmdClassifier model.CmdClassifierType, senderAddress, destinationAddress *model.FeatureAddressType, ackRequest bool, cmd []model.CmdType) (*model.MsgCounterType, error) + // Sends a result cmd with no error to indicate that a message was processed successfully + ResultSuccess(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType) error + // Sends a result cmd with error information to indicate that a message processing failed + ResultError(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, err *model.ErrorType) error + // Sends a reply cmd to response to a read cmd + Reply(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, cmd model.CmdType) error + // Sends a call cmd with a subscription request + Subscribe(senderAddress, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) + // Sends a call cmd with a subscription delete request + Unsubscribe(senderAddress, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) + // Sends a call cmd with a binding request + Bind(senderAddress, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) + // Sends a call cmd with a binding delte request + Unbind(senderAddress, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) + // Sends a notify cmd to indicate that a subscribed feature changed + Notify(senderAddress, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) + // Sends a write cmd, setting properties of remote features + Write(senderAddress, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) + // return the datagram for a given msgCounter (only availbe for Notify messages!), error if not found + DatagramForMsgCounter(msgCounter model.MsgCounterType) (model.DatagramType, error) +} diff --git a/src/eebus-bridge/third_party/spine-go/api/subscription.go b/src/eebus-bridge/third_party/spine-go/api/subscription.go new file mode 100644 index 0000000..cf69fd1 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/api/subscription.go @@ -0,0 +1,7 @@ +package api + +type SubscriptionEntry struct { + Id uint64 + ServerFeature FeatureLocalInterface + ClientFeature FeatureRemoteInterface +} diff --git a/src/eebus-bridge/third_party/spine-go/go.mod b/src/eebus-bridge/third_party/spine-go/go.mod new file mode 100644 index 0000000..eff0a1a --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/go.mod @@ -0,0 +1,21 @@ +module github.com/enbility/spine-go + +go 1.22.0 + +require ( + github.com/ahmetb/go-linq/v3 v3.2.0 + github.com/enbility/ship-go v0.6.0 + github.com/golanguzb70/lrucache v1.2.0 + github.com/google/go-cmp v0.6.0 + github.com/rickb777/date v1.21.1 + github.com/stretchr/testify v1.9.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rickb777/plural v1.4.2 // indirect + github.com/stretchr/objx v0.5.2 // indirect + golang.org/x/text v0.18.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/src/eebus-bridge/third_party/spine-go/go.sum b/src/eebus-bridge/third_party/spine-go/go.sum new file mode 100644 index 0000000..ae10519 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/go.sum @@ -0,0 +1,30 @@ +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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/enbility/ship-go v0.6.0 h1:1ft5NJJHqqGU3/ryYwQj8xBYJLFbf0q2cP9mjlYHlgw= +github.com/enbility/ship-go v0.6.0/go.mod h1:JJp8EQcJhUhTpZ2LSEU4rpdaM3E2n08tswWFWtmm/wU= +github.com/golanguzb70/lrucache v1.2.0 h1:VjpjmB4VTf9VXBtZTJGcgcN0CNFM5egDrrSjkGyQOlg= +github.com/golanguzb70/lrucache v1.2.0/go.mod h1:zc2GD26KwGEDdTHsCCTcJorv/11HyKwQVS9gqg2bizc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= +github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rickb777/date v1.21.1 h1:tUcQS8riIRoYK5kUAv5aevllFEYUEk2x8OYDyoldOn4= +github.com/rickb777/date v1.21.1/go.mod h1:gnDexsbXViZr2fCKMrY3m6IfAF5U2vSkEaiGJcNFaLQ= +github.com/rickb777/plural v1.4.2 h1:Kl/syFGLFZ5EbuV8c9SVud8s5HI2HpCCtOMw2U1kS+A= +github.com/rickb777/plural v1.4.2/go.mod h1:kdmXUpmKBJTS0FtG/TFumd//VBWsNTD7zOw7x4umxNw= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/src/eebus-bridge/third_party/spine-go/mocks/BindingManagerInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/BindingManagerInterface.go new file mode 100644 index 0000000..f020e19 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/BindingManagerInterface.go @@ -0,0 +1,340 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// BindingManagerInterface is an autogenerated mock type for the BindingManagerInterface type +type BindingManagerInterface struct { + mock.Mock +} + +type BindingManagerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *BindingManagerInterface) EXPECT() *BindingManagerInterface_Expecter { + return &BindingManagerInterface_Expecter{mock: &_m.Mock} +} + +// AddBinding provides a mock function with given fields: remoteDevice, data +func (_m *BindingManagerInterface) AddBinding(remoteDevice api.DeviceRemoteInterface, data model.BindingManagementRequestCallType) error { + ret := _m.Called(remoteDevice, data) + + if len(ret) == 0 { + panic("no return value specified for AddBinding") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface, model.BindingManagementRequestCallType) error); ok { + r0 = rf(remoteDevice, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// BindingManagerInterface_AddBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddBinding' +type BindingManagerInterface_AddBinding_Call struct { + *mock.Call +} + +// AddBinding is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +// - data model.BindingManagementRequestCallType +func (_e *BindingManagerInterface_Expecter) AddBinding(remoteDevice interface{}, data interface{}) *BindingManagerInterface_AddBinding_Call { + return &BindingManagerInterface_AddBinding_Call{Call: _e.mock.On("AddBinding", remoteDevice, data)} +} + +func (_c *BindingManagerInterface_AddBinding_Call) Run(run func(remoteDevice api.DeviceRemoteInterface, data model.BindingManagementRequestCallType)) *BindingManagerInterface_AddBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface), args[1].(model.BindingManagementRequestCallType)) + }) + return _c +} + +func (_c *BindingManagerInterface_AddBinding_Call) Return(_a0 error) *BindingManagerInterface_AddBinding_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BindingManagerInterface_AddBinding_Call) RunAndReturn(run func(api.DeviceRemoteInterface, model.BindingManagementRequestCallType) error) *BindingManagerInterface_AddBinding_Call { + _c.Call.Return(run) + return _c +} + +// Bindings provides a mock function with given fields: remoteDevice +func (_m *BindingManagerInterface) Bindings(remoteDevice api.DeviceRemoteInterface) []*api.BindingEntry { + ret := _m.Called(remoteDevice) + + if len(ret) == 0 { + panic("no return value specified for Bindings") + } + + var r0 []*api.BindingEntry + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface) []*api.BindingEntry); ok { + r0 = rf(remoteDevice) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*api.BindingEntry) + } + } + + return r0 +} + +// BindingManagerInterface_Bindings_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bindings' +type BindingManagerInterface_Bindings_Call struct { + *mock.Call +} + +// Bindings is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +func (_e *BindingManagerInterface_Expecter) Bindings(remoteDevice interface{}) *BindingManagerInterface_Bindings_Call { + return &BindingManagerInterface_Bindings_Call{Call: _e.mock.On("Bindings", remoteDevice)} +} + +func (_c *BindingManagerInterface_Bindings_Call) Run(run func(remoteDevice api.DeviceRemoteInterface)) *BindingManagerInterface_Bindings_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *BindingManagerInterface_Bindings_Call) Return(_a0 []*api.BindingEntry) *BindingManagerInterface_Bindings_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BindingManagerInterface_Bindings_Call) RunAndReturn(run func(api.DeviceRemoteInterface) []*api.BindingEntry) *BindingManagerInterface_Bindings_Call { + _c.Call.Return(run) + return _c +} + +// BindingsOnFeature provides a mock function with given fields: featureAddress +func (_m *BindingManagerInterface) BindingsOnFeature(featureAddress model.FeatureAddressType) []*api.BindingEntry { + ret := _m.Called(featureAddress) + + if len(ret) == 0 { + panic("no return value specified for BindingsOnFeature") + } + + var r0 []*api.BindingEntry + if rf, ok := ret.Get(0).(func(model.FeatureAddressType) []*api.BindingEntry); ok { + r0 = rf(featureAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*api.BindingEntry) + } + } + + return r0 +} + +// BindingManagerInterface_BindingsOnFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindingsOnFeature' +type BindingManagerInterface_BindingsOnFeature_Call struct { + *mock.Call +} + +// BindingsOnFeature is a helper method to define mock.On call +// - featureAddress model.FeatureAddressType +func (_e *BindingManagerInterface_Expecter) BindingsOnFeature(featureAddress interface{}) *BindingManagerInterface_BindingsOnFeature_Call { + return &BindingManagerInterface_BindingsOnFeature_Call{Call: _e.mock.On("BindingsOnFeature", featureAddress)} +} + +func (_c *BindingManagerInterface_BindingsOnFeature_Call) Run(run func(featureAddress model.FeatureAddressType)) *BindingManagerInterface_BindingsOnFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FeatureAddressType)) + }) + return _c +} + +func (_c *BindingManagerInterface_BindingsOnFeature_Call) Return(_a0 []*api.BindingEntry) *BindingManagerInterface_BindingsOnFeature_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BindingManagerInterface_BindingsOnFeature_Call) RunAndReturn(run func(model.FeatureAddressType) []*api.BindingEntry) *BindingManagerInterface_BindingsOnFeature_Call { + _c.Call.Return(run) + return _c +} + +// HasLocalFeatureRemoteBinding provides a mock function with given fields: localAddress, remoteAddress +func (_m *BindingManagerInterface) HasLocalFeatureRemoteBinding(localAddress *model.FeatureAddressType, remoteAddress *model.FeatureAddressType) bool { + ret := _m.Called(localAddress, remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for HasLocalFeatureRemoteBinding") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType) bool); ok { + r0 = rf(localAddress, remoteAddress) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// BindingManagerInterface_HasLocalFeatureRemoteBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasLocalFeatureRemoteBinding' +type BindingManagerInterface_HasLocalFeatureRemoteBinding_Call struct { + *mock.Call +} + +// HasLocalFeatureRemoteBinding is a helper method to define mock.On call +// - localAddress *model.FeatureAddressType +// - remoteAddress *model.FeatureAddressType +func (_e *BindingManagerInterface_Expecter) HasLocalFeatureRemoteBinding(localAddress interface{}, remoteAddress interface{}) *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call { + return &BindingManagerInterface_HasLocalFeatureRemoteBinding_Call{Call: _e.mock.On("HasLocalFeatureRemoteBinding", localAddress, remoteAddress)} +} + +func (_c *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call) Run(run func(localAddress *model.FeatureAddressType, remoteAddress *model.FeatureAddressType)) *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call) Return(_a0 bool) *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType) bool) *BindingManagerInterface_HasLocalFeatureRemoteBinding_Call { + _c.Call.Return(run) + return _c +} + +// RemoveBinding provides a mock function with given fields: data, remoteDevice +func (_m *BindingManagerInterface) RemoveBinding(data model.BindingManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface) error { + ret := _m.Called(data, remoteDevice) + + if len(ret) == 0 { + panic("no return value specified for RemoveBinding") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.BindingManagementDeleteCallType, api.DeviceRemoteInterface) error); ok { + r0 = rf(data, remoteDevice) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// BindingManagerInterface_RemoveBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveBinding' +type BindingManagerInterface_RemoveBinding_Call struct { + *mock.Call +} + +// RemoveBinding is a helper method to define mock.On call +// - data model.BindingManagementDeleteCallType +// - remoteDevice api.DeviceRemoteInterface +func (_e *BindingManagerInterface_Expecter) RemoveBinding(data interface{}, remoteDevice interface{}) *BindingManagerInterface_RemoveBinding_Call { + return &BindingManagerInterface_RemoveBinding_Call{Call: _e.mock.On("RemoveBinding", data, remoteDevice)} +} + +func (_c *BindingManagerInterface_RemoveBinding_Call) Run(run func(data model.BindingManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface)) *BindingManagerInterface_RemoveBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.BindingManagementDeleteCallType), args[1].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *BindingManagerInterface_RemoveBinding_Call) Return(_a0 error) *BindingManagerInterface_RemoveBinding_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *BindingManagerInterface_RemoveBinding_Call) RunAndReturn(run func(model.BindingManagementDeleteCallType, api.DeviceRemoteInterface) error) *BindingManagerInterface_RemoveBinding_Call { + _c.Call.Return(run) + return _c +} + +// RemoveBindingsForDevice provides a mock function with given fields: remoteDevice +func (_m *BindingManagerInterface) RemoveBindingsForDevice(remoteDevice api.DeviceRemoteInterface) { + _m.Called(remoteDevice) +} + +// BindingManagerInterface_RemoveBindingsForDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveBindingsForDevice' +type BindingManagerInterface_RemoveBindingsForDevice_Call struct { + *mock.Call +} + +// RemoveBindingsForDevice is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +func (_e *BindingManagerInterface_Expecter) RemoveBindingsForDevice(remoteDevice interface{}) *BindingManagerInterface_RemoveBindingsForDevice_Call { + return &BindingManagerInterface_RemoveBindingsForDevice_Call{Call: _e.mock.On("RemoveBindingsForDevice", remoteDevice)} +} + +func (_c *BindingManagerInterface_RemoveBindingsForDevice_Call) Run(run func(remoteDevice api.DeviceRemoteInterface)) *BindingManagerInterface_RemoveBindingsForDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *BindingManagerInterface_RemoveBindingsForDevice_Call) Return() *BindingManagerInterface_RemoveBindingsForDevice_Call { + _c.Call.Return() + return _c +} + +func (_c *BindingManagerInterface_RemoveBindingsForDevice_Call) RunAndReturn(run func(api.DeviceRemoteInterface)) *BindingManagerInterface_RemoveBindingsForDevice_Call { + _c.Call.Return(run) + return _c +} + +// RemoveBindingsForEntity provides a mock function with given fields: remoteEntity +func (_m *BindingManagerInterface) RemoveBindingsForEntity(remoteEntity api.EntityRemoteInterface) { + _m.Called(remoteEntity) +} + +// BindingManagerInterface_RemoveBindingsForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveBindingsForEntity' +type BindingManagerInterface_RemoveBindingsForEntity_Call struct { + *mock.Call +} + +// RemoveBindingsForEntity is a helper method to define mock.On call +// - remoteEntity api.EntityRemoteInterface +func (_e *BindingManagerInterface_Expecter) RemoveBindingsForEntity(remoteEntity interface{}) *BindingManagerInterface_RemoveBindingsForEntity_Call { + return &BindingManagerInterface_RemoveBindingsForEntity_Call{Call: _e.mock.On("RemoveBindingsForEntity", remoteEntity)} +} + +func (_c *BindingManagerInterface_RemoveBindingsForEntity_Call) Run(run func(remoteEntity api.EntityRemoteInterface)) *BindingManagerInterface_RemoveBindingsForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityRemoteInterface)) + }) + return _c +} + +func (_c *BindingManagerInterface_RemoveBindingsForEntity_Call) Return() *BindingManagerInterface_RemoveBindingsForEntity_Call { + _c.Call.Return() + return _c +} + +func (_c *BindingManagerInterface_RemoveBindingsForEntity_Call) RunAndReturn(run func(api.EntityRemoteInterface)) *BindingManagerInterface_RemoveBindingsForEntity_Call { + _c.Call.Return(run) + return _c +} + +// NewBindingManagerInterface creates a new instance of BindingManagerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewBindingManagerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *BindingManagerInterface { + mock := &BindingManagerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/ComControlInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/ComControlInterface.go new file mode 100644 index 0000000..9d60e2d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/ComControlInterface.go @@ -0,0 +1,81 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// ComControlInterface is an autogenerated mock type for the ComControlInterface type +type ComControlInterface struct { + mock.Mock +} + +type ComControlInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *ComControlInterface) EXPECT() *ComControlInterface_Expecter { + return &ComControlInterface_Expecter{mock: &_m.Mock} +} + +// SendSpineMessage provides a mock function with given fields: datagram +func (_m *ComControlInterface) SendSpineMessage(datagram model.DatagramType) error { + ret := _m.Called(datagram) + + if len(ret) == 0 { + panic("no return value specified for SendSpineMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.DatagramType) error); ok { + r0 = rf(datagram) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ComControlInterface_SendSpineMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendSpineMessage' +type ComControlInterface_SendSpineMessage_Call struct { + *mock.Call +} + +// SendSpineMessage is a helper method to define mock.On call +// - datagram model.DatagramType +func (_e *ComControlInterface_Expecter) SendSpineMessage(datagram interface{}) *ComControlInterface_SendSpineMessage_Call { + return &ComControlInterface_SendSpineMessage_Call{Call: _e.mock.On("SendSpineMessage", datagram)} +} + +func (_c *ComControlInterface_SendSpineMessage_Call) Run(run func(datagram model.DatagramType)) *ComControlInterface_SendSpineMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DatagramType)) + }) + return _c +} + +func (_c *ComControlInterface_SendSpineMessage_Call) Return(_a0 error) *ComControlInterface_SendSpineMessage_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ComControlInterface_SendSpineMessage_Call) RunAndReturn(run func(model.DatagramType) error) *ComControlInterface_SendSpineMessage_Call { + _c.Call.Return(run) + return _c +} + +// NewComControlInterface creates a new instance of ComControlInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewComControlInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *ComControlInterface { + mock := &ComControlInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/DeviceInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/DeviceInterface.go new file mode 100644 index 0000000..66e9e78 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/DeviceInterface.go @@ -0,0 +1,221 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// DeviceInterface is an autogenerated mock type for the DeviceInterface type +type DeviceInterface struct { + mock.Mock +} + +type DeviceInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceInterface) EXPECT() *DeviceInterface_Expecter { + return &DeviceInterface_Expecter{mock: &_m.Mock} +} + +// Address provides a mock function with given fields: +func (_m *DeviceInterface) Address() *model.AddressDeviceType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.AddressDeviceType + if rf, ok := ret.Get(0).(func() *model.AddressDeviceType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.AddressDeviceType) + } + } + + return r0 +} + +// DeviceInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type DeviceInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *DeviceInterface_Expecter) Address() *DeviceInterface_Address_Call { + return &DeviceInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *DeviceInterface_Address_Call) Run(run func()) *DeviceInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceInterface_Address_Call) Return(_a0 *model.AddressDeviceType) *DeviceInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceInterface_Address_Call) RunAndReturn(run func() *model.AddressDeviceType) *DeviceInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// DestinationData provides a mock function with given fields: +func (_m *DeviceInterface) DestinationData() model.NodeManagementDestinationDataType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DestinationData") + } + + var r0 model.NodeManagementDestinationDataType + if rf, ok := ret.Get(0).(func() model.NodeManagementDestinationDataType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.NodeManagementDestinationDataType) + } + + return r0 +} + +// DeviceInterface_DestinationData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestinationData' +type DeviceInterface_DestinationData_Call struct { + *mock.Call +} + +// DestinationData is a helper method to define mock.On call +func (_e *DeviceInterface_Expecter) DestinationData() *DeviceInterface_DestinationData_Call { + return &DeviceInterface_DestinationData_Call{Call: _e.mock.On("DestinationData")} +} + +func (_c *DeviceInterface_DestinationData_Call) Run(run func()) *DeviceInterface_DestinationData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceInterface_DestinationData_Call) Return(_a0 model.NodeManagementDestinationDataType) *DeviceInterface_DestinationData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceInterface_DestinationData_Call) RunAndReturn(run func() model.NodeManagementDestinationDataType) *DeviceInterface_DestinationData_Call { + _c.Call.Return(run) + return _c +} + +// DeviceType provides a mock function with given fields: +func (_m *DeviceInterface) DeviceType() *model.DeviceTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DeviceType") + } + + var r0 *model.DeviceTypeType + if rf, ok := ret.Get(0).(func() *model.DeviceTypeType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceTypeType) + } + } + + return r0 +} + +// DeviceInterface_DeviceType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeviceType' +type DeviceInterface_DeviceType_Call struct { + *mock.Call +} + +// DeviceType is a helper method to define mock.On call +func (_e *DeviceInterface_Expecter) DeviceType() *DeviceInterface_DeviceType_Call { + return &DeviceInterface_DeviceType_Call{Call: _e.mock.On("DeviceType")} +} + +func (_c *DeviceInterface_DeviceType_Call) Run(run func()) *DeviceInterface_DeviceType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceInterface_DeviceType_Call) Return(_a0 *model.DeviceTypeType) *DeviceInterface_DeviceType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceInterface_DeviceType_Call) RunAndReturn(run func() *model.DeviceTypeType) *DeviceInterface_DeviceType_Call { + _c.Call.Return(run) + return _c +} + +// FeatureSet provides a mock function with given fields: +func (_m *DeviceInterface) FeatureSet() *model.NetworkManagementFeatureSetType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FeatureSet") + } + + var r0 *model.NetworkManagementFeatureSetType + if rf, ok := ret.Get(0).(func() *model.NetworkManagementFeatureSetType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NetworkManagementFeatureSetType) + } + } + + return r0 +} + +// DeviceInterface_FeatureSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureSet' +type DeviceInterface_FeatureSet_Call struct { + *mock.Call +} + +// FeatureSet is a helper method to define mock.On call +func (_e *DeviceInterface_Expecter) FeatureSet() *DeviceInterface_FeatureSet_Call { + return &DeviceInterface_FeatureSet_Call{Call: _e.mock.On("FeatureSet")} +} + +func (_c *DeviceInterface_FeatureSet_Call) Run(run func()) *DeviceInterface_FeatureSet_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceInterface_FeatureSet_Call) Return(_a0 *model.NetworkManagementFeatureSetType) *DeviceInterface_FeatureSet_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceInterface_FeatureSet_Call) RunAndReturn(run func() *model.NetworkManagementFeatureSetType) *DeviceInterface_FeatureSet_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceInterface creates a new instance of DeviceInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceInterface { + mock := &DeviceInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/DeviceLocalInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/DeviceLocalInterface.go new file mode 100644 index 0000000..107e169 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/DeviceLocalInterface.go @@ -0,0 +1,1183 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + ship_goapi "github.com/enbility/ship-go/api" +) + +// DeviceLocalInterface is an autogenerated mock type for the DeviceLocalInterface type +type DeviceLocalInterface struct { + mock.Mock +} + +type DeviceLocalInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceLocalInterface) EXPECT() *DeviceLocalInterface_Expecter { + return &DeviceLocalInterface_Expecter{mock: &_m.Mock} +} + +// AddEntity provides a mock function with given fields: entity +func (_m *DeviceLocalInterface) AddEntity(entity api.EntityLocalInterface) { + _m.Called(entity) +} + +// DeviceLocalInterface_AddEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddEntity' +type DeviceLocalInterface_AddEntity_Call struct { + *mock.Call +} + +// AddEntity is a helper method to define mock.On call +// - entity api.EntityLocalInterface +func (_e *DeviceLocalInterface_Expecter) AddEntity(entity interface{}) *DeviceLocalInterface_AddEntity_Call { + return &DeviceLocalInterface_AddEntity_Call{Call: _e.mock.On("AddEntity", entity)} +} + +func (_c *DeviceLocalInterface_AddEntity_Call) Run(run func(entity api.EntityLocalInterface)) *DeviceLocalInterface_AddEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityLocalInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_AddEntity_Call) Return() *DeviceLocalInterface_AddEntity_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_AddEntity_Call) RunAndReturn(run func(api.EntityLocalInterface)) *DeviceLocalInterface_AddEntity_Call { + _c.Call.Return(run) + return _c +} + +// AddRemoteDeviceForSki provides a mock function with given fields: ski, rDevice +func (_m *DeviceLocalInterface) AddRemoteDeviceForSki(ski string, rDevice api.DeviceRemoteInterface) { + _m.Called(ski, rDevice) +} + +// DeviceLocalInterface_AddRemoteDeviceForSki_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRemoteDeviceForSki' +type DeviceLocalInterface_AddRemoteDeviceForSki_Call struct { + *mock.Call +} + +// AddRemoteDeviceForSki is a helper method to define mock.On call +// - ski string +// - rDevice api.DeviceRemoteInterface +func (_e *DeviceLocalInterface_Expecter) AddRemoteDeviceForSki(ski interface{}, rDevice interface{}) *DeviceLocalInterface_AddRemoteDeviceForSki_Call { + return &DeviceLocalInterface_AddRemoteDeviceForSki_Call{Call: _e.mock.On("AddRemoteDeviceForSki", ski, rDevice)} +} + +func (_c *DeviceLocalInterface_AddRemoteDeviceForSki_Call) Run(run func(ski string, rDevice api.DeviceRemoteInterface)) *DeviceLocalInterface_AddRemoteDeviceForSki_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_AddRemoteDeviceForSki_Call) Return() *DeviceLocalInterface_AddRemoteDeviceForSki_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_AddRemoteDeviceForSki_Call) RunAndReturn(run func(string, api.DeviceRemoteInterface)) *DeviceLocalInterface_AddRemoteDeviceForSki_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *DeviceLocalInterface) Address() *model.AddressDeviceType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.AddressDeviceType + if rf, ok := ret.Get(0).(func() *model.AddressDeviceType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.AddressDeviceType) + } + } + + return r0 +} + +// DeviceLocalInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type DeviceLocalInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) Address() *DeviceLocalInterface_Address_Call { + return &DeviceLocalInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *DeviceLocalInterface_Address_Call) Run(run func()) *DeviceLocalInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_Address_Call) Return(_a0 *model.AddressDeviceType) *DeviceLocalInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_Address_Call) RunAndReturn(run func() *model.AddressDeviceType) *DeviceLocalInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// BindingManager provides a mock function with given fields: +func (_m *DeviceLocalInterface) BindingManager() api.BindingManagerInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for BindingManager") + } + + var r0 api.BindingManagerInterface + if rf, ok := ret.Get(0).(func() api.BindingManagerInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.BindingManagerInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_BindingManager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindingManager' +type DeviceLocalInterface_BindingManager_Call struct { + *mock.Call +} + +// BindingManager is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) BindingManager() *DeviceLocalInterface_BindingManager_Call { + return &DeviceLocalInterface_BindingManager_Call{Call: _e.mock.On("BindingManager")} +} + +func (_c *DeviceLocalInterface_BindingManager_Call) Run(run func()) *DeviceLocalInterface_BindingManager_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_BindingManager_Call) Return(_a0 api.BindingManagerInterface) *DeviceLocalInterface_BindingManager_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_BindingManager_Call) RunAndReturn(run func() api.BindingManagerInterface) *DeviceLocalInterface_BindingManager_Call { + _c.Call.Return(run) + return _c +} + +// CleanRemoteEntityCaches provides a mock function with given fields: remoteAddress +func (_m *DeviceLocalInterface) CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) { + _m.Called(remoteAddress) +} + +// DeviceLocalInterface_CleanRemoteEntityCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanRemoteEntityCaches' +type DeviceLocalInterface_CleanRemoteEntityCaches_Call struct { + *mock.Call +} + +// CleanRemoteEntityCaches is a helper method to define mock.On call +// - remoteAddress *model.EntityAddressType +func (_e *DeviceLocalInterface_Expecter) CleanRemoteEntityCaches(remoteAddress interface{}) *DeviceLocalInterface_CleanRemoteEntityCaches_Call { + return &DeviceLocalInterface_CleanRemoteEntityCaches_Call{Call: _e.mock.On("CleanRemoteEntityCaches", remoteAddress)} +} + +func (_c *DeviceLocalInterface_CleanRemoteEntityCaches_Call) Run(run func(remoteAddress *model.EntityAddressType)) *DeviceLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.EntityAddressType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_CleanRemoteEntityCaches_Call) Return() *DeviceLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_CleanRemoteEntityCaches_Call) RunAndReturn(run func(*model.EntityAddressType)) *DeviceLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return(run) + return _c +} + +// DestinationData provides a mock function with given fields: +func (_m *DeviceLocalInterface) DestinationData() model.NodeManagementDestinationDataType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DestinationData") + } + + var r0 model.NodeManagementDestinationDataType + if rf, ok := ret.Get(0).(func() model.NodeManagementDestinationDataType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.NodeManagementDestinationDataType) + } + + return r0 +} + +// DeviceLocalInterface_DestinationData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestinationData' +type DeviceLocalInterface_DestinationData_Call struct { + *mock.Call +} + +// DestinationData is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) DestinationData() *DeviceLocalInterface_DestinationData_Call { + return &DeviceLocalInterface_DestinationData_Call{Call: _e.mock.On("DestinationData")} +} + +func (_c *DeviceLocalInterface_DestinationData_Call) Run(run func()) *DeviceLocalInterface_DestinationData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_DestinationData_Call) Return(_a0 model.NodeManagementDestinationDataType) *DeviceLocalInterface_DestinationData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_DestinationData_Call) RunAndReturn(run func() model.NodeManagementDestinationDataType) *DeviceLocalInterface_DestinationData_Call { + _c.Call.Return(run) + return _c +} + +// DeviceType provides a mock function with given fields: +func (_m *DeviceLocalInterface) DeviceType() *model.DeviceTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DeviceType") + } + + var r0 *model.DeviceTypeType + if rf, ok := ret.Get(0).(func() *model.DeviceTypeType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceTypeType) + } + } + + return r0 +} + +// DeviceLocalInterface_DeviceType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeviceType' +type DeviceLocalInterface_DeviceType_Call struct { + *mock.Call +} + +// DeviceType is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) DeviceType() *DeviceLocalInterface_DeviceType_Call { + return &DeviceLocalInterface_DeviceType_Call{Call: _e.mock.On("DeviceType")} +} + +func (_c *DeviceLocalInterface_DeviceType_Call) Run(run func()) *DeviceLocalInterface_DeviceType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_DeviceType_Call) Return(_a0 *model.DeviceTypeType) *DeviceLocalInterface_DeviceType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_DeviceType_Call) RunAndReturn(run func() *model.DeviceTypeType) *DeviceLocalInterface_DeviceType_Call { + _c.Call.Return(run) + return _c +} + +// Entities provides a mock function with given fields: +func (_m *DeviceLocalInterface) Entities() []api.EntityLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Entities") + } + + var r0 []api.EntityLocalInterface + if rf, ok := ret.Get(0).(func() []api.EntityLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.EntityLocalInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_Entities_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entities' +type DeviceLocalInterface_Entities_Call struct { + *mock.Call +} + +// Entities is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) Entities() *DeviceLocalInterface_Entities_Call { + return &DeviceLocalInterface_Entities_Call{Call: _e.mock.On("Entities")} +} + +func (_c *DeviceLocalInterface_Entities_Call) Run(run func()) *DeviceLocalInterface_Entities_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_Entities_Call) Return(_a0 []api.EntityLocalInterface) *DeviceLocalInterface_Entities_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_Entities_Call) RunAndReturn(run func() []api.EntityLocalInterface) *DeviceLocalInterface_Entities_Call { + _c.Call.Return(run) + return _c +} + +// Entity provides a mock function with given fields: id +func (_m *DeviceLocalInterface) Entity(id []model.AddressEntityType) api.EntityLocalInterface { + ret := _m.Called(id) + + if len(ret) == 0 { + panic("no return value specified for Entity") + } + + var r0 api.EntityLocalInterface + if rf, ok := ret.Get(0).(func([]model.AddressEntityType) api.EntityLocalInterface); ok { + r0 = rf(id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityLocalInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_Entity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entity' +type DeviceLocalInterface_Entity_Call struct { + *mock.Call +} + +// Entity is a helper method to define mock.On call +// - id []model.AddressEntityType +func (_e *DeviceLocalInterface_Expecter) Entity(id interface{}) *DeviceLocalInterface_Entity_Call { + return &DeviceLocalInterface_Entity_Call{Call: _e.mock.On("Entity", id)} +} + +func (_c *DeviceLocalInterface_Entity_Call) Run(run func(id []model.AddressEntityType)) *DeviceLocalInterface_Entity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.AddressEntityType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_Entity_Call) Return(_a0 api.EntityLocalInterface) *DeviceLocalInterface_Entity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_Entity_Call) RunAndReturn(run func([]model.AddressEntityType) api.EntityLocalInterface) *DeviceLocalInterface_Entity_Call { + _c.Call.Return(run) + return _c +} + +// EntityForType provides a mock function with given fields: entityType +func (_m *DeviceLocalInterface) EntityForType(entityType model.EntityTypeType) api.EntityLocalInterface { + ret := _m.Called(entityType) + + if len(ret) == 0 { + panic("no return value specified for EntityForType") + } + + var r0 api.EntityLocalInterface + if rf, ok := ret.Get(0).(func(model.EntityTypeType) api.EntityLocalInterface); ok { + r0 = rf(entityType) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityLocalInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_EntityForType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EntityForType' +type DeviceLocalInterface_EntityForType_Call struct { + *mock.Call +} + +// EntityForType is a helper method to define mock.On call +// - entityType model.EntityTypeType +func (_e *DeviceLocalInterface_Expecter) EntityForType(entityType interface{}) *DeviceLocalInterface_EntityForType_Call { + return &DeviceLocalInterface_EntityForType_Call{Call: _e.mock.On("EntityForType", entityType)} +} + +func (_c *DeviceLocalInterface_EntityForType_Call) Run(run func(entityType model.EntityTypeType)) *DeviceLocalInterface_EntityForType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.EntityTypeType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_EntityForType_Call) Return(_a0 api.EntityLocalInterface) *DeviceLocalInterface_EntityForType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_EntityForType_Call) RunAndReturn(run func(model.EntityTypeType) api.EntityLocalInterface) *DeviceLocalInterface_EntityForType_Call { + _c.Call.Return(run) + return _c +} + +// FeatureByAddress provides a mock function with given fields: address +func (_m *DeviceLocalInterface) FeatureByAddress(address *model.FeatureAddressType) api.FeatureLocalInterface { + ret := _m.Called(address) + + if len(ret) == 0 { + panic("no return value specified for FeatureByAddress") + } + + var r0 api.FeatureLocalInterface + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) api.FeatureLocalInterface); ok { + r0 = rf(address) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureLocalInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_FeatureByAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureByAddress' +type DeviceLocalInterface_FeatureByAddress_Call struct { + *mock.Call +} + +// FeatureByAddress is a helper method to define mock.On call +// - address *model.FeatureAddressType +func (_e *DeviceLocalInterface_Expecter) FeatureByAddress(address interface{}) *DeviceLocalInterface_FeatureByAddress_Call { + return &DeviceLocalInterface_FeatureByAddress_Call{Call: _e.mock.On("FeatureByAddress", address)} +} + +func (_c *DeviceLocalInterface_FeatureByAddress_Call) Run(run func(address *model.FeatureAddressType)) *DeviceLocalInterface_FeatureByAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_FeatureByAddress_Call) Return(_a0 api.FeatureLocalInterface) *DeviceLocalInterface_FeatureByAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_FeatureByAddress_Call) RunAndReturn(run func(*model.FeatureAddressType) api.FeatureLocalInterface) *DeviceLocalInterface_FeatureByAddress_Call { + _c.Call.Return(run) + return _c +} + +// FeatureSet provides a mock function with given fields: +func (_m *DeviceLocalInterface) FeatureSet() *model.NetworkManagementFeatureSetType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FeatureSet") + } + + var r0 *model.NetworkManagementFeatureSetType + if rf, ok := ret.Get(0).(func() *model.NetworkManagementFeatureSetType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NetworkManagementFeatureSetType) + } + } + + return r0 +} + +// DeviceLocalInterface_FeatureSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureSet' +type DeviceLocalInterface_FeatureSet_Call struct { + *mock.Call +} + +// FeatureSet is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) FeatureSet() *DeviceLocalInterface_FeatureSet_Call { + return &DeviceLocalInterface_FeatureSet_Call{Call: _e.mock.On("FeatureSet")} +} + +func (_c *DeviceLocalInterface_FeatureSet_Call) Run(run func()) *DeviceLocalInterface_FeatureSet_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_FeatureSet_Call) Return(_a0 *model.NetworkManagementFeatureSetType) *DeviceLocalInterface_FeatureSet_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_FeatureSet_Call) RunAndReturn(run func() *model.NetworkManagementFeatureSetType) *DeviceLocalInterface_FeatureSet_Call { + _c.Call.Return(run) + return _c +} + +// HeartbeatManager provides a mock function with given fields: +func (_m *DeviceLocalInterface) HeartbeatManager() api.HeartbeatManagerInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for HeartbeatManager") + } + + var r0 api.HeartbeatManagerInterface + if rf, ok := ret.Get(0).(func() api.HeartbeatManagerInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.HeartbeatManagerInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_HeartbeatManager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeartbeatManager' +type DeviceLocalInterface_HeartbeatManager_Call struct { + *mock.Call +} + +// HeartbeatManager is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) HeartbeatManager() *DeviceLocalInterface_HeartbeatManager_Call { + return &DeviceLocalInterface_HeartbeatManager_Call{Call: _e.mock.On("HeartbeatManager")} +} + +func (_c *DeviceLocalInterface_HeartbeatManager_Call) Run(run func()) *DeviceLocalInterface_HeartbeatManager_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_HeartbeatManager_Call) Return(_a0 api.HeartbeatManagerInterface) *DeviceLocalInterface_HeartbeatManager_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_HeartbeatManager_Call) RunAndReturn(run func() api.HeartbeatManagerInterface) *DeviceLocalInterface_HeartbeatManager_Call { + _c.Call.Return(run) + return _c +} + +// Information provides a mock function with given fields: +func (_m *DeviceLocalInterface) Information() *model.NodeManagementDetailedDiscoveryDeviceInformationType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Information") + } + + var r0 *model.NodeManagementDetailedDiscoveryDeviceInformationType + if rf, ok := ret.Get(0).(func() *model.NodeManagementDetailedDiscoveryDeviceInformationType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NodeManagementDetailedDiscoveryDeviceInformationType) + } + } + + return r0 +} + +// DeviceLocalInterface_Information_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Information' +type DeviceLocalInterface_Information_Call struct { + *mock.Call +} + +// Information is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) Information() *DeviceLocalInterface_Information_Call { + return &DeviceLocalInterface_Information_Call{Call: _e.mock.On("Information")} +} + +func (_c *DeviceLocalInterface_Information_Call) Run(run func()) *DeviceLocalInterface_Information_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_Information_Call) Return(_a0 *model.NodeManagementDetailedDiscoveryDeviceInformationType) *DeviceLocalInterface_Information_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_Information_Call) RunAndReturn(run func() *model.NodeManagementDetailedDiscoveryDeviceInformationType) *DeviceLocalInterface_Information_Call { + _c.Call.Return(run) + return _c +} + +// NodeManagement provides a mock function with given fields: +func (_m *DeviceLocalInterface) NodeManagement() api.NodeManagementInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NodeManagement") + } + + var r0 api.NodeManagementInterface + if rf, ok := ret.Get(0).(func() api.NodeManagementInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.NodeManagementInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_NodeManagement_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NodeManagement' +type DeviceLocalInterface_NodeManagement_Call struct { + *mock.Call +} + +// NodeManagement is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) NodeManagement() *DeviceLocalInterface_NodeManagement_Call { + return &DeviceLocalInterface_NodeManagement_Call{Call: _e.mock.On("NodeManagement")} +} + +func (_c *DeviceLocalInterface_NodeManagement_Call) Run(run func()) *DeviceLocalInterface_NodeManagement_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_NodeManagement_Call) Return(_a0 api.NodeManagementInterface) *DeviceLocalInterface_NodeManagement_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_NodeManagement_Call) RunAndReturn(run func() api.NodeManagementInterface) *DeviceLocalInterface_NodeManagement_Call { + _c.Call.Return(run) + return _c +} + +// NotifySubscribers provides a mock function with given fields: featureAddress, cmd +func (_m *DeviceLocalInterface) NotifySubscribers(featureAddress *model.FeatureAddressType, cmd model.CmdType) { + _m.Called(featureAddress, cmd) +} + +// DeviceLocalInterface_NotifySubscribers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NotifySubscribers' +type DeviceLocalInterface_NotifySubscribers_Call struct { + *mock.Call +} + +// NotifySubscribers is a helper method to define mock.On call +// - featureAddress *model.FeatureAddressType +// - cmd model.CmdType +func (_e *DeviceLocalInterface_Expecter) NotifySubscribers(featureAddress interface{}, cmd interface{}) *DeviceLocalInterface_NotifySubscribers_Call { + return &DeviceLocalInterface_NotifySubscribers_Call{Call: _e.mock.On("NotifySubscribers", featureAddress, cmd)} +} + +func (_c *DeviceLocalInterface_NotifySubscribers_Call) Run(run func(featureAddress *model.FeatureAddressType, cmd model.CmdType)) *DeviceLocalInterface_NotifySubscribers_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(model.CmdType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_NotifySubscribers_Call) Return() *DeviceLocalInterface_NotifySubscribers_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_NotifySubscribers_Call) RunAndReturn(run func(*model.FeatureAddressType, model.CmdType)) *DeviceLocalInterface_NotifySubscribers_Call { + _c.Call.Return(run) + return _c +} + +// ProcessCmd provides a mock function with given fields: datagram, remoteDevice +func (_m *DeviceLocalInterface) ProcessCmd(datagram model.DatagramType, remoteDevice api.DeviceRemoteInterface) error { + ret := _m.Called(datagram, remoteDevice) + + if len(ret) == 0 { + panic("no return value specified for ProcessCmd") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.DatagramType, api.DeviceRemoteInterface) error); ok { + r0 = rf(datagram, remoteDevice) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeviceLocalInterface_ProcessCmd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessCmd' +type DeviceLocalInterface_ProcessCmd_Call struct { + *mock.Call +} + +// ProcessCmd is a helper method to define mock.On call +// - datagram model.DatagramType +// - remoteDevice api.DeviceRemoteInterface +func (_e *DeviceLocalInterface_Expecter) ProcessCmd(datagram interface{}, remoteDevice interface{}) *DeviceLocalInterface_ProcessCmd_Call { + return &DeviceLocalInterface_ProcessCmd_Call{Call: _e.mock.On("ProcessCmd", datagram, remoteDevice)} +} + +func (_c *DeviceLocalInterface_ProcessCmd_Call) Run(run func(datagram model.DatagramType, remoteDevice api.DeviceRemoteInterface)) *DeviceLocalInterface_ProcessCmd_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DatagramType), args[1].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_ProcessCmd_Call) Return(_a0 error) *DeviceLocalInterface_ProcessCmd_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_ProcessCmd_Call) RunAndReturn(run func(model.DatagramType, api.DeviceRemoteInterface) error) *DeviceLocalInterface_ProcessCmd_Call { + _c.Call.Return(run) + return _c +} + +// RemoteDeviceForAddress provides a mock function with given fields: address +func (_m *DeviceLocalInterface) RemoteDeviceForAddress(address model.AddressDeviceType) api.DeviceRemoteInterface { + ret := _m.Called(address) + + if len(ret) == 0 { + panic("no return value specified for RemoteDeviceForAddress") + } + + var r0 api.DeviceRemoteInterface + if rf, ok := ret.Get(0).(func(model.AddressDeviceType) api.DeviceRemoteInterface); ok { + r0 = rf(address) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceRemoteInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_RemoteDeviceForAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteDeviceForAddress' +type DeviceLocalInterface_RemoteDeviceForAddress_Call struct { + *mock.Call +} + +// RemoteDeviceForAddress is a helper method to define mock.On call +// - address model.AddressDeviceType +func (_e *DeviceLocalInterface_Expecter) RemoteDeviceForAddress(address interface{}) *DeviceLocalInterface_RemoteDeviceForAddress_Call { + return &DeviceLocalInterface_RemoteDeviceForAddress_Call{Call: _e.mock.On("RemoteDeviceForAddress", address)} +} + +func (_c *DeviceLocalInterface_RemoteDeviceForAddress_Call) Run(run func(address model.AddressDeviceType)) *DeviceLocalInterface_RemoteDeviceForAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.AddressDeviceType)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDeviceForAddress_Call) Return(_a0 api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDeviceForAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDeviceForAddress_Call) RunAndReturn(run func(model.AddressDeviceType) api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDeviceForAddress_Call { + _c.Call.Return(run) + return _c +} + +// RemoteDeviceForSki provides a mock function with given fields: ski +func (_m *DeviceLocalInterface) RemoteDeviceForSki(ski string) api.DeviceRemoteInterface { + ret := _m.Called(ski) + + if len(ret) == 0 { + panic("no return value specified for RemoteDeviceForSki") + } + + var r0 api.DeviceRemoteInterface + if rf, ok := ret.Get(0).(func(string) api.DeviceRemoteInterface); ok { + r0 = rf(ski) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceRemoteInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_RemoteDeviceForSki_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteDeviceForSki' +type DeviceLocalInterface_RemoteDeviceForSki_Call struct { + *mock.Call +} + +// RemoteDeviceForSki is a helper method to define mock.On call +// - ski string +func (_e *DeviceLocalInterface_Expecter) RemoteDeviceForSki(ski interface{}) *DeviceLocalInterface_RemoteDeviceForSki_Call { + return &DeviceLocalInterface_RemoteDeviceForSki_Call{Call: _e.mock.On("RemoteDeviceForSki", ski)} +} + +func (_c *DeviceLocalInterface_RemoteDeviceForSki_Call) Run(run func(ski string)) *DeviceLocalInterface_RemoteDeviceForSki_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDeviceForSki_Call) Return(_a0 api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDeviceForSki_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDeviceForSki_Call) RunAndReturn(run func(string) api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDeviceForSki_Call { + _c.Call.Return(run) + return _c +} + +// RemoteDevices provides a mock function with given fields: +func (_m *DeviceLocalInterface) RemoteDevices() []api.DeviceRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for RemoteDevices") + } + + var r0 []api.DeviceRemoteInterface + if rf, ok := ret.Get(0).(func() []api.DeviceRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.DeviceRemoteInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_RemoteDevices_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoteDevices' +type DeviceLocalInterface_RemoteDevices_Call struct { + *mock.Call +} + +// RemoteDevices is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) RemoteDevices() *DeviceLocalInterface_RemoteDevices_Call { + return &DeviceLocalInterface_RemoteDevices_Call{Call: _e.mock.On("RemoteDevices")} +} + +func (_c *DeviceLocalInterface_RemoteDevices_Call) Run(run func()) *DeviceLocalInterface_RemoteDevices_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDevices_Call) Return(_a0 []api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDevices_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_RemoteDevices_Call) RunAndReturn(run func() []api.DeviceRemoteInterface) *DeviceLocalInterface_RemoteDevices_Call { + _c.Call.Return(run) + return _c +} + +// RemoveEntity provides a mock function with given fields: entity +func (_m *DeviceLocalInterface) RemoveEntity(entity api.EntityLocalInterface) { + _m.Called(entity) +} + +// DeviceLocalInterface_RemoveEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveEntity' +type DeviceLocalInterface_RemoveEntity_Call struct { + *mock.Call +} + +// RemoveEntity is a helper method to define mock.On call +// - entity api.EntityLocalInterface +func (_e *DeviceLocalInterface_Expecter) RemoveEntity(entity interface{}) *DeviceLocalInterface_RemoveEntity_Call { + return &DeviceLocalInterface_RemoveEntity_Call{Call: _e.mock.On("RemoveEntity", entity)} +} + +func (_c *DeviceLocalInterface_RemoveEntity_Call) Run(run func(entity api.EntityLocalInterface)) *DeviceLocalInterface_RemoveEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityLocalInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoveEntity_Call) Return() *DeviceLocalInterface_RemoveEntity_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_RemoveEntity_Call) RunAndReturn(run func(api.EntityLocalInterface)) *DeviceLocalInterface_RemoveEntity_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteDevice provides a mock function with given fields: ski +func (_m *DeviceLocalInterface) RemoveRemoteDevice(ski string) { + _m.Called(ski) +} + +// DeviceLocalInterface_RemoveRemoteDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteDevice' +type DeviceLocalInterface_RemoveRemoteDevice_Call struct { + *mock.Call +} + +// RemoveRemoteDevice is a helper method to define mock.On call +// - ski string +func (_e *DeviceLocalInterface_Expecter) RemoveRemoteDevice(ski interface{}) *DeviceLocalInterface_RemoveRemoteDevice_Call { + return &DeviceLocalInterface_RemoveRemoteDevice_Call{Call: _e.mock.On("RemoveRemoteDevice", ski)} +} + +func (_c *DeviceLocalInterface_RemoveRemoteDevice_Call) Run(run func(ski string)) *DeviceLocalInterface_RemoveRemoteDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoveRemoteDevice_Call) Return() *DeviceLocalInterface_RemoveRemoteDevice_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_RemoveRemoteDevice_Call) RunAndReturn(run func(string)) *DeviceLocalInterface_RemoveRemoteDevice_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteDeviceConnection provides a mock function with given fields: ski +func (_m *DeviceLocalInterface) RemoveRemoteDeviceConnection(ski string) { + _m.Called(ski) +} + +// DeviceLocalInterface_RemoveRemoteDeviceConnection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteDeviceConnection' +type DeviceLocalInterface_RemoveRemoteDeviceConnection_Call struct { + *mock.Call +} + +// RemoveRemoteDeviceConnection is a helper method to define mock.On call +// - ski string +func (_e *DeviceLocalInterface_Expecter) RemoveRemoteDeviceConnection(ski interface{}) *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call { + return &DeviceLocalInterface_RemoveRemoteDeviceConnection_Call{Call: _e.mock.On("RemoveRemoteDeviceConnection", ski)} +} + +func (_c *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call) Run(run func(ski string)) *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call) Return() *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call) RunAndReturn(run func(string)) *DeviceLocalInterface_RemoveRemoteDeviceConnection_Call { + _c.Call.Return(run) + return _c +} + +// RequestRemoteDetailedDiscoveryData provides a mock function with given fields: rDevice +func (_m *DeviceLocalInterface) RequestRemoteDetailedDiscoveryData(rDevice api.DeviceRemoteInterface) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(rDevice) + + if len(ret) == 0 { + panic("no return value specified for RequestRemoteDetailedDiscoveryData") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(rDevice) + } + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface) *model.MsgCounterType); ok { + r0 = rf(rDevice) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(api.DeviceRemoteInterface) *model.ErrorType); ok { + r1 = rf(rDevice) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestRemoteDetailedDiscoveryData' +type DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call struct { + *mock.Call +} + +// RequestRemoteDetailedDiscoveryData is a helper method to define mock.On call +// - rDevice api.DeviceRemoteInterface +func (_e *DeviceLocalInterface_Expecter) RequestRemoteDetailedDiscoveryData(rDevice interface{}) *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call { + return &DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call{Call: _e.mock.On("RequestRemoteDetailedDiscoveryData", rDevice)} +} + +func (_c *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call) Run(run func(rDevice api.DeviceRemoteInterface)) *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call) RunAndReturn(run func(api.DeviceRemoteInterface) (*model.MsgCounterType, *model.ErrorType)) *DeviceLocalInterface_RequestRemoteDetailedDiscoveryData_Call { + _c.Call.Return(run) + return _c +} + +// SetupRemoteDevice provides a mock function with given fields: ski, writeI +func (_m *DeviceLocalInterface) SetupRemoteDevice(ski string, writeI ship_goapi.ShipConnectionDataWriterInterface) ship_goapi.ShipConnectionDataReaderInterface { + ret := _m.Called(ski, writeI) + + if len(ret) == 0 { + panic("no return value specified for SetupRemoteDevice") + } + + var r0 ship_goapi.ShipConnectionDataReaderInterface + if rf, ok := ret.Get(0).(func(string, ship_goapi.ShipConnectionDataWriterInterface) ship_goapi.ShipConnectionDataReaderInterface); ok { + r0 = rf(ski, writeI) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(ship_goapi.ShipConnectionDataReaderInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_SetupRemoteDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetupRemoteDevice' +type DeviceLocalInterface_SetupRemoteDevice_Call struct { + *mock.Call +} + +// SetupRemoteDevice is a helper method to define mock.On call +// - ski string +// - writeI ship_goapi.ShipConnectionDataWriterInterface +func (_e *DeviceLocalInterface_Expecter) SetupRemoteDevice(ski interface{}, writeI interface{}) *DeviceLocalInterface_SetupRemoteDevice_Call { + return &DeviceLocalInterface_SetupRemoteDevice_Call{Call: _e.mock.On("SetupRemoteDevice", ski, writeI)} +} + +func (_c *DeviceLocalInterface_SetupRemoteDevice_Call) Run(run func(ski string, writeI ship_goapi.ShipConnectionDataWriterInterface)) *DeviceLocalInterface_SetupRemoteDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(ship_goapi.ShipConnectionDataWriterInterface)) + }) + return _c +} + +func (_c *DeviceLocalInterface_SetupRemoteDevice_Call) Return(_a0 ship_goapi.ShipConnectionDataReaderInterface) *DeviceLocalInterface_SetupRemoteDevice_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_SetupRemoteDevice_Call) RunAndReturn(run func(string, ship_goapi.ShipConnectionDataWriterInterface) ship_goapi.ShipConnectionDataReaderInterface) *DeviceLocalInterface_SetupRemoteDevice_Call { + _c.Call.Return(run) + return _c +} + +// SubscriptionManager provides a mock function with given fields: +func (_m *DeviceLocalInterface) SubscriptionManager() api.SubscriptionManagerInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SubscriptionManager") + } + + var r0 api.SubscriptionManagerInterface + if rf, ok := ret.Get(0).(func() api.SubscriptionManagerInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.SubscriptionManagerInterface) + } + } + + return r0 +} + +// DeviceLocalInterface_SubscriptionManager_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscriptionManager' +type DeviceLocalInterface_SubscriptionManager_Call struct { + *mock.Call +} + +// SubscriptionManager is a helper method to define mock.On call +func (_e *DeviceLocalInterface_Expecter) SubscriptionManager() *DeviceLocalInterface_SubscriptionManager_Call { + return &DeviceLocalInterface_SubscriptionManager_Call{Call: _e.mock.On("SubscriptionManager")} +} + +func (_c *DeviceLocalInterface_SubscriptionManager_Call) Run(run func()) *DeviceLocalInterface_SubscriptionManager_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceLocalInterface_SubscriptionManager_Call) Return(_a0 api.SubscriptionManagerInterface) *DeviceLocalInterface_SubscriptionManager_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceLocalInterface_SubscriptionManager_Call) RunAndReturn(run func() api.SubscriptionManagerInterface) *DeviceLocalInterface_SubscriptionManager_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceLocalInterface creates a new instance of DeviceLocalInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceLocalInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceLocalInterface { + mock := &DeviceLocalInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/DeviceRemoteInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/DeviceRemoteInterface.go new file mode 100644 index 0000000..8ea1675 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/DeviceRemoteInterface.go @@ -0,0 +1,833 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// DeviceRemoteInterface is an autogenerated mock type for the DeviceRemoteInterface type +type DeviceRemoteInterface struct { + mock.Mock +} + +type DeviceRemoteInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *DeviceRemoteInterface) EXPECT() *DeviceRemoteInterface_Expecter { + return &DeviceRemoteInterface_Expecter{mock: &_m.Mock} +} + +// AddEntity provides a mock function with given fields: entity +func (_m *DeviceRemoteInterface) AddEntity(entity api.EntityRemoteInterface) { + _m.Called(entity) +} + +// DeviceRemoteInterface_AddEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddEntity' +type DeviceRemoteInterface_AddEntity_Call struct { + *mock.Call +} + +// AddEntity is a helper method to define mock.On call +// - entity api.EntityRemoteInterface +func (_e *DeviceRemoteInterface_Expecter) AddEntity(entity interface{}) *DeviceRemoteInterface_AddEntity_Call { + return &DeviceRemoteInterface_AddEntity_Call{Call: _e.mock.On("AddEntity", entity)} +} + +func (_c *DeviceRemoteInterface_AddEntity_Call) Run(run func(entity api.EntityRemoteInterface)) *DeviceRemoteInterface_AddEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityRemoteInterface)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_AddEntity_Call) Return() *DeviceRemoteInterface_AddEntity_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceRemoteInterface_AddEntity_Call) RunAndReturn(run func(api.EntityRemoteInterface)) *DeviceRemoteInterface_AddEntity_Call { + _c.Call.Return(run) + return _c +} + +// AddEntityAndFeatures provides a mock function with given fields: initialData, data +func (_m *DeviceRemoteInterface) AddEntityAndFeatures(initialData bool, data *model.NodeManagementDetailedDiscoveryDataType) ([]api.EntityRemoteInterface, error) { + ret := _m.Called(initialData, data) + + if len(ret) == 0 { + panic("no return value specified for AddEntityAndFeatures") + } + + var r0 []api.EntityRemoteInterface + var r1 error + if rf, ok := ret.Get(0).(func(bool, *model.NodeManagementDetailedDiscoveryDataType) ([]api.EntityRemoteInterface, error)); ok { + return rf(initialData, data) + } + if rf, ok := ret.Get(0).(func(bool, *model.NodeManagementDetailedDiscoveryDataType) []api.EntityRemoteInterface); ok { + r0 = rf(initialData, data) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.EntityRemoteInterface) + } + } + + if rf, ok := ret.Get(1).(func(bool, *model.NodeManagementDetailedDiscoveryDataType) error); ok { + r1 = rf(initialData, data) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceRemoteInterface_AddEntityAndFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddEntityAndFeatures' +type DeviceRemoteInterface_AddEntityAndFeatures_Call struct { + *mock.Call +} + +// AddEntityAndFeatures is a helper method to define mock.On call +// - initialData bool +// - data *model.NodeManagementDetailedDiscoveryDataType +func (_e *DeviceRemoteInterface_Expecter) AddEntityAndFeatures(initialData interface{}, data interface{}) *DeviceRemoteInterface_AddEntityAndFeatures_Call { + return &DeviceRemoteInterface_AddEntityAndFeatures_Call{Call: _e.mock.On("AddEntityAndFeatures", initialData, data)} +} + +func (_c *DeviceRemoteInterface_AddEntityAndFeatures_Call) Run(run func(initialData bool, data *model.NodeManagementDetailedDiscoveryDataType)) *DeviceRemoteInterface_AddEntityAndFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool), args[1].(*model.NodeManagementDetailedDiscoveryDataType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_AddEntityAndFeatures_Call) Return(_a0 []api.EntityRemoteInterface, _a1 error) *DeviceRemoteInterface_AddEntityAndFeatures_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceRemoteInterface_AddEntityAndFeatures_Call) RunAndReturn(run func(bool, *model.NodeManagementDetailedDiscoveryDataType) ([]api.EntityRemoteInterface, error)) *DeviceRemoteInterface_AddEntityAndFeatures_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *DeviceRemoteInterface) Address() *model.AddressDeviceType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.AddressDeviceType + if rf, ok := ret.Get(0).(func() *model.AddressDeviceType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.AddressDeviceType) + } + } + + return r0 +} + +// DeviceRemoteInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type DeviceRemoteInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) Address() *DeviceRemoteInterface_Address_Call { + return &DeviceRemoteInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *DeviceRemoteInterface_Address_Call) Run(run func()) *DeviceRemoteInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_Address_Call) Return(_a0 *model.AddressDeviceType) *DeviceRemoteInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_Address_Call) RunAndReturn(run func() *model.AddressDeviceType) *DeviceRemoteInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// CheckEntityInformation provides a mock function with given fields: initialData, entity +func (_m *DeviceRemoteInterface) CheckEntityInformation(initialData bool, entity model.NodeManagementDetailedDiscoveryEntityInformationType) error { + ret := _m.Called(initialData, entity) + + if len(ret) == 0 { + panic("no return value specified for CheckEntityInformation") + } + + var r0 error + if rf, ok := ret.Get(0).(func(bool, model.NodeManagementDetailedDiscoveryEntityInformationType) error); ok { + r0 = rf(initialData, entity) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeviceRemoteInterface_CheckEntityInformation_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckEntityInformation' +type DeviceRemoteInterface_CheckEntityInformation_Call struct { + *mock.Call +} + +// CheckEntityInformation is a helper method to define mock.On call +// - initialData bool +// - entity model.NodeManagementDetailedDiscoveryEntityInformationType +func (_e *DeviceRemoteInterface_Expecter) CheckEntityInformation(initialData interface{}, entity interface{}) *DeviceRemoteInterface_CheckEntityInformation_Call { + return &DeviceRemoteInterface_CheckEntityInformation_Call{Call: _e.mock.On("CheckEntityInformation", initialData, entity)} +} + +func (_c *DeviceRemoteInterface_CheckEntityInformation_Call) Run(run func(initialData bool, entity model.NodeManagementDetailedDiscoveryEntityInformationType)) *DeviceRemoteInterface_CheckEntityInformation_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool), args[1].(model.NodeManagementDetailedDiscoveryEntityInformationType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_CheckEntityInformation_Call) Return(_a0 error) *DeviceRemoteInterface_CheckEntityInformation_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_CheckEntityInformation_Call) RunAndReturn(run func(bool, model.NodeManagementDetailedDiscoveryEntityInformationType) error) *DeviceRemoteInterface_CheckEntityInformation_Call { + _c.Call.Return(run) + return _c +} + +// DestinationData provides a mock function with given fields: +func (_m *DeviceRemoteInterface) DestinationData() model.NodeManagementDestinationDataType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DestinationData") + } + + var r0 model.NodeManagementDestinationDataType + if rf, ok := ret.Get(0).(func() model.NodeManagementDestinationDataType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.NodeManagementDestinationDataType) + } + + return r0 +} + +// DeviceRemoteInterface_DestinationData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestinationData' +type DeviceRemoteInterface_DestinationData_Call struct { + *mock.Call +} + +// DestinationData is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) DestinationData() *DeviceRemoteInterface_DestinationData_Call { + return &DeviceRemoteInterface_DestinationData_Call{Call: _e.mock.On("DestinationData")} +} + +func (_c *DeviceRemoteInterface_DestinationData_Call) Run(run func()) *DeviceRemoteInterface_DestinationData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_DestinationData_Call) Return(_a0 model.NodeManagementDestinationDataType) *DeviceRemoteInterface_DestinationData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_DestinationData_Call) RunAndReturn(run func() model.NodeManagementDestinationDataType) *DeviceRemoteInterface_DestinationData_Call { + _c.Call.Return(run) + return _c +} + +// DeviceType provides a mock function with given fields: +func (_m *DeviceRemoteInterface) DeviceType() *model.DeviceTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DeviceType") + } + + var r0 *model.DeviceTypeType + if rf, ok := ret.Get(0).(func() *model.DeviceTypeType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DeviceTypeType) + } + } + + return r0 +} + +// DeviceRemoteInterface_DeviceType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeviceType' +type DeviceRemoteInterface_DeviceType_Call struct { + *mock.Call +} + +// DeviceType is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) DeviceType() *DeviceRemoteInterface_DeviceType_Call { + return &DeviceRemoteInterface_DeviceType_Call{Call: _e.mock.On("DeviceType")} +} + +func (_c *DeviceRemoteInterface_DeviceType_Call) Run(run func()) *DeviceRemoteInterface_DeviceType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_DeviceType_Call) Return(_a0 *model.DeviceTypeType) *DeviceRemoteInterface_DeviceType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_DeviceType_Call) RunAndReturn(run func() *model.DeviceTypeType) *DeviceRemoteInterface_DeviceType_Call { + _c.Call.Return(run) + return _c +} + +// Entities provides a mock function with given fields: +func (_m *DeviceRemoteInterface) Entities() []api.EntityRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Entities") + } + + var r0 []api.EntityRemoteInterface + if rf, ok := ret.Get(0).(func() []api.EntityRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.EntityRemoteInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_Entities_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entities' +type DeviceRemoteInterface_Entities_Call struct { + *mock.Call +} + +// Entities is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) Entities() *DeviceRemoteInterface_Entities_Call { + return &DeviceRemoteInterface_Entities_Call{Call: _e.mock.On("Entities")} +} + +func (_c *DeviceRemoteInterface_Entities_Call) Run(run func()) *DeviceRemoteInterface_Entities_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_Entities_Call) Return(_a0 []api.EntityRemoteInterface) *DeviceRemoteInterface_Entities_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_Entities_Call) RunAndReturn(run func() []api.EntityRemoteInterface) *DeviceRemoteInterface_Entities_Call { + _c.Call.Return(run) + return _c +} + +// Entity provides a mock function with given fields: id +func (_m *DeviceRemoteInterface) Entity(id []model.AddressEntityType) api.EntityRemoteInterface { + ret := _m.Called(id) + + if len(ret) == 0 { + panic("no return value specified for Entity") + } + + var r0 api.EntityRemoteInterface + if rf, ok := ret.Get(0).(func([]model.AddressEntityType) api.EntityRemoteInterface); ok { + r0 = rf(id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityRemoteInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_Entity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entity' +type DeviceRemoteInterface_Entity_Call struct { + *mock.Call +} + +// Entity is a helper method to define mock.On call +// - id []model.AddressEntityType +func (_e *DeviceRemoteInterface_Expecter) Entity(id interface{}) *DeviceRemoteInterface_Entity_Call { + return &DeviceRemoteInterface_Entity_Call{Call: _e.mock.On("Entity", id)} +} + +func (_c *DeviceRemoteInterface_Entity_Call) Run(run func(id []model.AddressEntityType)) *DeviceRemoteInterface_Entity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.AddressEntityType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_Entity_Call) Return(_a0 api.EntityRemoteInterface) *DeviceRemoteInterface_Entity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_Entity_Call) RunAndReturn(run func([]model.AddressEntityType) api.EntityRemoteInterface) *DeviceRemoteInterface_Entity_Call { + _c.Call.Return(run) + return _c +} + +// FeatureByAddress provides a mock function with given fields: address +func (_m *DeviceRemoteInterface) FeatureByAddress(address *model.FeatureAddressType) api.FeatureRemoteInterface { + ret := _m.Called(address) + + if len(ret) == 0 { + panic("no return value specified for FeatureByAddress") + } + + var r0 api.FeatureRemoteInterface + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) api.FeatureRemoteInterface); ok { + r0 = rf(address) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureRemoteInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_FeatureByAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureByAddress' +type DeviceRemoteInterface_FeatureByAddress_Call struct { + *mock.Call +} + +// FeatureByAddress is a helper method to define mock.On call +// - address *model.FeatureAddressType +func (_e *DeviceRemoteInterface_Expecter) FeatureByAddress(address interface{}) *DeviceRemoteInterface_FeatureByAddress_Call { + return &DeviceRemoteInterface_FeatureByAddress_Call{Call: _e.mock.On("FeatureByAddress", address)} +} + +func (_c *DeviceRemoteInterface_FeatureByAddress_Call) Run(run func(address *model.FeatureAddressType)) *DeviceRemoteInterface_FeatureByAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureByAddress_Call) Return(_a0 api.FeatureRemoteInterface) *DeviceRemoteInterface_FeatureByAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureByAddress_Call) RunAndReturn(run func(*model.FeatureAddressType) api.FeatureRemoteInterface) *DeviceRemoteInterface_FeatureByAddress_Call { + _c.Call.Return(run) + return _c +} + +// FeatureByEntityTypeAndRole provides a mock function with given fields: entity, featureType, role +func (_m *DeviceRemoteInterface) FeatureByEntityTypeAndRole(entity api.EntityRemoteInterface, featureType model.FeatureTypeType, role model.RoleType) api.FeatureRemoteInterface { + ret := _m.Called(entity, featureType, role) + + if len(ret) == 0 { + panic("no return value specified for FeatureByEntityTypeAndRole") + } + + var r0 api.FeatureRemoteInterface + if rf, ok := ret.Get(0).(func(api.EntityRemoteInterface, model.FeatureTypeType, model.RoleType) api.FeatureRemoteInterface); ok { + r0 = rf(entity, featureType, role) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureRemoteInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureByEntityTypeAndRole' +type DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call struct { + *mock.Call +} + +// FeatureByEntityTypeAndRole is a helper method to define mock.On call +// - entity api.EntityRemoteInterface +// - featureType model.FeatureTypeType +// - role model.RoleType +func (_e *DeviceRemoteInterface_Expecter) FeatureByEntityTypeAndRole(entity interface{}, featureType interface{}, role interface{}) *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call { + return &DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call{Call: _e.mock.On("FeatureByEntityTypeAndRole", entity, featureType, role)} +} + +func (_c *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call) Run(run func(entity api.EntityRemoteInterface, featureType model.FeatureTypeType, role model.RoleType)) *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityRemoteInterface), args[1].(model.FeatureTypeType), args[2].(model.RoleType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call) Return(_a0 api.FeatureRemoteInterface) *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call) RunAndReturn(run func(api.EntityRemoteInterface, model.FeatureTypeType, model.RoleType) api.FeatureRemoteInterface) *DeviceRemoteInterface_FeatureByEntityTypeAndRole_Call { + _c.Call.Return(run) + return _c +} + +// FeatureSet provides a mock function with given fields: +func (_m *DeviceRemoteInterface) FeatureSet() *model.NetworkManagementFeatureSetType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FeatureSet") + } + + var r0 *model.NetworkManagementFeatureSetType + if rf, ok := ret.Get(0).(func() *model.NetworkManagementFeatureSetType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NetworkManagementFeatureSetType) + } + } + + return r0 +} + +// DeviceRemoteInterface_FeatureSet_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureSet' +type DeviceRemoteInterface_FeatureSet_Call struct { + *mock.Call +} + +// FeatureSet is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) FeatureSet() *DeviceRemoteInterface_FeatureSet_Call { + return &DeviceRemoteInterface_FeatureSet_Call{Call: _e.mock.On("FeatureSet")} +} + +func (_c *DeviceRemoteInterface_FeatureSet_Call) Run(run func()) *DeviceRemoteInterface_FeatureSet_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureSet_Call) Return(_a0 *model.NetworkManagementFeatureSetType) *DeviceRemoteInterface_FeatureSet_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_FeatureSet_Call) RunAndReturn(run func() *model.NetworkManagementFeatureSetType) *DeviceRemoteInterface_FeatureSet_Call { + _c.Call.Return(run) + return _c +} + +// HandleSpineMesssage provides a mock function with given fields: message +func (_m *DeviceRemoteInterface) HandleSpineMesssage(message []byte) (*model.MsgCounterType, error) { + ret := _m.Called(message) + + if len(ret) == 0 { + panic("no return value specified for HandleSpineMesssage") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func([]byte) (*model.MsgCounterType, error)); ok { + return rf(message) + } + if rf, ok := ret.Get(0).(func([]byte) *model.MsgCounterType); ok { + r0 = rf(message) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func([]byte) error); ok { + r1 = rf(message) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeviceRemoteInterface_HandleSpineMesssage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleSpineMesssage' +type DeviceRemoteInterface_HandleSpineMesssage_Call struct { + *mock.Call +} + +// HandleSpineMesssage is a helper method to define mock.On call +// - message []byte +func (_e *DeviceRemoteInterface_Expecter) HandleSpineMesssage(message interface{}) *DeviceRemoteInterface_HandleSpineMesssage_Call { + return &DeviceRemoteInterface_HandleSpineMesssage_Call{Call: _e.mock.On("HandleSpineMesssage", message)} +} + +func (_c *DeviceRemoteInterface_HandleSpineMesssage_Call) Run(run func(message []byte)) *DeviceRemoteInterface_HandleSpineMesssage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]byte)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_HandleSpineMesssage_Call) Return(_a0 *model.MsgCounterType, _a1 error) *DeviceRemoteInterface_HandleSpineMesssage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *DeviceRemoteInterface_HandleSpineMesssage_Call) RunAndReturn(run func([]byte) (*model.MsgCounterType, error)) *DeviceRemoteInterface_HandleSpineMesssage_Call { + _c.Call.Return(run) + return _c +} + +// RemoveEntityByAddress provides a mock function with given fields: addr +func (_m *DeviceRemoteInterface) RemoveEntityByAddress(addr []model.AddressEntityType) api.EntityRemoteInterface { + ret := _m.Called(addr) + + if len(ret) == 0 { + panic("no return value specified for RemoveEntityByAddress") + } + + var r0 api.EntityRemoteInterface + if rf, ok := ret.Get(0).(func([]model.AddressEntityType) api.EntityRemoteInterface); ok { + r0 = rf(addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityRemoteInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_RemoveEntityByAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveEntityByAddress' +type DeviceRemoteInterface_RemoveEntityByAddress_Call struct { + *mock.Call +} + +// RemoveEntityByAddress is a helper method to define mock.On call +// - addr []model.AddressEntityType +func (_e *DeviceRemoteInterface_Expecter) RemoveEntityByAddress(addr interface{}) *DeviceRemoteInterface_RemoveEntityByAddress_Call { + return &DeviceRemoteInterface_RemoveEntityByAddress_Call{Call: _e.mock.On("RemoveEntityByAddress", addr)} +} + +func (_c *DeviceRemoteInterface_RemoveEntityByAddress_Call) Run(run func(addr []model.AddressEntityType)) *DeviceRemoteInterface_RemoveEntityByAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.AddressEntityType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_RemoveEntityByAddress_Call) Return(_a0 api.EntityRemoteInterface) *DeviceRemoteInterface_RemoveEntityByAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_RemoveEntityByAddress_Call) RunAndReturn(run func([]model.AddressEntityType) api.EntityRemoteInterface) *DeviceRemoteInterface_RemoveEntityByAddress_Call { + _c.Call.Return(run) + return _c +} + +// Sender provides a mock function with given fields: +func (_m *DeviceRemoteInterface) Sender() api.SenderInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Sender") + } + + var r0 api.SenderInterface + if rf, ok := ret.Get(0).(func() api.SenderInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.SenderInterface) + } + } + + return r0 +} + +// DeviceRemoteInterface_Sender_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sender' +type DeviceRemoteInterface_Sender_Call struct { + *mock.Call +} + +// Sender is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) Sender() *DeviceRemoteInterface_Sender_Call { + return &DeviceRemoteInterface_Sender_Call{Call: _e.mock.On("Sender")} +} + +func (_c *DeviceRemoteInterface_Sender_Call) Run(run func()) *DeviceRemoteInterface_Sender_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_Sender_Call) Return(_a0 api.SenderInterface) *DeviceRemoteInterface_Sender_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_Sender_Call) RunAndReturn(run func() api.SenderInterface) *DeviceRemoteInterface_Sender_Call { + _c.Call.Return(run) + return _c +} + +// Ski provides a mock function with given fields: +func (_m *DeviceRemoteInterface) Ski() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Ski") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// DeviceRemoteInterface_Ski_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ski' +type DeviceRemoteInterface_Ski_Call struct { + *mock.Call +} + +// Ski is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) Ski() *DeviceRemoteInterface_Ski_Call { + return &DeviceRemoteInterface_Ski_Call{Call: _e.mock.On("Ski")} +} + +func (_c *DeviceRemoteInterface_Ski_Call) Run(run func()) *DeviceRemoteInterface_Ski_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_Ski_Call) Return(_a0 string) *DeviceRemoteInterface_Ski_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_Ski_Call) RunAndReturn(run func() string) *DeviceRemoteInterface_Ski_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDevice provides a mock function with given fields: description +func (_m *DeviceRemoteInterface) UpdateDevice(description *model.NetworkManagementDeviceDescriptionDataType) { + _m.Called(description) +} + +// DeviceRemoteInterface_UpdateDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDevice' +type DeviceRemoteInterface_UpdateDevice_Call struct { + *mock.Call +} + +// UpdateDevice is a helper method to define mock.On call +// - description *model.NetworkManagementDeviceDescriptionDataType +func (_e *DeviceRemoteInterface_Expecter) UpdateDevice(description interface{}) *DeviceRemoteInterface_UpdateDevice_Call { + return &DeviceRemoteInterface_UpdateDevice_Call{Call: _e.mock.On("UpdateDevice", description)} +} + +func (_c *DeviceRemoteInterface_UpdateDevice_Call) Run(run func(description *model.NetworkManagementDeviceDescriptionDataType)) *DeviceRemoteInterface_UpdateDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.NetworkManagementDeviceDescriptionDataType)) + }) + return _c +} + +func (_c *DeviceRemoteInterface_UpdateDevice_Call) Return() *DeviceRemoteInterface_UpdateDevice_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceRemoteInterface_UpdateDevice_Call) RunAndReturn(run func(*model.NetworkManagementDeviceDescriptionDataType)) *DeviceRemoteInterface_UpdateDevice_Call { + _c.Call.Return(run) + return _c +} + +// UseCases provides a mock function with given fields: +func (_m *DeviceRemoteInterface) UseCases() []model.UseCaseInformationDataType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for UseCases") + } + + var r0 []model.UseCaseInformationDataType + if rf, ok := ret.Get(0).(func() []model.UseCaseInformationDataType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.UseCaseInformationDataType) + } + } + + return r0 +} + +// DeviceRemoteInterface_UseCases_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UseCases' +type DeviceRemoteInterface_UseCases_Call struct { + *mock.Call +} + +// UseCases is a helper method to define mock.On call +func (_e *DeviceRemoteInterface_Expecter) UseCases() *DeviceRemoteInterface_UseCases_Call { + return &DeviceRemoteInterface_UseCases_Call{Call: _e.mock.On("UseCases")} +} + +func (_c *DeviceRemoteInterface_UseCases_Call) Run(run func()) *DeviceRemoteInterface_UseCases_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *DeviceRemoteInterface_UseCases_Call) Return(_a0 []model.UseCaseInformationDataType) *DeviceRemoteInterface_UseCases_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *DeviceRemoteInterface_UseCases_Call) RunAndReturn(run func() []model.UseCaseInformationDataType) *DeviceRemoteInterface_UseCases_Call { + _c.Call.Return(run) + return _c +} + +// NewDeviceRemoteInterface creates a new instance of DeviceRemoteInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDeviceRemoteInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *DeviceRemoteInterface { + mock := &DeviceRemoteInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/EntityInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/EntityInterface.go new file mode 100644 index 0000000..f688479 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/EntityInterface.go @@ -0,0 +1,252 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// EntityInterface is an autogenerated mock type for the EntityInterface type +type EntityInterface struct { + mock.Mock +} + +type EntityInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EntityInterface) EXPECT() *EntityInterface_Expecter { + return &EntityInterface_Expecter{mock: &_m.Mock} +} + +// Address provides a mock function with given fields: +func (_m *EntityInterface) Address() *model.EntityAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.EntityAddressType + if rf, ok := ret.Get(0).(func() *model.EntityAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.EntityAddressType) + } + } + + return r0 +} + +// EntityInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type EntityInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *EntityInterface_Expecter) Address() *EntityInterface_Address_Call { + return &EntityInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *EntityInterface_Address_Call) Run(run func()) *EntityInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityInterface_Address_Call) Return(_a0 *model.EntityAddressType) *EntityInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityInterface_Address_Call) RunAndReturn(run func() *model.EntityAddressType) *EntityInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *EntityInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// EntityInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type EntityInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *EntityInterface_Expecter) Description() *EntityInterface_Description_Call { + return &EntityInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *EntityInterface_Description_Call) Run(run func()) *EntityInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityInterface_Description_Call) Return(_a0 *model.DescriptionType) *EntityInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *EntityInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// EntityType provides a mock function with given fields: +func (_m *EntityInterface) EntityType() model.EntityTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EntityType") + } + + var r0 model.EntityTypeType + if rf, ok := ret.Get(0).(func() model.EntityTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.EntityTypeType) + } + + return r0 +} + +// EntityInterface_EntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EntityType' +type EntityInterface_EntityType_Call struct { + *mock.Call +} + +// EntityType is a helper method to define mock.On call +func (_e *EntityInterface_Expecter) EntityType() *EntityInterface_EntityType_Call { + return &EntityInterface_EntityType_Call{Call: _e.mock.On("EntityType")} +} + +func (_c *EntityInterface_EntityType_Call) Run(run func()) *EntityInterface_EntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityInterface_EntityType_Call) Return(_a0 model.EntityTypeType) *EntityInterface_EntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityInterface_EntityType_Call) RunAndReturn(run func() model.EntityTypeType) *EntityInterface_EntityType_Call { + _c.Call.Return(run) + return _c +} + +// NextFeatureId provides a mock function with given fields: +func (_m *EntityInterface) NextFeatureId() uint { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NextFeatureId") + } + + var r0 uint + if rf, ok := ret.Get(0).(func() uint); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// EntityInterface_NextFeatureId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextFeatureId' +type EntityInterface_NextFeatureId_Call struct { + *mock.Call +} + +// NextFeatureId is a helper method to define mock.On call +func (_e *EntityInterface_Expecter) NextFeatureId() *EntityInterface_NextFeatureId_Call { + return &EntityInterface_NextFeatureId_Call{Call: _e.mock.On("NextFeatureId")} +} + +func (_c *EntityInterface_NextFeatureId_Call) Run(run func()) *EntityInterface_NextFeatureId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityInterface_NextFeatureId_Call) Return(_a0 uint) *EntityInterface_NextFeatureId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityInterface_NextFeatureId_Call) RunAndReturn(run func() uint) *EntityInterface_NextFeatureId_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: d +func (_m *EntityInterface) SetDescription(d *model.DescriptionType) { + _m.Called(d) +} + +// EntityInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type EntityInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - d *model.DescriptionType +func (_e *EntityInterface_Expecter) SetDescription(d interface{}) *EntityInterface_SetDescription_Call { + return &EntityInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", d)} +} + +func (_c *EntityInterface_SetDescription_Call) Run(run func(d *model.DescriptionType)) *EntityInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *EntityInterface_SetDescription_Call) Return() *EntityInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *EntityInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// NewEntityInterface creates a new instance of EntityInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEntityInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EntityInterface { + mock := &EntityInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/EntityLocalInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/EntityLocalInterface.go new file mode 100644 index 0000000..bb29275 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/EntityLocalInterface.go @@ -0,0 +1,824 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// EntityLocalInterface is an autogenerated mock type for the EntityLocalInterface type +type EntityLocalInterface struct { + mock.Mock +} + +type EntityLocalInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EntityLocalInterface) EXPECT() *EntityLocalInterface_Expecter { + return &EntityLocalInterface_Expecter{mock: &_m.Mock} +} + +// AddFeature provides a mock function with given fields: f +func (_m *EntityLocalInterface) AddFeature(f api.FeatureLocalInterface) { + _m.Called(f) +} + +// EntityLocalInterface_AddFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeature' +type EntityLocalInterface_AddFeature_Call struct { + *mock.Call +} + +// AddFeature is a helper method to define mock.On call +// - f api.FeatureLocalInterface +func (_e *EntityLocalInterface_Expecter) AddFeature(f interface{}) *EntityLocalInterface_AddFeature_Call { + return &EntityLocalInterface_AddFeature_Call{Call: _e.mock.On("AddFeature", f)} +} + +func (_c *EntityLocalInterface_AddFeature_Call) Run(run func(f api.FeatureLocalInterface)) *EntityLocalInterface_AddFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.FeatureLocalInterface)) + }) + return _c +} + +func (_c *EntityLocalInterface_AddFeature_Call) Return() *EntityLocalInterface_AddFeature_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_AddFeature_Call) RunAndReturn(run func(api.FeatureLocalInterface)) *EntityLocalInterface_AddFeature_Call { + _c.Call.Return(run) + return _c +} + +// AddUseCaseSupport provides a mock function with given fields: actor, useCaseName, useCaseVersion, useCaseDocumemtSubRevision, useCaseAvailable, scenarios +func (_m *EntityLocalInterface) AddUseCaseSupport(actor model.UseCaseActorType, useCaseName model.UseCaseNameType, useCaseVersion model.SpecificationVersionType, useCaseDocumemtSubRevision string, useCaseAvailable bool, scenarios []model.UseCaseScenarioSupportType) { + _m.Called(actor, useCaseName, useCaseVersion, useCaseDocumemtSubRevision, useCaseAvailable, scenarios) +} + +// EntityLocalInterface_AddUseCaseSupport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCaseSupport' +type EntityLocalInterface_AddUseCaseSupport_Call struct { + *mock.Call +} + +// AddUseCaseSupport is a helper method to define mock.On call +// - actor model.UseCaseActorType +// - useCaseName model.UseCaseNameType +// - useCaseVersion model.SpecificationVersionType +// - useCaseDocumemtSubRevision string +// - useCaseAvailable bool +// - scenarios []model.UseCaseScenarioSupportType +func (_e *EntityLocalInterface_Expecter) AddUseCaseSupport(actor interface{}, useCaseName interface{}, useCaseVersion interface{}, useCaseDocumemtSubRevision interface{}, useCaseAvailable interface{}, scenarios interface{}) *EntityLocalInterface_AddUseCaseSupport_Call { + return &EntityLocalInterface_AddUseCaseSupport_Call{Call: _e.mock.On("AddUseCaseSupport", actor, useCaseName, useCaseVersion, useCaseDocumemtSubRevision, useCaseAvailable, scenarios)} +} + +func (_c *EntityLocalInterface_AddUseCaseSupport_Call) Run(run func(actor model.UseCaseActorType, useCaseName model.UseCaseNameType, useCaseVersion model.SpecificationVersionType, useCaseDocumemtSubRevision string, useCaseAvailable bool, scenarios []model.UseCaseScenarioSupportType)) *EntityLocalInterface_AddUseCaseSupport_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.UseCaseActorType), args[1].(model.UseCaseNameType), args[2].(model.SpecificationVersionType), args[3].(string), args[4].(bool), args[5].([]model.UseCaseScenarioSupportType)) + }) + return _c +} + +func (_c *EntityLocalInterface_AddUseCaseSupport_Call) Return() *EntityLocalInterface_AddUseCaseSupport_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_AddUseCaseSupport_Call) RunAndReturn(run func(model.UseCaseActorType, model.UseCaseNameType, model.SpecificationVersionType, string, bool, []model.UseCaseScenarioSupportType)) *EntityLocalInterface_AddUseCaseSupport_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *EntityLocalInterface) Address() *model.EntityAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.EntityAddressType + if rf, ok := ret.Get(0).(func() *model.EntityAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.EntityAddressType) + } + } + + return r0 +} + +// EntityLocalInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type EntityLocalInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) Address() *EntityLocalInterface_Address_Call { + return &EntityLocalInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *EntityLocalInterface_Address_Call) Run(run func()) *EntityLocalInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_Address_Call) Return(_a0 *model.EntityAddressType) *EntityLocalInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_Address_Call) RunAndReturn(run func() *model.EntityAddressType) *EntityLocalInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *EntityLocalInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// EntityLocalInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type EntityLocalInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) Description() *EntityLocalInterface_Description_Call { + return &EntityLocalInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *EntityLocalInterface_Description_Call) Run(run func()) *EntityLocalInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_Description_Call) Return(_a0 *model.DescriptionType) *EntityLocalInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *EntityLocalInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Device provides a mock function with given fields: +func (_m *EntityLocalInterface) Device() api.DeviceLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Device") + } + + var r0 api.DeviceLocalInterface + if rf, ok := ret.Get(0).(func() api.DeviceLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceLocalInterface) + } + } + + return r0 +} + +// EntityLocalInterface_Device_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Device' +type EntityLocalInterface_Device_Call struct { + *mock.Call +} + +// Device is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) Device() *EntityLocalInterface_Device_Call { + return &EntityLocalInterface_Device_Call{Call: _e.mock.On("Device")} +} + +func (_c *EntityLocalInterface_Device_Call) Run(run func()) *EntityLocalInterface_Device_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_Device_Call) Return(_a0 api.DeviceLocalInterface) *EntityLocalInterface_Device_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_Device_Call) RunAndReturn(run func() api.DeviceLocalInterface) *EntityLocalInterface_Device_Call { + _c.Call.Return(run) + return _c +} + +// EntityType provides a mock function with given fields: +func (_m *EntityLocalInterface) EntityType() model.EntityTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EntityType") + } + + var r0 model.EntityTypeType + if rf, ok := ret.Get(0).(func() model.EntityTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.EntityTypeType) + } + + return r0 +} + +// EntityLocalInterface_EntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EntityType' +type EntityLocalInterface_EntityType_Call struct { + *mock.Call +} + +// EntityType is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) EntityType() *EntityLocalInterface_EntityType_Call { + return &EntityLocalInterface_EntityType_Call{Call: _e.mock.On("EntityType")} +} + +func (_c *EntityLocalInterface_EntityType_Call) Run(run func()) *EntityLocalInterface_EntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_EntityType_Call) Return(_a0 model.EntityTypeType) *EntityLocalInterface_EntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_EntityType_Call) RunAndReturn(run func() model.EntityTypeType) *EntityLocalInterface_EntityType_Call { + _c.Call.Return(run) + return _c +} + +// FeatureOfAddress provides a mock function with given fields: addressFeature +func (_m *EntityLocalInterface) FeatureOfAddress(addressFeature *model.AddressFeatureType) api.FeatureLocalInterface { + ret := _m.Called(addressFeature) + + if len(ret) == 0 { + panic("no return value specified for FeatureOfAddress") + } + + var r0 api.FeatureLocalInterface + if rf, ok := ret.Get(0).(func(*model.AddressFeatureType) api.FeatureLocalInterface); ok { + r0 = rf(addressFeature) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureLocalInterface) + } + } + + return r0 +} + +// EntityLocalInterface_FeatureOfAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureOfAddress' +type EntityLocalInterface_FeatureOfAddress_Call struct { + *mock.Call +} + +// FeatureOfAddress is a helper method to define mock.On call +// - addressFeature *model.AddressFeatureType +func (_e *EntityLocalInterface_Expecter) FeatureOfAddress(addressFeature interface{}) *EntityLocalInterface_FeatureOfAddress_Call { + return &EntityLocalInterface_FeatureOfAddress_Call{Call: _e.mock.On("FeatureOfAddress", addressFeature)} +} + +func (_c *EntityLocalInterface_FeatureOfAddress_Call) Run(run func(addressFeature *model.AddressFeatureType)) *EntityLocalInterface_FeatureOfAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.AddressFeatureType)) + }) + return _c +} + +func (_c *EntityLocalInterface_FeatureOfAddress_Call) Return(_a0 api.FeatureLocalInterface) *EntityLocalInterface_FeatureOfAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_FeatureOfAddress_Call) RunAndReturn(run func(*model.AddressFeatureType) api.FeatureLocalInterface) *EntityLocalInterface_FeatureOfAddress_Call { + _c.Call.Return(run) + return _c +} + +// FeatureOfTypeAndRole provides a mock function with given fields: featureType, role +func (_m *EntityLocalInterface) FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) api.FeatureLocalInterface { + ret := _m.Called(featureType, role) + + if len(ret) == 0 { + panic("no return value specified for FeatureOfTypeAndRole") + } + + var r0 api.FeatureLocalInterface + if rf, ok := ret.Get(0).(func(model.FeatureTypeType, model.RoleType) api.FeatureLocalInterface); ok { + r0 = rf(featureType, role) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureLocalInterface) + } + } + + return r0 +} + +// EntityLocalInterface_FeatureOfTypeAndRole_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureOfTypeAndRole' +type EntityLocalInterface_FeatureOfTypeAndRole_Call struct { + *mock.Call +} + +// FeatureOfTypeAndRole is a helper method to define mock.On call +// - featureType model.FeatureTypeType +// - role model.RoleType +func (_e *EntityLocalInterface_Expecter) FeatureOfTypeAndRole(featureType interface{}, role interface{}) *EntityLocalInterface_FeatureOfTypeAndRole_Call { + return &EntityLocalInterface_FeatureOfTypeAndRole_Call{Call: _e.mock.On("FeatureOfTypeAndRole", featureType, role)} +} + +func (_c *EntityLocalInterface_FeatureOfTypeAndRole_Call) Run(run func(featureType model.FeatureTypeType, role model.RoleType)) *EntityLocalInterface_FeatureOfTypeAndRole_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FeatureTypeType), args[1].(model.RoleType)) + }) + return _c +} + +func (_c *EntityLocalInterface_FeatureOfTypeAndRole_Call) Return(_a0 api.FeatureLocalInterface) *EntityLocalInterface_FeatureOfTypeAndRole_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_FeatureOfTypeAndRole_Call) RunAndReturn(run func(model.FeatureTypeType, model.RoleType) api.FeatureLocalInterface) *EntityLocalInterface_FeatureOfTypeAndRole_Call { + _c.Call.Return(run) + return _c +} + +// Features provides a mock function with given fields: +func (_m *EntityLocalInterface) Features() []api.FeatureLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Features") + } + + var r0 []api.FeatureLocalInterface + if rf, ok := ret.Get(0).(func() []api.FeatureLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.FeatureLocalInterface) + } + } + + return r0 +} + +// EntityLocalInterface_Features_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Features' +type EntityLocalInterface_Features_Call struct { + *mock.Call +} + +// Features is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) Features() *EntityLocalInterface_Features_Call { + return &EntityLocalInterface_Features_Call{Call: _e.mock.On("Features")} +} + +func (_c *EntityLocalInterface_Features_Call) Run(run func()) *EntityLocalInterface_Features_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_Features_Call) Return(_a0 []api.FeatureLocalInterface) *EntityLocalInterface_Features_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_Features_Call) RunAndReturn(run func() []api.FeatureLocalInterface) *EntityLocalInterface_Features_Call { + _c.Call.Return(run) + return _c +} + +// GetOrAddFeature provides a mock function with given fields: featureType, role +func (_m *EntityLocalInterface) GetOrAddFeature(featureType model.FeatureTypeType, role model.RoleType) api.FeatureLocalInterface { + ret := _m.Called(featureType, role) + + if len(ret) == 0 { + panic("no return value specified for GetOrAddFeature") + } + + var r0 api.FeatureLocalInterface + if rf, ok := ret.Get(0).(func(model.FeatureTypeType, model.RoleType) api.FeatureLocalInterface); ok { + r0 = rf(featureType, role) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureLocalInterface) + } + } + + return r0 +} + +// EntityLocalInterface_GetOrAddFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOrAddFeature' +type EntityLocalInterface_GetOrAddFeature_Call struct { + *mock.Call +} + +// GetOrAddFeature is a helper method to define mock.On call +// - featureType model.FeatureTypeType +// - role model.RoleType +func (_e *EntityLocalInterface_Expecter) GetOrAddFeature(featureType interface{}, role interface{}) *EntityLocalInterface_GetOrAddFeature_Call { + return &EntityLocalInterface_GetOrAddFeature_Call{Call: _e.mock.On("GetOrAddFeature", featureType, role)} +} + +func (_c *EntityLocalInterface_GetOrAddFeature_Call) Run(run func(featureType model.FeatureTypeType, role model.RoleType)) *EntityLocalInterface_GetOrAddFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FeatureTypeType), args[1].(model.RoleType)) + }) + return _c +} + +func (_c *EntityLocalInterface_GetOrAddFeature_Call) Return(_a0 api.FeatureLocalInterface) *EntityLocalInterface_GetOrAddFeature_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_GetOrAddFeature_Call) RunAndReturn(run func(model.FeatureTypeType, model.RoleType) api.FeatureLocalInterface) *EntityLocalInterface_GetOrAddFeature_Call { + _c.Call.Return(run) + return _c +} + +// HasUseCaseSupport provides a mock function with given fields: actor, useCaseName +func (_m *EntityLocalInterface) HasUseCaseSupport(actor model.UseCaseActorType, useCaseName model.UseCaseNameType) bool { + ret := _m.Called(actor, useCaseName) + + if len(ret) == 0 { + panic("no return value specified for HasUseCaseSupport") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(model.UseCaseActorType, model.UseCaseNameType) bool); ok { + r0 = rf(actor, useCaseName) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EntityLocalInterface_HasUseCaseSupport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasUseCaseSupport' +type EntityLocalInterface_HasUseCaseSupport_Call struct { + *mock.Call +} + +// HasUseCaseSupport is a helper method to define mock.On call +// - actor model.UseCaseActorType +// - useCaseName model.UseCaseNameType +func (_e *EntityLocalInterface_Expecter) HasUseCaseSupport(actor interface{}, useCaseName interface{}) *EntityLocalInterface_HasUseCaseSupport_Call { + return &EntityLocalInterface_HasUseCaseSupport_Call{Call: _e.mock.On("HasUseCaseSupport", actor, useCaseName)} +} + +func (_c *EntityLocalInterface_HasUseCaseSupport_Call) Run(run func(actor model.UseCaseActorType, useCaseName model.UseCaseNameType)) *EntityLocalInterface_HasUseCaseSupport_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.UseCaseActorType), args[1].(model.UseCaseNameType)) + }) + return _c +} + +func (_c *EntityLocalInterface_HasUseCaseSupport_Call) Return(_a0 bool) *EntityLocalInterface_HasUseCaseSupport_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_HasUseCaseSupport_Call) RunAndReturn(run func(model.UseCaseActorType, model.UseCaseNameType) bool) *EntityLocalInterface_HasUseCaseSupport_Call { + _c.Call.Return(run) + return _c +} + +// Information provides a mock function with given fields: +func (_m *EntityLocalInterface) Information() *model.NodeManagementDetailedDiscoveryEntityInformationType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Information") + } + + var r0 *model.NodeManagementDetailedDiscoveryEntityInformationType + if rf, ok := ret.Get(0).(func() *model.NodeManagementDetailedDiscoveryEntityInformationType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NodeManagementDetailedDiscoveryEntityInformationType) + } + } + + return r0 +} + +// EntityLocalInterface_Information_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Information' +type EntityLocalInterface_Information_Call struct { + *mock.Call +} + +// Information is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) Information() *EntityLocalInterface_Information_Call { + return &EntityLocalInterface_Information_Call{Call: _e.mock.On("Information")} +} + +func (_c *EntityLocalInterface_Information_Call) Run(run func()) *EntityLocalInterface_Information_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_Information_Call) Return(_a0 *model.NodeManagementDetailedDiscoveryEntityInformationType) *EntityLocalInterface_Information_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_Information_Call) RunAndReturn(run func() *model.NodeManagementDetailedDiscoveryEntityInformationType) *EntityLocalInterface_Information_Call { + _c.Call.Return(run) + return _c +} + +// NextFeatureId provides a mock function with given fields: +func (_m *EntityLocalInterface) NextFeatureId() uint { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NextFeatureId") + } + + var r0 uint + if rf, ok := ret.Get(0).(func() uint); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// EntityLocalInterface_NextFeatureId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextFeatureId' +type EntityLocalInterface_NextFeatureId_Call struct { + *mock.Call +} + +// NextFeatureId is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) NextFeatureId() *EntityLocalInterface_NextFeatureId_Call { + return &EntityLocalInterface_NextFeatureId_Call{Call: _e.mock.On("NextFeatureId")} +} + +func (_c *EntityLocalInterface_NextFeatureId_Call) Run(run func()) *EntityLocalInterface_NextFeatureId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_NextFeatureId_Call) Return(_a0 uint) *EntityLocalInterface_NextFeatureId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityLocalInterface_NextFeatureId_Call) RunAndReturn(run func() uint) *EntityLocalInterface_NextFeatureId_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllBindings provides a mock function with given fields: +func (_m *EntityLocalInterface) RemoveAllBindings() { + _m.Called() +} + +// EntityLocalInterface_RemoveAllBindings_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllBindings' +type EntityLocalInterface_RemoveAllBindings_Call struct { + *mock.Call +} + +// RemoveAllBindings is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) RemoveAllBindings() *EntityLocalInterface_RemoveAllBindings_Call { + return &EntityLocalInterface_RemoveAllBindings_Call{Call: _e.mock.On("RemoveAllBindings")} +} + +func (_c *EntityLocalInterface_RemoveAllBindings_Call) Run(run func()) *EntityLocalInterface_RemoveAllBindings_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_RemoveAllBindings_Call) Return() *EntityLocalInterface_RemoveAllBindings_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_RemoveAllBindings_Call) RunAndReturn(run func()) *EntityLocalInterface_RemoveAllBindings_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllSubscriptions provides a mock function with given fields: +func (_m *EntityLocalInterface) RemoveAllSubscriptions() { + _m.Called() +} + +// EntityLocalInterface_RemoveAllSubscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllSubscriptions' +type EntityLocalInterface_RemoveAllSubscriptions_Call struct { + *mock.Call +} + +// RemoveAllSubscriptions is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) RemoveAllSubscriptions() *EntityLocalInterface_RemoveAllSubscriptions_Call { + return &EntityLocalInterface_RemoveAllSubscriptions_Call{Call: _e.mock.On("RemoveAllSubscriptions")} +} + +func (_c *EntityLocalInterface_RemoveAllSubscriptions_Call) Run(run func()) *EntityLocalInterface_RemoveAllSubscriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_RemoveAllSubscriptions_Call) Return() *EntityLocalInterface_RemoveAllSubscriptions_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_RemoveAllSubscriptions_Call) RunAndReturn(run func()) *EntityLocalInterface_RemoveAllSubscriptions_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllUseCaseSupports provides a mock function with given fields: +func (_m *EntityLocalInterface) RemoveAllUseCaseSupports() { + _m.Called() +} + +// EntityLocalInterface_RemoveAllUseCaseSupports_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllUseCaseSupports' +type EntityLocalInterface_RemoveAllUseCaseSupports_Call struct { + *mock.Call +} + +// RemoveAllUseCaseSupports is a helper method to define mock.On call +func (_e *EntityLocalInterface_Expecter) RemoveAllUseCaseSupports() *EntityLocalInterface_RemoveAllUseCaseSupports_Call { + return &EntityLocalInterface_RemoveAllUseCaseSupports_Call{Call: _e.mock.On("RemoveAllUseCaseSupports")} +} + +func (_c *EntityLocalInterface_RemoveAllUseCaseSupports_Call) Run(run func()) *EntityLocalInterface_RemoveAllUseCaseSupports_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityLocalInterface_RemoveAllUseCaseSupports_Call) Return() *EntityLocalInterface_RemoveAllUseCaseSupports_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_RemoveAllUseCaseSupports_Call) RunAndReturn(run func()) *EntityLocalInterface_RemoveAllUseCaseSupports_Call { + _c.Call.Return(run) + return _c +} + +// RemoveUseCaseSupport provides a mock function with given fields: actor, useCaseName +func (_m *EntityLocalInterface) RemoveUseCaseSupport(actor model.UseCaseActorType, useCaseName model.UseCaseNameType) { + _m.Called(actor, useCaseName) +} + +// EntityLocalInterface_RemoveUseCaseSupport_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveUseCaseSupport' +type EntityLocalInterface_RemoveUseCaseSupport_Call struct { + *mock.Call +} + +// RemoveUseCaseSupport is a helper method to define mock.On call +// - actor model.UseCaseActorType +// - useCaseName model.UseCaseNameType +func (_e *EntityLocalInterface_Expecter) RemoveUseCaseSupport(actor interface{}, useCaseName interface{}) *EntityLocalInterface_RemoveUseCaseSupport_Call { + return &EntityLocalInterface_RemoveUseCaseSupport_Call{Call: _e.mock.On("RemoveUseCaseSupport", actor, useCaseName)} +} + +func (_c *EntityLocalInterface_RemoveUseCaseSupport_Call) Run(run func(actor model.UseCaseActorType, useCaseName model.UseCaseNameType)) *EntityLocalInterface_RemoveUseCaseSupport_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.UseCaseActorType), args[1].(model.UseCaseNameType)) + }) + return _c +} + +func (_c *EntityLocalInterface_RemoveUseCaseSupport_Call) Return() *EntityLocalInterface_RemoveUseCaseSupport_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_RemoveUseCaseSupport_Call) RunAndReturn(run func(model.UseCaseActorType, model.UseCaseNameType)) *EntityLocalInterface_RemoveUseCaseSupport_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: d +func (_m *EntityLocalInterface) SetDescription(d *model.DescriptionType) { + _m.Called(d) +} + +// EntityLocalInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type EntityLocalInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - d *model.DescriptionType +func (_e *EntityLocalInterface_Expecter) SetDescription(d interface{}) *EntityLocalInterface_SetDescription_Call { + return &EntityLocalInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", d)} +} + +func (_c *EntityLocalInterface_SetDescription_Call) Run(run func(d *model.DescriptionType)) *EntityLocalInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *EntityLocalInterface_SetDescription_Call) Return() *EntityLocalInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *EntityLocalInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// SetUseCaseAvailability provides a mock function with given fields: actor, useCaseName, available +func (_m *EntityLocalInterface) SetUseCaseAvailability(actor model.UseCaseActorType, useCaseName model.UseCaseNameType, available bool) { + _m.Called(actor, useCaseName, available) +} + +// EntityLocalInterface_SetUseCaseAvailability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetUseCaseAvailability' +type EntityLocalInterface_SetUseCaseAvailability_Call struct { + *mock.Call +} + +// SetUseCaseAvailability is a helper method to define mock.On call +// - actor model.UseCaseActorType +// - useCaseName model.UseCaseNameType +// - available bool +func (_e *EntityLocalInterface_Expecter) SetUseCaseAvailability(actor interface{}, useCaseName interface{}, available interface{}) *EntityLocalInterface_SetUseCaseAvailability_Call { + return &EntityLocalInterface_SetUseCaseAvailability_Call{Call: _e.mock.On("SetUseCaseAvailability", actor, useCaseName, available)} +} + +func (_c *EntityLocalInterface_SetUseCaseAvailability_Call) Run(run func(actor model.UseCaseActorType, useCaseName model.UseCaseNameType, available bool)) *EntityLocalInterface_SetUseCaseAvailability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.UseCaseActorType), args[1].(model.UseCaseNameType), args[2].(bool)) + }) + return _c +} + +func (_c *EntityLocalInterface_SetUseCaseAvailability_Call) Return() *EntityLocalInterface_SetUseCaseAvailability_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityLocalInterface_SetUseCaseAvailability_Call) RunAndReturn(run func(model.UseCaseActorType, model.UseCaseNameType, bool)) *EntityLocalInterface_SetUseCaseAvailability_Call { + _c.Call.Return(run) + return _c +} + +// NewEntityLocalInterface creates a new instance of EntityLocalInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEntityLocalInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EntityLocalInterface { + mock := &EntityLocalInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/EntityRemoteInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/EntityRemoteInterface.go new file mode 100644 index 0000000..eb8af24 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/EntityRemoteInterface.go @@ -0,0 +1,543 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// EntityRemoteInterface is an autogenerated mock type for the EntityRemoteInterface type +type EntityRemoteInterface struct { + mock.Mock +} + +type EntityRemoteInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EntityRemoteInterface) EXPECT() *EntityRemoteInterface_Expecter { + return &EntityRemoteInterface_Expecter{mock: &_m.Mock} +} + +// AddFeature provides a mock function with given fields: f +func (_m *EntityRemoteInterface) AddFeature(f api.FeatureRemoteInterface) { + _m.Called(f) +} + +// EntityRemoteInterface_AddFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeature' +type EntityRemoteInterface_AddFeature_Call struct { + *mock.Call +} + +// AddFeature is a helper method to define mock.On call +// - f api.FeatureRemoteInterface +func (_e *EntityRemoteInterface_Expecter) AddFeature(f interface{}) *EntityRemoteInterface_AddFeature_Call { + return &EntityRemoteInterface_AddFeature_Call{Call: _e.mock.On("AddFeature", f)} +} + +func (_c *EntityRemoteInterface_AddFeature_Call) Run(run func(f api.FeatureRemoteInterface)) *EntityRemoteInterface_AddFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.FeatureRemoteInterface)) + }) + return _c +} + +func (_c *EntityRemoteInterface_AddFeature_Call) Return() *EntityRemoteInterface_AddFeature_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityRemoteInterface_AddFeature_Call) RunAndReturn(run func(api.FeatureRemoteInterface)) *EntityRemoteInterface_AddFeature_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *EntityRemoteInterface) Address() *model.EntityAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.EntityAddressType + if rf, ok := ret.Get(0).(func() *model.EntityAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.EntityAddressType) + } + } + + return r0 +} + +// EntityRemoteInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type EntityRemoteInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) Address() *EntityRemoteInterface_Address_Call { + return &EntityRemoteInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *EntityRemoteInterface_Address_Call) Run(run func()) *EntityRemoteInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_Address_Call) Return(_a0 *model.EntityAddressType) *EntityRemoteInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_Address_Call) RunAndReturn(run func() *model.EntityAddressType) *EntityRemoteInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *EntityRemoteInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// EntityRemoteInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type EntityRemoteInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) Description() *EntityRemoteInterface_Description_Call { + return &EntityRemoteInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *EntityRemoteInterface_Description_Call) Run(run func()) *EntityRemoteInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_Description_Call) Return(_a0 *model.DescriptionType) *EntityRemoteInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *EntityRemoteInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Device provides a mock function with given fields: +func (_m *EntityRemoteInterface) Device() api.DeviceRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Device") + } + + var r0 api.DeviceRemoteInterface + if rf, ok := ret.Get(0).(func() api.DeviceRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceRemoteInterface) + } + } + + return r0 +} + +// EntityRemoteInterface_Device_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Device' +type EntityRemoteInterface_Device_Call struct { + *mock.Call +} + +// Device is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) Device() *EntityRemoteInterface_Device_Call { + return &EntityRemoteInterface_Device_Call{Call: _e.mock.On("Device")} +} + +func (_c *EntityRemoteInterface_Device_Call) Run(run func()) *EntityRemoteInterface_Device_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_Device_Call) Return(_a0 api.DeviceRemoteInterface) *EntityRemoteInterface_Device_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_Device_Call) RunAndReturn(run func() api.DeviceRemoteInterface) *EntityRemoteInterface_Device_Call { + _c.Call.Return(run) + return _c +} + +// EntityType provides a mock function with given fields: +func (_m *EntityRemoteInterface) EntityType() model.EntityTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EntityType") + } + + var r0 model.EntityTypeType + if rf, ok := ret.Get(0).(func() model.EntityTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.EntityTypeType) + } + + return r0 +} + +// EntityRemoteInterface_EntityType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EntityType' +type EntityRemoteInterface_EntityType_Call struct { + *mock.Call +} + +// EntityType is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) EntityType() *EntityRemoteInterface_EntityType_Call { + return &EntityRemoteInterface_EntityType_Call{Call: _e.mock.On("EntityType")} +} + +func (_c *EntityRemoteInterface_EntityType_Call) Run(run func()) *EntityRemoteInterface_EntityType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_EntityType_Call) Return(_a0 model.EntityTypeType) *EntityRemoteInterface_EntityType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_EntityType_Call) RunAndReturn(run func() model.EntityTypeType) *EntityRemoteInterface_EntityType_Call { + _c.Call.Return(run) + return _c +} + +// FeatureOfAddress provides a mock function with given fields: addressFeature +func (_m *EntityRemoteInterface) FeatureOfAddress(addressFeature *model.AddressFeatureType) api.FeatureRemoteInterface { + ret := _m.Called(addressFeature) + + if len(ret) == 0 { + panic("no return value specified for FeatureOfAddress") + } + + var r0 api.FeatureRemoteInterface + if rf, ok := ret.Get(0).(func(*model.AddressFeatureType) api.FeatureRemoteInterface); ok { + r0 = rf(addressFeature) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureRemoteInterface) + } + } + + return r0 +} + +// EntityRemoteInterface_FeatureOfAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureOfAddress' +type EntityRemoteInterface_FeatureOfAddress_Call struct { + *mock.Call +} + +// FeatureOfAddress is a helper method to define mock.On call +// - addressFeature *model.AddressFeatureType +func (_e *EntityRemoteInterface_Expecter) FeatureOfAddress(addressFeature interface{}) *EntityRemoteInterface_FeatureOfAddress_Call { + return &EntityRemoteInterface_FeatureOfAddress_Call{Call: _e.mock.On("FeatureOfAddress", addressFeature)} +} + +func (_c *EntityRemoteInterface_FeatureOfAddress_Call) Run(run func(addressFeature *model.AddressFeatureType)) *EntityRemoteInterface_FeatureOfAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.AddressFeatureType)) + }) + return _c +} + +func (_c *EntityRemoteInterface_FeatureOfAddress_Call) Return(_a0 api.FeatureRemoteInterface) *EntityRemoteInterface_FeatureOfAddress_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_FeatureOfAddress_Call) RunAndReturn(run func(*model.AddressFeatureType) api.FeatureRemoteInterface) *EntityRemoteInterface_FeatureOfAddress_Call { + _c.Call.Return(run) + return _c +} + +// FeatureOfTypeAndRole provides a mock function with given fields: featureType, role +func (_m *EntityRemoteInterface) FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) api.FeatureRemoteInterface { + ret := _m.Called(featureType, role) + + if len(ret) == 0 { + panic("no return value specified for FeatureOfTypeAndRole") + } + + var r0 api.FeatureRemoteInterface + if rf, ok := ret.Get(0).(func(model.FeatureTypeType, model.RoleType) api.FeatureRemoteInterface); ok { + r0 = rf(featureType, role) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.FeatureRemoteInterface) + } + } + + return r0 +} + +// EntityRemoteInterface_FeatureOfTypeAndRole_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FeatureOfTypeAndRole' +type EntityRemoteInterface_FeatureOfTypeAndRole_Call struct { + *mock.Call +} + +// FeatureOfTypeAndRole is a helper method to define mock.On call +// - featureType model.FeatureTypeType +// - role model.RoleType +func (_e *EntityRemoteInterface_Expecter) FeatureOfTypeAndRole(featureType interface{}, role interface{}) *EntityRemoteInterface_FeatureOfTypeAndRole_Call { + return &EntityRemoteInterface_FeatureOfTypeAndRole_Call{Call: _e.mock.On("FeatureOfTypeAndRole", featureType, role)} +} + +func (_c *EntityRemoteInterface_FeatureOfTypeAndRole_Call) Run(run func(featureType model.FeatureTypeType, role model.RoleType)) *EntityRemoteInterface_FeatureOfTypeAndRole_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FeatureTypeType), args[1].(model.RoleType)) + }) + return _c +} + +func (_c *EntityRemoteInterface_FeatureOfTypeAndRole_Call) Return(_a0 api.FeatureRemoteInterface) *EntityRemoteInterface_FeatureOfTypeAndRole_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_FeatureOfTypeAndRole_Call) RunAndReturn(run func(model.FeatureTypeType, model.RoleType) api.FeatureRemoteInterface) *EntityRemoteInterface_FeatureOfTypeAndRole_Call { + _c.Call.Return(run) + return _c +} + +// Features provides a mock function with given fields: +func (_m *EntityRemoteInterface) Features() []api.FeatureRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Features") + } + + var r0 []api.FeatureRemoteInterface + if rf, ok := ret.Get(0).(func() []api.FeatureRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]api.FeatureRemoteInterface) + } + } + + return r0 +} + +// EntityRemoteInterface_Features_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Features' +type EntityRemoteInterface_Features_Call struct { + *mock.Call +} + +// Features is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) Features() *EntityRemoteInterface_Features_Call { + return &EntityRemoteInterface_Features_Call{Call: _e.mock.On("Features")} +} + +func (_c *EntityRemoteInterface_Features_Call) Run(run func()) *EntityRemoteInterface_Features_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_Features_Call) Return(_a0 []api.FeatureRemoteInterface) *EntityRemoteInterface_Features_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_Features_Call) RunAndReturn(run func() []api.FeatureRemoteInterface) *EntityRemoteInterface_Features_Call { + _c.Call.Return(run) + return _c +} + +// NextFeatureId provides a mock function with given fields: +func (_m *EntityRemoteInterface) NextFeatureId() uint { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NextFeatureId") + } + + var r0 uint + if rf, ok := ret.Get(0).(func() uint); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// EntityRemoteInterface_NextFeatureId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NextFeatureId' +type EntityRemoteInterface_NextFeatureId_Call struct { + *mock.Call +} + +// NextFeatureId is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) NextFeatureId() *EntityRemoteInterface_NextFeatureId_Call { + return &EntityRemoteInterface_NextFeatureId_Call{Call: _e.mock.On("NextFeatureId")} +} + +func (_c *EntityRemoteInterface_NextFeatureId_Call) Run(run func()) *EntityRemoteInterface_NextFeatureId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_NextFeatureId_Call) Return(_a0 uint) *EntityRemoteInterface_NextFeatureId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EntityRemoteInterface_NextFeatureId_Call) RunAndReturn(run func() uint) *EntityRemoteInterface_NextFeatureId_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllFeatures provides a mock function with given fields: +func (_m *EntityRemoteInterface) RemoveAllFeatures() { + _m.Called() +} + +// EntityRemoteInterface_RemoveAllFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllFeatures' +type EntityRemoteInterface_RemoveAllFeatures_Call struct { + *mock.Call +} + +// RemoveAllFeatures is a helper method to define mock.On call +func (_e *EntityRemoteInterface_Expecter) RemoveAllFeatures() *EntityRemoteInterface_RemoveAllFeatures_Call { + return &EntityRemoteInterface_RemoveAllFeatures_Call{Call: _e.mock.On("RemoveAllFeatures")} +} + +func (_c *EntityRemoteInterface_RemoveAllFeatures_Call) Run(run func()) *EntityRemoteInterface_RemoveAllFeatures_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EntityRemoteInterface_RemoveAllFeatures_Call) Return() *EntityRemoteInterface_RemoveAllFeatures_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityRemoteInterface_RemoveAllFeatures_Call) RunAndReturn(run func()) *EntityRemoteInterface_RemoveAllFeatures_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: d +func (_m *EntityRemoteInterface) SetDescription(d *model.DescriptionType) { + _m.Called(d) +} + +// EntityRemoteInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type EntityRemoteInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - d *model.DescriptionType +func (_e *EntityRemoteInterface_Expecter) SetDescription(d interface{}) *EntityRemoteInterface_SetDescription_Call { + return &EntityRemoteInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", d)} +} + +func (_c *EntityRemoteInterface_SetDescription_Call) Run(run func(d *model.DescriptionType)) *EntityRemoteInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *EntityRemoteInterface_SetDescription_Call) Return() *EntityRemoteInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityRemoteInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *EntityRemoteInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDeviceAddress provides a mock function with given fields: address +func (_m *EntityRemoteInterface) UpdateDeviceAddress(address model.AddressDeviceType) { + _m.Called(address) +} + +// EntityRemoteInterface_UpdateDeviceAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDeviceAddress' +type EntityRemoteInterface_UpdateDeviceAddress_Call struct { + *mock.Call +} + +// UpdateDeviceAddress is a helper method to define mock.On call +// - address model.AddressDeviceType +func (_e *EntityRemoteInterface_Expecter) UpdateDeviceAddress(address interface{}) *EntityRemoteInterface_UpdateDeviceAddress_Call { + return &EntityRemoteInterface_UpdateDeviceAddress_Call{Call: _e.mock.On("UpdateDeviceAddress", address)} +} + +func (_c *EntityRemoteInterface_UpdateDeviceAddress_Call) Run(run func(address model.AddressDeviceType)) *EntityRemoteInterface_UpdateDeviceAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.AddressDeviceType)) + }) + return _c +} + +func (_c *EntityRemoteInterface_UpdateDeviceAddress_Call) Return() *EntityRemoteInterface_UpdateDeviceAddress_Call { + _c.Call.Return() + return _c +} + +func (_c *EntityRemoteInterface_UpdateDeviceAddress_Call) RunAndReturn(run func(model.AddressDeviceType)) *EntityRemoteInterface_UpdateDeviceAddress_Call { + _c.Call.Return(run) + return _c +} + +// NewEntityRemoteInterface creates a new instance of EntityRemoteInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEntityRemoteInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EntityRemoteInterface { + mock := &EntityRemoteInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/EventHandlerInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/EventHandlerInterface.go new file mode 100644 index 0000000..3c51b8b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/EventHandlerInterface.go @@ -0,0 +1,68 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" +) + +// EventHandlerInterface is an autogenerated mock type for the EventHandlerInterface type +type EventHandlerInterface struct { + mock.Mock +} + +type EventHandlerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *EventHandlerInterface) EXPECT() *EventHandlerInterface_Expecter { + return &EventHandlerInterface_Expecter{mock: &_m.Mock} +} + +// HandleEvent provides a mock function with given fields: _a0 +func (_m *EventHandlerInterface) HandleEvent(_a0 api.EventPayload) { + _m.Called(_a0) +} + +// EventHandlerInterface_HandleEvent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleEvent' +type EventHandlerInterface_HandleEvent_Call struct { + *mock.Call +} + +// HandleEvent is a helper method to define mock.On call +// - _a0 api.EventPayload +func (_e *EventHandlerInterface_Expecter) HandleEvent(_a0 interface{}) *EventHandlerInterface_HandleEvent_Call { + return &EventHandlerInterface_HandleEvent_Call{Call: _e.mock.On("HandleEvent", _a0)} +} + +func (_c *EventHandlerInterface_HandleEvent_Call) Run(run func(_a0 api.EventPayload)) *EventHandlerInterface_HandleEvent_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EventPayload)) + }) + return _c +} + +func (_c *EventHandlerInterface_HandleEvent_Call) Return() *EventHandlerInterface_HandleEvent_Call { + _c.Call.Return() + return _c +} + +func (_c *EventHandlerInterface_HandleEvent_Call) RunAndReturn(run func(api.EventPayload)) *EventHandlerInterface_HandleEvent_Call { + _c.Call.Return(run) + return _c +} + +// NewEventHandlerInterface creates a new instance of EventHandlerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEventHandlerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *EventHandlerInterface { + mock := &EventHandlerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/FeatureInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/FeatureInterface.go new file mode 100644 index 0000000..2c0a769 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/FeatureInterface.go @@ -0,0 +1,379 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// FeatureInterface is an autogenerated mock type for the FeatureInterface type +type FeatureInterface struct { + mock.Mock +} + +type FeatureInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureInterface) EXPECT() *FeatureInterface_Expecter { + return &FeatureInterface_Expecter{mock: &_m.Mock} +} + +// Address provides a mock function with given fields: +func (_m *FeatureInterface) Address() *model.FeatureAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.FeatureAddressType + if rf, ok := ret.Get(0).(func() *model.FeatureAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.FeatureAddressType) + } + } + + return r0 +} + +// FeatureInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type FeatureInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Address() *FeatureInterface_Address_Call { + return &FeatureInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *FeatureInterface_Address_Call) Run(run func()) *FeatureInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Address_Call) Return(_a0 *model.FeatureAddressType) *FeatureInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_Address_Call) RunAndReturn(run func() *model.FeatureAddressType) *FeatureInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *FeatureInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// FeatureInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type FeatureInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Description() *FeatureInterface_Description_Call { + return &FeatureInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *FeatureInterface_Description_Call) Run(run func()) *FeatureInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Description_Call) Return(_a0 *model.DescriptionType) *FeatureInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *FeatureInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Operations provides a mock function with given fields: +func (_m *FeatureInterface) Operations() map[model.FunctionType]api.OperationsInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Operations") + } + + var r0 map[model.FunctionType]api.OperationsInterface + if rf, ok := ret.Get(0).(func() map[model.FunctionType]api.OperationsInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.FunctionType]api.OperationsInterface) + } + } + + return r0 +} + +// FeatureInterface_Operations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operations' +type FeatureInterface_Operations_Call struct { + *mock.Call +} + +// Operations is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Operations() *FeatureInterface_Operations_Call { + return &FeatureInterface_Operations_Call{Call: _e.mock.On("Operations")} +} + +func (_c *FeatureInterface_Operations_Call) Run(run func()) *FeatureInterface_Operations_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Operations_Call) Return(_a0 map[model.FunctionType]api.OperationsInterface) *FeatureInterface_Operations_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_Operations_Call) RunAndReturn(run func() map[model.FunctionType]api.OperationsInterface) *FeatureInterface_Operations_Call { + _c.Call.Return(run) + return _c +} + +// Role provides a mock function with given fields: +func (_m *FeatureInterface) Role() model.RoleType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Role") + } + + var r0 model.RoleType + if rf, ok := ret.Get(0).(func() model.RoleType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.RoleType) + } + + return r0 +} + +// FeatureInterface_Role_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Role' +type FeatureInterface_Role_Call struct { + *mock.Call +} + +// Role is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Role() *FeatureInterface_Role_Call { + return &FeatureInterface_Role_Call{Call: _e.mock.On("Role")} +} + +func (_c *FeatureInterface_Role_Call) Run(run func()) *FeatureInterface_Role_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Role_Call) Return(_a0 model.RoleType) *FeatureInterface_Role_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_Role_Call) RunAndReturn(run func() model.RoleType) *FeatureInterface_Role_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: desc +func (_m *FeatureInterface) SetDescription(desc *model.DescriptionType) { + _m.Called(desc) +} + +// FeatureInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type FeatureInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - desc *model.DescriptionType +func (_e *FeatureInterface_Expecter) SetDescription(desc interface{}) *FeatureInterface_SetDescription_Call { + return &FeatureInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", desc)} +} + +func (_c *FeatureInterface_SetDescription_Call) Run(run func(desc *model.DescriptionType)) *FeatureInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *FeatureInterface_SetDescription_Call) Return() *FeatureInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *FeatureInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// SetDescriptionString provides a mock function with given fields: s +func (_m *FeatureInterface) SetDescriptionString(s string) { + _m.Called(s) +} + +// FeatureInterface_SetDescriptionString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescriptionString' +type FeatureInterface_SetDescriptionString_Call struct { + *mock.Call +} + +// SetDescriptionString is a helper method to define mock.On call +// - s string +func (_e *FeatureInterface_Expecter) SetDescriptionString(s interface{}) *FeatureInterface_SetDescriptionString_Call { + return &FeatureInterface_SetDescriptionString_Call{Call: _e.mock.On("SetDescriptionString", s)} +} + +func (_c *FeatureInterface_SetDescriptionString_Call) Run(run func(s string)) *FeatureInterface_SetDescriptionString_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *FeatureInterface_SetDescriptionString_Call) Return() *FeatureInterface_SetDescriptionString_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureInterface_SetDescriptionString_Call) RunAndReturn(run func(string)) *FeatureInterface_SetDescriptionString_Call { + _c.Call.Return(run) + return _c +} + +// String provides a mock function with given fields: +func (_m *FeatureInterface) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// FeatureInterface_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' +type FeatureInterface_String_Call struct { + *mock.Call +} + +// String is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) String() *FeatureInterface_String_Call { + return &FeatureInterface_String_Call{Call: _e.mock.On("String")} +} + +func (_c *FeatureInterface_String_Call) Run(run func()) *FeatureInterface_String_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_String_Call) Return(_a0 string) *FeatureInterface_String_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_String_Call) RunAndReturn(run func() string) *FeatureInterface_String_Call { + _c.Call.Return(run) + return _c +} + +// Type provides a mock function with given fields: +func (_m *FeatureInterface) Type() model.FeatureTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Type") + } + + var r0 model.FeatureTypeType + if rf, ok := ret.Get(0).(func() model.FeatureTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FeatureTypeType) + } + + return r0 +} + +// FeatureInterface_Type_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Type' +type FeatureInterface_Type_Call struct { + *mock.Call +} + +// Type is a helper method to define mock.On call +func (_e *FeatureInterface_Expecter) Type() *FeatureInterface_Type_Call { + return &FeatureInterface_Type_Call{Call: _e.mock.On("Type")} +} + +func (_c *FeatureInterface_Type_Call) Run(run func()) *FeatureInterface_Type_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureInterface_Type_Call) Return(_a0 model.FeatureTypeType) *FeatureInterface_Type_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureInterface_Type_Call) RunAndReturn(run func() model.FeatureTypeType) *FeatureInterface_Type_Call { + _c.Call.Return(run) + return _c +} + +// NewFeatureInterface creates a new instance of FeatureInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureInterface { + mock := &FeatureInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/FeatureLocalInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/FeatureLocalInterface.go new file mode 100644 index 0000000..d864da7 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/FeatureLocalInterface.go @@ -0,0 +1,1600 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + time "time" +) + +// FeatureLocalInterface is an autogenerated mock type for the FeatureLocalInterface type +type FeatureLocalInterface struct { + mock.Mock +} + +type FeatureLocalInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureLocalInterface) EXPECT() *FeatureLocalInterface_Expecter { + return &FeatureLocalInterface_Expecter{mock: &_m.Mock} +} + +// AddFunctionType provides a mock function with given fields: function, read, write +func (_m *FeatureLocalInterface) AddFunctionType(function model.FunctionType, read bool, write bool) { + _m.Called(function, read, write) +} + +// FeatureLocalInterface_AddFunctionType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFunctionType' +type FeatureLocalInterface_AddFunctionType_Call struct { + *mock.Call +} + +// AddFunctionType is a helper method to define mock.On call +// - function model.FunctionType +// - read bool +// - write bool +func (_e *FeatureLocalInterface_Expecter) AddFunctionType(function interface{}, read interface{}, write interface{}) *FeatureLocalInterface_AddFunctionType_Call { + return &FeatureLocalInterface_AddFunctionType_Call{Call: _e.mock.On("AddFunctionType", function, read, write)} +} + +func (_c *FeatureLocalInterface_AddFunctionType_Call) Run(run func(function model.FunctionType, read bool, write bool)) *FeatureLocalInterface_AddFunctionType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(bool), args[2].(bool)) + }) + return _c +} + +func (_c *FeatureLocalInterface_AddFunctionType_Call) Return() *FeatureLocalInterface_AddFunctionType_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_AddFunctionType_Call) RunAndReturn(run func(model.FunctionType, bool, bool)) *FeatureLocalInterface_AddFunctionType_Call { + _c.Call.Return(run) + return _c +} + +// AddResponseCallback provides a mock function with given fields: msgCounterReference, function +func (_m *FeatureLocalInterface) AddResponseCallback(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage)) error { + ret := _m.Called(msgCounterReference, function) + + if len(ret) == 0 { + panic("no return value specified for AddResponseCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MsgCounterType, func(api.ResponseMessage)) error); ok { + r0 = rf(msgCounterReference, function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FeatureLocalInterface_AddResponseCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResponseCallback' +type FeatureLocalInterface_AddResponseCallback_Call struct { + *mock.Call +} + +// AddResponseCallback is a helper method to define mock.On call +// - msgCounterReference model.MsgCounterType +// - function func(api.ResponseMessage) +func (_e *FeatureLocalInterface_Expecter) AddResponseCallback(msgCounterReference interface{}, function interface{}) *FeatureLocalInterface_AddResponseCallback_Call { + return &FeatureLocalInterface_AddResponseCallback_Call{Call: _e.mock.On("AddResponseCallback", msgCounterReference, function)} +} + +func (_c *FeatureLocalInterface_AddResponseCallback_Call) Run(run func(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage))) *FeatureLocalInterface_AddResponseCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureLocalInterface_AddResponseCallback_Call) Return(_a0 error) *FeatureLocalInterface_AddResponseCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_AddResponseCallback_Call) RunAndReturn(run func(model.MsgCounterType, func(api.ResponseMessage)) error) *FeatureLocalInterface_AddResponseCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddResultCallback provides a mock function with given fields: function +func (_m *FeatureLocalInterface) AddResultCallback(function func(api.ResponseMessage)) { + _m.Called(function) +} + +// FeatureLocalInterface_AddResultCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResultCallback' +type FeatureLocalInterface_AddResultCallback_Call struct { + *mock.Call +} + +// AddResultCallback is a helper method to define mock.On call +// - function func(api.ResponseMessage) +func (_e *FeatureLocalInterface_Expecter) AddResultCallback(function interface{}) *FeatureLocalInterface_AddResultCallback_Call { + return &FeatureLocalInterface_AddResultCallback_Call{Call: _e.mock.On("AddResultCallback", function)} +} + +func (_c *FeatureLocalInterface_AddResultCallback_Call) Run(run func(function func(api.ResponseMessage))) *FeatureLocalInterface_AddResultCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *FeatureLocalInterface_AddResultCallback_Call) Return() *FeatureLocalInterface_AddResultCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_AddResultCallback_Call) RunAndReturn(run func(func(api.ResponseMessage))) *FeatureLocalInterface_AddResultCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddWriteApprovalCallback provides a mock function with given fields: function +func (_m *FeatureLocalInterface) AddWriteApprovalCallback(function api.WriteApprovalCallbackFunc) error { + ret := _m.Called(function) + + if len(ret) == 0 { + panic("no return value specified for AddWriteApprovalCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.WriteApprovalCallbackFunc) error); ok { + r0 = rf(function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// FeatureLocalInterface_AddWriteApprovalCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddWriteApprovalCallback' +type FeatureLocalInterface_AddWriteApprovalCallback_Call struct { + *mock.Call +} + +// AddWriteApprovalCallback is a helper method to define mock.On call +// - function api.WriteApprovalCallbackFunc +func (_e *FeatureLocalInterface_Expecter) AddWriteApprovalCallback(function interface{}) *FeatureLocalInterface_AddWriteApprovalCallback_Call { + return &FeatureLocalInterface_AddWriteApprovalCallback_Call{Call: _e.mock.On("AddWriteApprovalCallback", function)} +} + +func (_c *FeatureLocalInterface_AddWriteApprovalCallback_Call) Run(run func(function api.WriteApprovalCallbackFunc)) *FeatureLocalInterface_AddWriteApprovalCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.WriteApprovalCallbackFunc)) + }) + return _c +} + +func (_c *FeatureLocalInterface_AddWriteApprovalCallback_Call) Return(_a0 error) *FeatureLocalInterface_AddWriteApprovalCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_AddWriteApprovalCallback_Call) RunAndReturn(run func(api.WriteApprovalCallbackFunc) error) *FeatureLocalInterface_AddWriteApprovalCallback_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *FeatureLocalInterface) Address() *model.FeatureAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.FeatureAddressType + if rf, ok := ret.Get(0).(func() *model.FeatureAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.FeatureAddressType) + } + } + + return r0 +} + +// FeatureLocalInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type FeatureLocalInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Address() *FeatureLocalInterface_Address_Call { + return &FeatureLocalInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *FeatureLocalInterface_Address_Call) Run(run func()) *FeatureLocalInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Address_Call) Return(_a0 *model.FeatureAddressType) *FeatureLocalInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Address_Call) RunAndReturn(run func() *model.FeatureAddressType) *FeatureLocalInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// ApproveOrDenyWrite provides a mock function with given fields: msg, err +func (_m *FeatureLocalInterface) ApproveOrDenyWrite(msg *api.Message, err model.ErrorType) { + _m.Called(msg, err) +} + +// FeatureLocalInterface_ApproveOrDenyWrite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApproveOrDenyWrite' +type FeatureLocalInterface_ApproveOrDenyWrite_Call struct { + *mock.Call +} + +// ApproveOrDenyWrite is a helper method to define mock.On call +// - msg *api.Message +// - err model.ErrorType +func (_e *FeatureLocalInterface_Expecter) ApproveOrDenyWrite(msg interface{}, err interface{}) *FeatureLocalInterface_ApproveOrDenyWrite_Call { + return &FeatureLocalInterface_ApproveOrDenyWrite_Call{Call: _e.mock.On("ApproveOrDenyWrite", msg, err)} +} + +func (_c *FeatureLocalInterface_ApproveOrDenyWrite_Call) Run(run func(msg *api.Message, err model.ErrorType)) *FeatureLocalInterface_ApproveOrDenyWrite_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*api.Message), args[1].(model.ErrorType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_ApproveOrDenyWrite_Call) Return() *FeatureLocalInterface_ApproveOrDenyWrite_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_ApproveOrDenyWrite_Call) RunAndReturn(run func(*api.Message, model.ErrorType)) *FeatureLocalInterface_ApproveOrDenyWrite_Call { + _c.Call.Return(run) + return _c +} + +// BindToRemote provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) BindToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for BindToRemote") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_BindToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindToRemote' +type FeatureLocalInterface_BindToRemote_Call struct { + *mock.Call +} + +// BindToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) BindToRemote(remoteAddress interface{}) *FeatureLocalInterface_BindToRemote_Call { + return &FeatureLocalInterface_BindToRemote_Call{Call: _e.mock.On("BindToRemote", remoteAddress)} +} + +func (_c *FeatureLocalInterface_BindToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_BindToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_BindToRemote_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_BindToRemote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_BindToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_BindToRemote_Call { + _c.Call.Return(run) + return _c +} + +// CleanRemoteDeviceCaches provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) CleanRemoteDeviceCaches(remoteAddress *model.DeviceAddressType) { + _m.Called(remoteAddress) +} + +// FeatureLocalInterface_CleanRemoteDeviceCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanRemoteDeviceCaches' +type FeatureLocalInterface_CleanRemoteDeviceCaches_Call struct { + *mock.Call +} + +// CleanRemoteDeviceCaches is a helper method to define mock.On call +// - remoteAddress *model.DeviceAddressType +func (_e *FeatureLocalInterface_Expecter) CleanRemoteDeviceCaches(remoteAddress interface{}) *FeatureLocalInterface_CleanRemoteDeviceCaches_Call { + return &FeatureLocalInterface_CleanRemoteDeviceCaches_Call{Call: _e.mock.On("CleanRemoteDeviceCaches", remoteAddress)} +} + +func (_c *FeatureLocalInterface_CleanRemoteDeviceCaches_Call) Run(run func(remoteAddress *model.DeviceAddressType)) *FeatureLocalInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DeviceAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_CleanRemoteDeviceCaches_Call) Return() *FeatureLocalInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_CleanRemoteDeviceCaches_Call) RunAndReturn(run func(*model.DeviceAddressType)) *FeatureLocalInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Return(run) + return _c +} + +// CleanRemoteEntityCaches provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) { + _m.Called(remoteAddress) +} + +// FeatureLocalInterface_CleanRemoteEntityCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanRemoteEntityCaches' +type FeatureLocalInterface_CleanRemoteEntityCaches_Call struct { + *mock.Call +} + +// CleanRemoteEntityCaches is a helper method to define mock.On call +// - remoteAddress *model.EntityAddressType +func (_e *FeatureLocalInterface_Expecter) CleanRemoteEntityCaches(remoteAddress interface{}) *FeatureLocalInterface_CleanRemoteEntityCaches_Call { + return &FeatureLocalInterface_CleanRemoteEntityCaches_Call{Call: _e.mock.On("CleanRemoteEntityCaches", remoteAddress)} +} + +func (_c *FeatureLocalInterface_CleanRemoteEntityCaches_Call) Run(run func(remoteAddress *model.EntityAddressType)) *FeatureLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.EntityAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_CleanRemoteEntityCaches_Call) Return() *FeatureLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_CleanRemoteEntityCaches_Call) RunAndReturn(run func(*model.EntityAddressType)) *FeatureLocalInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return(run) + return _c +} + +// CleanWriteApprovalCaches provides a mock function with given fields: ski +func (_m *FeatureLocalInterface) CleanWriteApprovalCaches(ski string) { + _m.Called(ski) +} + +// FeatureLocalInterface_CleanWriteApprovalCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanWriteApprovalCaches' +type FeatureLocalInterface_CleanWriteApprovalCaches_Call struct { + *mock.Call +} + +// CleanWriteApprovalCaches is a helper method to define mock.On call +// - ski string +func (_e *FeatureLocalInterface_Expecter) CleanWriteApprovalCaches(ski interface{}) *FeatureLocalInterface_CleanWriteApprovalCaches_Call { + return &FeatureLocalInterface_CleanWriteApprovalCaches_Call{Call: _e.mock.On("CleanWriteApprovalCaches", ski)} +} + +func (_c *FeatureLocalInterface_CleanWriteApprovalCaches_Call) Run(run func(ski string)) *FeatureLocalInterface_CleanWriteApprovalCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *FeatureLocalInterface_CleanWriteApprovalCaches_Call) Return() *FeatureLocalInterface_CleanWriteApprovalCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_CleanWriteApprovalCaches_Call) RunAndReturn(run func(string)) *FeatureLocalInterface_CleanWriteApprovalCaches_Call { + _c.Call.Return(run) + return _c +} + +// DataCopy provides a mock function with given fields: function +func (_m *FeatureLocalInterface) DataCopy(function model.FunctionType) interface{} { + ret := _m.Called(function) + + if len(ret) == 0 { + panic("no return value specified for DataCopy") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func(model.FunctionType) interface{}); ok { + r0 = rf(function) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// FeatureLocalInterface_DataCopy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DataCopy' +type FeatureLocalInterface_DataCopy_Call struct { + *mock.Call +} + +// DataCopy is a helper method to define mock.On call +// - function model.FunctionType +func (_e *FeatureLocalInterface_Expecter) DataCopy(function interface{}) *FeatureLocalInterface_DataCopy_Call { + return &FeatureLocalInterface_DataCopy_Call{Call: _e.mock.On("DataCopy", function)} +} + +func (_c *FeatureLocalInterface_DataCopy_Call) Run(run func(function model.FunctionType)) *FeatureLocalInterface_DataCopy_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_DataCopy_Call) Return(_a0 interface{}) *FeatureLocalInterface_DataCopy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_DataCopy_Call) RunAndReturn(run func(model.FunctionType) interface{}) *FeatureLocalInterface_DataCopy_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *FeatureLocalInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// FeatureLocalInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type FeatureLocalInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Description() *FeatureLocalInterface_Description_Call { + return &FeatureLocalInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *FeatureLocalInterface_Description_Call) Run(run func()) *FeatureLocalInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Description_Call) Return(_a0 *model.DescriptionType) *FeatureLocalInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *FeatureLocalInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Device provides a mock function with given fields: +func (_m *FeatureLocalInterface) Device() api.DeviceLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Device") + } + + var r0 api.DeviceLocalInterface + if rf, ok := ret.Get(0).(func() api.DeviceLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceLocalInterface) + } + } + + return r0 +} + +// FeatureLocalInterface_Device_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Device' +type FeatureLocalInterface_Device_Call struct { + *mock.Call +} + +// Device is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Device() *FeatureLocalInterface_Device_Call { + return &FeatureLocalInterface_Device_Call{Call: _e.mock.On("Device")} +} + +func (_c *FeatureLocalInterface_Device_Call) Run(run func()) *FeatureLocalInterface_Device_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Device_Call) Return(_a0 api.DeviceLocalInterface) *FeatureLocalInterface_Device_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Device_Call) RunAndReturn(run func() api.DeviceLocalInterface) *FeatureLocalInterface_Device_Call { + _c.Call.Return(run) + return _c +} + +// Entity provides a mock function with given fields: +func (_m *FeatureLocalInterface) Entity() api.EntityLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Entity") + } + + var r0 api.EntityLocalInterface + if rf, ok := ret.Get(0).(func() api.EntityLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityLocalInterface) + } + } + + return r0 +} + +// FeatureLocalInterface_Entity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entity' +type FeatureLocalInterface_Entity_Call struct { + *mock.Call +} + +// Entity is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Entity() *FeatureLocalInterface_Entity_Call { + return &FeatureLocalInterface_Entity_Call{Call: _e.mock.On("Entity")} +} + +func (_c *FeatureLocalInterface_Entity_Call) Run(run func()) *FeatureLocalInterface_Entity_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Entity_Call) Return(_a0 api.EntityLocalInterface) *FeatureLocalInterface_Entity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Entity_Call) RunAndReturn(run func() api.EntityLocalInterface) *FeatureLocalInterface_Entity_Call { + _c.Call.Return(run) + return _c +} + +// Functions provides a mock function with given fields: +func (_m *FeatureLocalInterface) Functions() []model.FunctionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Functions") + } + + var r0 []model.FunctionType + if rf, ok := ret.Get(0).(func() []model.FunctionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.FunctionType) + } + } + + return r0 +} + +// FeatureLocalInterface_Functions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Functions' +type FeatureLocalInterface_Functions_Call struct { + *mock.Call +} + +// Functions is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Functions() *FeatureLocalInterface_Functions_Call { + return &FeatureLocalInterface_Functions_Call{Call: _e.mock.On("Functions")} +} + +func (_c *FeatureLocalInterface_Functions_Call) Run(run func()) *FeatureLocalInterface_Functions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Functions_Call) Return(_a0 []model.FunctionType) *FeatureLocalInterface_Functions_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Functions_Call) RunAndReturn(run func() []model.FunctionType) *FeatureLocalInterface_Functions_Call { + _c.Call.Return(run) + return _c +} + +// HandleMessage provides a mock function with given fields: message +func (_m *FeatureLocalInterface) HandleMessage(message *api.Message) *model.ErrorType { + ret := _m.Called(message) + + if len(ret) == 0 { + panic("no return value specified for HandleMessage") + } + + var r0 *model.ErrorType + if rf, ok := ret.Get(0).(func(*api.Message) *model.ErrorType); ok { + r0 = rf(message) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ErrorType) + } + } + + return r0 +} + +// FeatureLocalInterface_HandleMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleMessage' +type FeatureLocalInterface_HandleMessage_Call struct { + *mock.Call +} + +// HandleMessage is a helper method to define mock.On call +// - message *api.Message +func (_e *FeatureLocalInterface_Expecter) HandleMessage(message interface{}) *FeatureLocalInterface_HandleMessage_Call { + return &FeatureLocalInterface_HandleMessage_Call{Call: _e.mock.On("HandleMessage", message)} +} + +func (_c *FeatureLocalInterface_HandleMessage_Call) Run(run func(message *api.Message)) *FeatureLocalInterface_HandleMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*api.Message)) + }) + return _c +} + +func (_c *FeatureLocalInterface_HandleMessage_Call) Return(_a0 *model.ErrorType) *FeatureLocalInterface_HandleMessage_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_HandleMessage_Call) RunAndReturn(run func(*api.Message) *model.ErrorType) *FeatureLocalInterface_HandleMessage_Call { + _c.Call.Return(run) + return _c +} + +// HasBindingToRemote provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) HasBindingToRemote(remoteAddress *model.FeatureAddressType) bool { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for HasBindingToRemote") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) bool); ok { + r0 = rf(remoteAddress) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureLocalInterface_HasBindingToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasBindingToRemote' +type FeatureLocalInterface_HasBindingToRemote_Call struct { + *mock.Call +} + +// HasBindingToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) HasBindingToRemote(remoteAddress interface{}) *FeatureLocalInterface_HasBindingToRemote_Call { + return &FeatureLocalInterface_HasBindingToRemote_Call{Call: _e.mock.On("HasBindingToRemote", remoteAddress)} +} + +func (_c *FeatureLocalInterface_HasBindingToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_HasBindingToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_HasBindingToRemote_Call) Return(_a0 bool) *FeatureLocalInterface_HasBindingToRemote_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_HasBindingToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) bool) *FeatureLocalInterface_HasBindingToRemote_Call { + _c.Call.Return(run) + return _c +} + +// HasSubscriptionToRemote provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) HasSubscriptionToRemote(remoteAddress *model.FeatureAddressType) bool { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for HasSubscriptionToRemote") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) bool); ok { + r0 = rf(remoteAddress) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FeatureLocalInterface_HasSubscriptionToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasSubscriptionToRemote' +type FeatureLocalInterface_HasSubscriptionToRemote_Call struct { + *mock.Call +} + +// HasSubscriptionToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) HasSubscriptionToRemote(remoteAddress interface{}) *FeatureLocalInterface_HasSubscriptionToRemote_Call { + return &FeatureLocalInterface_HasSubscriptionToRemote_Call{Call: _e.mock.On("HasSubscriptionToRemote", remoteAddress)} +} + +func (_c *FeatureLocalInterface_HasSubscriptionToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_HasSubscriptionToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_HasSubscriptionToRemote_Call) Return(_a0 bool) *FeatureLocalInterface_HasSubscriptionToRemote_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_HasSubscriptionToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) bool) *FeatureLocalInterface_HasSubscriptionToRemote_Call { + _c.Call.Return(run) + return _c +} + +// Information provides a mock function with given fields: +func (_m *FeatureLocalInterface) Information() *model.NodeManagementDetailedDiscoveryFeatureInformationType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Information") + } + + var r0 *model.NodeManagementDetailedDiscoveryFeatureInformationType + if rf, ok := ret.Get(0).(func() *model.NodeManagementDetailedDiscoveryFeatureInformationType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NodeManagementDetailedDiscoveryFeatureInformationType) + } + } + + return r0 +} + +// FeatureLocalInterface_Information_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Information' +type FeatureLocalInterface_Information_Call struct { + *mock.Call +} + +// Information is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Information() *FeatureLocalInterface_Information_Call { + return &FeatureLocalInterface_Information_Call{Call: _e.mock.On("Information")} +} + +func (_c *FeatureLocalInterface_Information_Call) Run(run func()) *FeatureLocalInterface_Information_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Information_Call) Return(_a0 *model.NodeManagementDetailedDiscoveryFeatureInformationType) *FeatureLocalInterface_Information_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Information_Call) RunAndReturn(run func() *model.NodeManagementDetailedDiscoveryFeatureInformationType) *FeatureLocalInterface_Information_Call { + _c.Call.Return(run) + return _c +} + +// Operations provides a mock function with given fields: +func (_m *FeatureLocalInterface) Operations() map[model.FunctionType]api.OperationsInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Operations") + } + + var r0 map[model.FunctionType]api.OperationsInterface + if rf, ok := ret.Get(0).(func() map[model.FunctionType]api.OperationsInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.FunctionType]api.OperationsInterface) + } + } + + return r0 +} + +// FeatureLocalInterface_Operations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operations' +type FeatureLocalInterface_Operations_Call struct { + *mock.Call +} + +// Operations is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Operations() *FeatureLocalInterface_Operations_Call { + return &FeatureLocalInterface_Operations_Call{Call: _e.mock.On("Operations")} +} + +func (_c *FeatureLocalInterface_Operations_Call) Run(run func()) *FeatureLocalInterface_Operations_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Operations_Call) Return(_a0 map[model.FunctionType]api.OperationsInterface) *FeatureLocalInterface_Operations_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Operations_Call) RunAndReturn(run func() map[model.FunctionType]api.OperationsInterface) *FeatureLocalInterface_Operations_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllRemoteBindings provides a mock function with given fields: +func (_m *FeatureLocalInterface) RemoveAllRemoteBindings() { + _m.Called() +} + +// FeatureLocalInterface_RemoveAllRemoteBindings_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllRemoteBindings' +type FeatureLocalInterface_RemoveAllRemoteBindings_Call struct { + *mock.Call +} + +// RemoveAllRemoteBindings is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) RemoveAllRemoteBindings() *FeatureLocalInterface_RemoveAllRemoteBindings_Call { + return &FeatureLocalInterface_RemoveAllRemoteBindings_Call{Call: _e.mock.On("RemoveAllRemoteBindings")} +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteBindings_Call) Run(run func()) *FeatureLocalInterface_RemoveAllRemoteBindings_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteBindings_Call) Return() *FeatureLocalInterface_RemoveAllRemoteBindings_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteBindings_Call) RunAndReturn(run func()) *FeatureLocalInterface_RemoveAllRemoteBindings_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllRemoteSubscriptions provides a mock function with given fields: +func (_m *FeatureLocalInterface) RemoveAllRemoteSubscriptions() { + _m.Called() +} + +// FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllRemoteSubscriptions' +type FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call struct { + *mock.Call +} + +// RemoveAllRemoteSubscriptions is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) RemoveAllRemoteSubscriptions() *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call { + return &FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call{Call: _e.mock.On("RemoveAllRemoteSubscriptions")} +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call) Run(run func()) *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call) Return() *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call) RunAndReturn(run func()) *FeatureLocalInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteBinding provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) RemoveRemoteBinding(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for RemoveRemoteBinding") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_RemoveRemoteBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteBinding' +type FeatureLocalInterface_RemoveRemoteBinding_Call struct { + *mock.Call +} + +// RemoveRemoteBinding is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) RemoveRemoteBinding(remoteAddress interface{}) *FeatureLocalInterface_RemoveRemoteBinding_Call { + return &FeatureLocalInterface_RemoveRemoteBinding_Call{Call: _e.mock.On("RemoveRemoteBinding", remoteAddress)} +} + +func (_c *FeatureLocalInterface_RemoveRemoteBinding_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_RemoveRemoteBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_RemoveRemoteBinding_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_RemoveRemoteBinding_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_RemoveRemoteBinding_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_RemoveRemoteBinding_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteSubscription provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) RemoveRemoteSubscription(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for RemoveRemoteSubscription") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_RemoveRemoteSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteSubscription' +type FeatureLocalInterface_RemoveRemoteSubscription_Call struct { + *mock.Call +} + +// RemoveRemoteSubscription is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) RemoveRemoteSubscription(remoteAddress interface{}) *FeatureLocalInterface_RemoveRemoteSubscription_Call { + return &FeatureLocalInterface_RemoveRemoteSubscription_Call{Call: _e.mock.On("RemoveRemoteSubscription", remoteAddress)} +} + +func (_c *FeatureLocalInterface_RemoveRemoteSubscription_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_RemoveRemoteSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_RemoveRemoteSubscription_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_RemoveRemoteSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_RemoveRemoteSubscription_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_RemoveRemoteSubscription_Call { + _c.Call.Return(run) + return _c +} + +// RequestRemoteData provides a mock function with given fields: function, selector, elements, destination +func (_m *FeatureLocalInterface) RequestRemoteData(function model.FunctionType, selector interface{}, elements interface{}, destination api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(function, selector, elements, destination) + + if len(ret) == 0 { + panic("no return value specified for RequestRemoteData") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(function, selector, elements, destination) + } + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) *model.MsgCounterType); ok { + r0 = rf(function, selector, elements, destination) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) *model.ErrorType); ok { + r1 = rf(function, selector, elements, destination) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_RequestRemoteData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestRemoteData' +type FeatureLocalInterface_RequestRemoteData_Call struct { + *mock.Call +} + +// RequestRemoteData is a helper method to define mock.On call +// - function model.FunctionType +// - selector interface{} +// - elements interface{} +// - destination api.FeatureRemoteInterface +func (_e *FeatureLocalInterface_Expecter) RequestRemoteData(function interface{}, selector interface{}, elements interface{}, destination interface{}) *FeatureLocalInterface_RequestRemoteData_Call { + return &FeatureLocalInterface_RequestRemoteData_Call{Call: _e.mock.On("RequestRemoteData", function, selector, elements, destination)} +} + +func (_c *FeatureLocalInterface_RequestRemoteData_Call) Run(run func(function model.FunctionType, selector interface{}, elements interface{}, destination api.FeatureRemoteInterface)) *FeatureLocalInterface_RequestRemoteData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{}), args[2].(interface{}), args[3].(api.FeatureRemoteInterface)) + }) + return _c +} + +func (_c *FeatureLocalInterface_RequestRemoteData_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_RequestRemoteData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_RequestRemoteData_Call) RunAndReturn(run func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_RequestRemoteData_Call { + _c.Call.Return(run) + return _c +} + +// RequestRemoteDataBySenderAddress provides a mock function with given fields: cmd, sender, destinationSki, destinationAddress, maxDelay +func (_m *FeatureLocalInterface) RequestRemoteDataBySenderAddress(cmd model.CmdType, sender api.SenderInterface, destinationSki string, destinationAddress *model.FeatureAddressType, maxDelay time.Duration) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(cmd, sender, destinationSki, destinationAddress, maxDelay) + + if len(ret) == 0 { + panic("no return value specified for RequestRemoteDataBySenderAddress") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } + if rf, ok := ret.Get(0).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) *model.MsgCounterType); ok { + r0 = rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) *model.ErrorType); ok { + r1 = rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestRemoteDataBySenderAddress' +type FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call struct { + *mock.Call +} + +// RequestRemoteDataBySenderAddress is a helper method to define mock.On call +// - cmd model.CmdType +// - sender api.SenderInterface +// - destinationSki string +// - destinationAddress *model.FeatureAddressType +// - maxDelay time.Duration +func (_e *FeatureLocalInterface_Expecter) RequestRemoteDataBySenderAddress(cmd interface{}, sender interface{}, destinationSki interface{}, destinationAddress interface{}, maxDelay interface{}) *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call { + return &FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call{Call: _e.mock.On("RequestRemoteDataBySenderAddress", cmd, sender, destinationSki, destinationAddress, maxDelay)} +} + +func (_c *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call) Run(run func(cmd model.CmdType, sender api.SenderInterface, destinationSki string, destinationAddress *model.FeatureAddressType, maxDelay time.Duration)) *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.CmdType), args[1].(api.SenderInterface), args[2].(string), args[3].(*model.FeatureAddressType), args[4].(time.Duration)) + }) + return _c +} + +func (_c *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call) RunAndReturn(run func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Return(run) + return _c +} + +// Role provides a mock function with given fields: +func (_m *FeatureLocalInterface) Role() model.RoleType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Role") + } + + var r0 model.RoleType + if rf, ok := ret.Get(0).(func() model.RoleType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.RoleType) + } + + return r0 +} + +// FeatureLocalInterface_Role_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Role' +type FeatureLocalInterface_Role_Call struct { + *mock.Call +} + +// Role is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Role() *FeatureLocalInterface_Role_Call { + return &FeatureLocalInterface_Role_Call{Call: _e.mock.On("Role")} +} + +func (_c *FeatureLocalInterface_Role_Call) Run(run func()) *FeatureLocalInterface_Role_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Role_Call) Return(_a0 model.RoleType) *FeatureLocalInterface_Role_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Role_Call) RunAndReturn(run func() model.RoleType) *FeatureLocalInterface_Role_Call { + _c.Call.Return(run) + return _c +} + +// SetData provides a mock function with given fields: function, data +func (_m *FeatureLocalInterface) SetData(function model.FunctionType, data interface{}) { + _m.Called(function, data) +} + +// FeatureLocalInterface_SetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetData' +type FeatureLocalInterface_SetData_Call struct { + *mock.Call +} + +// SetData is a helper method to define mock.On call +// - function model.FunctionType +// - data interface{} +func (_e *FeatureLocalInterface_Expecter) SetData(function interface{}, data interface{}) *FeatureLocalInterface_SetData_Call { + return &FeatureLocalInterface_SetData_Call{Call: _e.mock.On("SetData", function, data)} +} + +func (_c *FeatureLocalInterface_SetData_Call) Run(run func(function model.FunctionType, data interface{})) *FeatureLocalInterface_SetData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{})) + }) + return _c +} + +func (_c *FeatureLocalInterface_SetData_Call) Return() *FeatureLocalInterface_SetData_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_SetData_Call) RunAndReturn(run func(model.FunctionType, interface{})) *FeatureLocalInterface_SetData_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: desc +func (_m *FeatureLocalInterface) SetDescription(desc *model.DescriptionType) { + _m.Called(desc) +} + +// FeatureLocalInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type FeatureLocalInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - desc *model.DescriptionType +func (_e *FeatureLocalInterface_Expecter) SetDescription(desc interface{}) *FeatureLocalInterface_SetDescription_Call { + return &FeatureLocalInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", desc)} +} + +func (_c *FeatureLocalInterface_SetDescription_Call) Run(run func(desc *model.DescriptionType)) *FeatureLocalInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_SetDescription_Call) Return() *FeatureLocalInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *FeatureLocalInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// SetDescriptionString provides a mock function with given fields: s +func (_m *FeatureLocalInterface) SetDescriptionString(s string) { + _m.Called(s) +} + +// FeatureLocalInterface_SetDescriptionString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescriptionString' +type FeatureLocalInterface_SetDescriptionString_Call struct { + *mock.Call +} + +// SetDescriptionString is a helper method to define mock.On call +// - s string +func (_e *FeatureLocalInterface_Expecter) SetDescriptionString(s interface{}) *FeatureLocalInterface_SetDescriptionString_Call { + return &FeatureLocalInterface_SetDescriptionString_Call{Call: _e.mock.On("SetDescriptionString", s)} +} + +func (_c *FeatureLocalInterface_SetDescriptionString_Call) Run(run func(s string)) *FeatureLocalInterface_SetDescriptionString_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *FeatureLocalInterface_SetDescriptionString_Call) Return() *FeatureLocalInterface_SetDescriptionString_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_SetDescriptionString_Call) RunAndReturn(run func(string)) *FeatureLocalInterface_SetDescriptionString_Call { + _c.Call.Return(run) + return _c +} + +// SetWriteApprovalTimeout provides a mock function with given fields: duration +func (_m *FeatureLocalInterface) SetWriteApprovalTimeout(duration time.Duration) { + _m.Called(duration) +} + +// FeatureLocalInterface_SetWriteApprovalTimeout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetWriteApprovalTimeout' +type FeatureLocalInterface_SetWriteApprovalTimeout_Call struct { + *mock.Call +} + +// SetWriteApprovalTimeout is a helper method to define mock.On call +// - duration time.Duration +func (_e *FeatureLocalInterface_Expecter) SetWriteApprovalTimeout(duration interface{}) *FeatureLocalInterface_SetWriteApprovalTimeout_Call { + return &FeatureLocalInterface_SetWriteApprovalTimeout_Call{Call: _e.mock.On("SetWriteApprovalTimeout", duration)} +} + +func (_c *FeatureLocalInterface_SetWriteApprovalTimeout_Call) Run(run func(duration time.Duration)) *FeatureLocalInterface_SetWriteApprovalTimeout_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration)) + }) + return _c +} + +func (_c *FeatureLocalInterface_SetWriteApprovalTimeout_Call) Return() *FeatureLocalInterface_SetWriteApprovalTimeout_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureLocalInterface_SetWriteApprovalTimeout_Call) RunAndReturn(run func(time.Duration)) *FeatureLocalInterface_SetWriteApprovalTimeout_Call { + _c.Call.Return(run) + return _c +} + +// String provides a mock function with given fields: +func (_m *FeatureLocalInterface) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// FeatureLocalInterface_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' +type FeatureLocalInterface_String_Call struct { + *mock.Call +} + +// String is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) String() *FeatureLocalInterface_String_Call { + return &FeatureLocalInterface_String_Call{Call: _e.mock.On("String")} +} + +func (_c *FeatureLocalInterface_String_Call) Run(run func()) *FeatureLocalInterface_String_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_String_Call) Return(_a0 string) *FeatureLocalInterface_String_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_String_Call) RunAndReturn(run func() string) *FeatureLocalInterface_String_Call { + _c.Call.Return(run) + return _c +} + +// SubscribeToRemote provides a mock function with given fields: remoteAddress +func (_m *FeatureLocalInterface) SubscribeToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for SubscribeToRemote") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureLocalInterface_SubscribeToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeToRemote' +type FeatureLocalInterface_SubscribeToRemote_Call struct { + *mock.Call +} + +// SubscribeToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *FeatureLocalInterface_Expecter) SubscribeToRemote(remoteAddress interface{}) *FeatureLocalInterface_SubscribeToRemote_Call { + return &FeatureLocalInterface_SubscribeToRemote_Call{Call: _e.mock.On("SubscribeToRemote", remoteAddress)} +} + +func (_c *FeatureLocalInterface_SubscribeToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *FeatureLocalInterface_SubscribeToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_SubscribeToRemote_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *FeatureLocalInterface_SubscribeToRemote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureLocalInterface_SubscribeToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *FeatureLocalInterface_SubscribeToRemote_Call { + _c.Call.Return(run) + return _c +} + +// Type provides a mock function with given fields: +func (_m *FeatureLocalInterface) Type() model.FeatureTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Type") + } + + var r0 model.FeatureTypeType + if rf, ok := ret.Get(0).(func() model.FeatureTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FeatureTypeType) + } + + return r0 +} + +// FeatureLocalInterface_Type_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Type' +type FeatureLocalInterface_Type_Call struct { + *mock.Call +} + +// Type is a helper method to define mock.On call +func (_e *FeatureLocalInterface_Expecter) Type() *FeatureLocalInterface_Type_Call { + return &FeatureLocalInterface_Type_Call{Call: _e.mock.On("Type")} +} + +func (_c *FeatureLocalInterface_Type_Call) Run(run func()) *FeatureLocalInterface_Type_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureLocalInterface_Type_Call) Return(_a0 model.FeatureTypeType) *FeatureLocalInterface_Type_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_Type_Call) RunAndReturn(run func() model.FeatureTypeType) *FeatureLocalInterface_Type_Call { + _c.Call.Return(run) + return _c +} + +// UpdateData provides a mock function with given fields: function, data, filterPartial, filterDelete +func (_m *FeatureLocalInterface) UpdateData(function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType) *model.ErrorType { + ret := _m.Called(function, data, filterPartial, filterDelete) + + if len(ret) == 0 { + panic("no return value specified for UpdateData") + } + + var r0 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType); ok { + r0 = rf(function, data, filterPartial, filterDelete) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ErrorType) + } + } + + return r0 +} + +// FeatureLocalInterface_UpdateData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateData' +type FeatureLocalInterface_UpdateData_Call struct { + *mock.Call +} + +// UpdateData is a helper method to define mock.On call +// - function model.FunctionType +// - data interface{} +// - filterPartial *model.FilterType +// - filterDelete *model.FilterType +func (_e *FeatureLocalInterface_Expecter) UpdateData(function interface{}, data interface{}, filterPartial interface{}, filterDelete interface{}) *FeatureLocalInterface_UpdateData_Call { + return &FeatureLocalInterface_UpdateData_Call{Call: _e.mock.On("UpdateData", function, data, filterPartial, filterDelete)} +} + +func (_c *FeatureLocalInterface_UpdateData_Call) Run(run func(function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType)) *FeatureLocalInterface_UpdateData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{}), args[2].(*model.FilterType), args[3].(*model.FilterType)) + }) + return _c +} + +func (_c *FeatureLocalInterface_UpdateData_Call) Return(_a0 *model.ErrorType) *FeatureLocalInterface_UpdateData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureLocalInterface_UpdateData_Call) RunAndReturn(run func(model.FunctionType, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType) *FeatureLocalInterface_UpdateData_Call { + _c.Call.Return(run) + return _c +} + +// NewFeatureLocalInterface creates a new instance of FeatureLocalInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureLocalInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureLocalInterface { + mock := &FeatureLocalInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/FeatureRemoteInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/FeatureRemoteInterface.go new file mode 100644 index 0000000..dcb4418 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/FeatureRemoteInterface.go @@ -0,0 +1,698 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + time "time" +) + +// FeatureRemoteInterface is an autogenerated mock type for the FeatureRemoteInterface type +type FeatureRemoteInterface struct { + mock.Mock +} + +type FeatureRemoteInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FeatureRemoteInterface) EXPECT() *FeatureRemoteInterface_Expecter { + return &FeatureRemoteInterface_Expecter{mock: &_m.Mock} +} + +// Address provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Address() *model.FeatureAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.FeatureAddressType + if rf, ok := ret.Get(0).(func() *model.FeatureAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.FeatureAddressType) + } + } + + return r0 +} + +// FeatureRemoteInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type FeatureRemoteInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Address() *FeatureRemoteInterface_Address_Call { + return &FeatureRemoteInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *FeatureRemoteInterface_Address_Call) Run(run func()) *FeatureRemoteInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Address_Call) Return(_a0 *model.FeatureAddressType) *FeatureRemoteInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Address_Call) RunAndReturn(run func() *model.FeatureAddressType) *FeatureRemoteInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// DataCopy provides a mock function with given fields: function +func (_m *FeatureRemoteInterface) DataCopy(function model.FunctionType) interface{} { + ret := _m.Called(function) + + if len(ret) == 0 { + panic("no return value specified for DataCopy") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func(model.FunctionType) interface{}); ok { + r0 = rf(function) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// FeatureRemoteInterface_DataCopy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DataCopy' +type FeatureRemoteInterface_DataCopy_Call struct { + *mock.Call +} + +// DataCopy is a helper method to define mock.On call +// - function model.FunctionType +func (_e *FeatureRemoteInterface_Expecter) DataCopy(function interface{}) *FeatureRemoteInterface_DataCopy_Call { + return &FeatureRemoteInterface_DataCopy_Call{Call: _e.mock.On("DataCopy", function)} +} + +func (_c *FeatureRemoteInterface_DataCopy_Call) Run(run func(function model.FunctionType)) *FeatureRemoteInterface_DataCopy_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_DataCopy_Call) Return(_a0 interface{}) *FeatureRemoteInterface_DataCopy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_DataCopy_Call) RunAndReturn(run func(model.FunctionType) interface{}) *FeatureRemoteInterface_DataCopy_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// FeatureRemoteInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type FeatureRemoteInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Description() *FeatureRemoteInterface_Description_Call { + return &FeatureRemoteInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *FeatureRemoteInterface_Description_Call) Run(run func()) *FeatureRemoteInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Description_Call) Return(_a0 *model.DescriptionType) *FeatureRemoteInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *FeatureRemoteInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Device provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Device() api.DeviceRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Device") + } + + var r0 api.DeviceRemoteInterface + if rf, ok := ret.Get(0).(func() api.DeviceRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceRemoteInterface) + } + } + + return r0 +} + +// FeatureRemoteInterface_Device_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Device' +type FeatureRemoteInterface_Device_Call struct { + *mock.Call +} + +// Device is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Device() *FeatureRemoteInterface_Device_Call { + return &FeatureRemoteInterface_Device_Call{Call: _e.mock.On("Device")} +} + +func (_c *FeatureRemoteInterface_Device_Call) Run(run func()) *FeatureRemoteInterface_Device_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Device_Call) Return(_a0 api.DeviceRemoteInterface) *FeatureRemoteInterface_Device_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Device_Call) RunAndReturn(run func() api.DeviceRemoteInterface) *FeatureRemoteInterface_Device_Call { + _c.Call.Return(run) + return _c +} + +// Entity provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Entity() api.EntityRemoteInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Entity") + } + + var r0 api.EntityRemoteInterface + if rf, ok := ret.Get(0).(func() api.EntityRemoteInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityRemoteInterface) + } + } + + return r0 +} + +// FeatureRemoteInterface_Entity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entity' +type FeatureRemoteInterface_Entity_Call struct { + *mock.Call +} + +// Entity is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Entity() *FeatureRemoteInterface_Entity_Call { + return &FeatureRemoteInterface_Entity_Call{Call: _e.mock.On("Entity")} +} + +func (_c *FeatureRemoteInterface_Entity_Call) Run(run func()) *FeatureRemoteInterface_Entity_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Entity_Call) Return(_a0 api.EntityRemoteInterface) *FeatureRemoteInterface_Entity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Entity_Call) RunAndReturn(run func() api.EntityRemoteInterface) *FeatureRemoteInterface_Entity_Call { + _c.Call.Return(run) + return _c +} + +// MaxResponseDelayDuration provides a mock function with given fields: +func (_m *FeatureRemoteInterface) MaxResponseDelayDuration() time.Duration { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for MaxResponseDelayDuration") + } + + var r0 time.Duration + if rf, ok := ret.Get(0).(func() time.Duration); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(time.Duration) + } + + return r0 +} + +// FeatureRemoteInterface_MaxResponseDelayDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MaxResponseDelayDuration' +type FeatureRemoteInterface_MaxResponseDelayDuration_Call struct { + *mock.Call +} + +// MaxResponseDelayDuration is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) MaxResponseDelayDuration() *FeatureRemoteInterface_MaxResponseDelayDuration_Call { + return &FeatureRemoteInterface_MaxResponseDelayDuration_Call{Call: _e.mock.On("MaxResponseDelayDuration")} +} + +func (_c *FeatureRemoteInterface_MaxResponseDelayDuration_Call) Run(run func()) *FeatureRemoteInterface_MaxResponseDelayDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_MaxResponseDelayDuration_Call) Return(_a0 time.Duration) *FeatureRemoteInterface_MaxResponseDelayDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_MaxResponseDelayDuration_Call) RunAndReturn(run func() time.Duration) *FeatureRemoteInterface_MaxResponseDelayDuration_Call { + _c.Call.Return(run) + return _c +} + +// Operations provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Operations() map[model.FunctionType]api.OperationsInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Operations") + } + + var r0 map[model.FunctionType]api.OperationsInterface + if rf, ok := ret.Get(0).(func() map[model.FunctionType]api.OperationsInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.FunctionType]api.OperationsInterface) + } + } + + return r0 +} + +// FeatureRemoteInterface_Operations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operations' +type FeatureRemoteInterface_Operations_Call struct { + *mock.Call +} + +// Operations is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Operations() *FeatureRemoteInterface_Operations_Call { + return &FeatureRemoteInterface_Operations_Call{Call: _e.mock.On("Operations")} +} + +func (_c *FeatureRemoteInterface_Operations_Call) Run(run func()) *FeatureRemoteInterface_Operations_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Operations_Call) Return(_a0 map[model.FunctionType]api.OperationsInterface) *FeatureRemoteInterface_Operations_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Operations_Call) RunAndReturn(run func() map[model.FunctionType]api.OperationsInterface) *FeatureRemoteInterface_Operations_Call { + _c.Call.Return(run) + return _c +} + +// Role provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Role() model.RoleType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Role") + } + + var r0 model.RoleType + if rf, ok := ret.Get(0).(func() model.RoleType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.RoleType) + } + + return r0 +} + +// FeatureRemoteInterface_Role_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Role' +type FeatureRemoteInterface_Role_Call struct { + *mock.Call +} + +// Role is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Role() *FeatureRemoteInterface_Role_Call { + return &FeatureRemoteInterface_Role_Call{Call: _e.mock.On("Role")} +} + +func (_c *FeatureRemoteInterface_Role_Call) Run(run func()) *FeatureRemoteInterface_Role_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Role_Call) Return(_a0 model.RoleType) *FeatureRemoteInterface_Role_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Role_Call) RunAndReturn(run func() model.RoleType) *FeatureRemoteInterface_Role_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: desc +func (_m *FeatureRemoteInterface) SetDescription(desc *model.DescriptionType) { + _m.Called(desc) +} + +// FeatureRemoteInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type FeatureRemoteInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - desc *model.DescriptionType +func (_e *FeatureRemoteInterface_Expecter) SetDescription(desc interface{}) *FeatureRemoteInterface_SetDescription_Call { + return &FeatureRemoteInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", desc)} +} + +func (_c *FeatureRemoteInterface_SetDescription_Call) Run(run func(desc *model.DescriptionType)) *FeatureRemoteInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_SetDescription_Call) Return() *FeatureRemoteInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureRemoteInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *FeatureRemoteInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// SetDescriptionString provides a mock function with given fields: s +func (_m *FeatureRemoteInterface) SetDescriptionString(s string) { + _m.Called(s) +} + +// FeatureRemoteInterface_SetDescriptionString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescriptionString' +type FeatureRemoteInterface_SetDescriptionString_Call struct { + *mock.Call +} + +// SetDescriptionString is a helper method to define mock.On call +// - s string +func (_e *FeatureRemoteInterface_Expecter) SetDescriptionString(s interface{}) *FeatureRemoteInterface_SetDescriptionString_Call { + return &FeatureRemoteInterface_SetDescriptionString_Call{Call: _e.mock.On("SetDescriptionString", s)} +} + +func (_c *FeatureRemoteInterface_SetDescriptionString_Call) Run(run func(s string)) *FeatureRemoteInterface_SetDescriptionString_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_SetDescriptionString_Call) Return() *FeatureRemoteInterface_SetDescriptionString_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureRemoteInterface_SetDescriptionString_Call) RunAndReturn(run func(string)) *FeatureRemoteInterface_SetDescriptionString_Call { + _c.Call.Return(run) + return _c +} + +// SetMaxResponseDelay provides a mock function with given fields: delay +func (_m *FeatureRemoteInterface) SetMaxResponseDelay(delay *model.MaxResponseDelayType) { + _m.Called(delay) +} + +// FeatureRemoteInterface_SetMaxResponseDelay_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMaxResponseDelay' +type FeatureRemoteInterface_SetMaxResponseDelay_Call struct { + *mock.Call +} + +// SetMaxResponseDelay is a helper method to define mock.On call +// - delay *model.MaxResponseDelayType +func (_e *FeatureRemoteInterface_Expecter) SetMaxResponseDelay(delay interface{}) *FeatureRemoteInterface_SetMaxResponseDelay_Call { + return &FeatureRemoteInterface_SetMaxResponseDelay_Call{Call: _e.mock.On("SetMaxResponseDelay", delay)} +} + +func (_c *FeatureRemoteInterface_SetMaxResponseDelay_Call) Run(run func(delay *model.MaxResponseDelayType)) *FeatureRemoteInterface_SetMaxResponseDelay_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.MaxResponseDelayType)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_SetMaxResponseDelay_Call) Return() *FeatureRemoteInterface_SetMaxResponseDelay_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureRemoteInterface_SetMaxResponseDelay_Call) RunAndReturn(run func(*model.MaxResponseDelayType)) *FeatureRemoteInterface_SetMaxResponseDelay_Call { + _c.Call.Return(run) + return _c +} + +// SetOperations provides a mock function with given fields: functions +func (_m *FeatureRemoteInterface) SetOperations(functions []model.FunctionPropertyType) { + _m.Called(functions) +} + +// FeatureRemoteInterface_SetOperations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOperations' +type FeatureRemoteInterface_SetOperations_Call struct { + *mock.Call +} + +// SetOperations is a helper method to define mock.On call +// - functions []model.FunctionPropertyType +func (_e *FeatureRemoteInterface_Expecter) SetOperations(functions interface{}) *FeatureRemoteInterface_SetOperations_Call { + return &FeatureRemoteInterface_SetOperations_Call{Call: _e.mock.On("SetOperations", functions)} +} + +func (_c *FeatureRemoteInterface_SetOperations_Call) Run(run func(functions []model.FunctionPropertyType)) *FeatureRemoteInterface_SetOperations_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]model.FunctionPropertyType)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_SetOperations_Call) Return() *FeatureRemoteInterface_SetOperations_Call { + _c.Call.Return() + return _c +} + +func (_c *FeatureRemoteInterface_SetOperations_Call) RunAndReturn(run func([]model.FunctionPropertyType)) *FeatureRemoteInterface_SetOperations_Call { + _c.Call.Return(run) + return _c +} + +// String provides a mock function with given fields: +func (_m *FeatureRemoteInterface) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// FeatureRemoteInterface_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' +type FeatureRemoteInterface_String_Call struct { + *mock.Call +} + +// String is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) String() *FeatureRemoteInterface_String_Call { + return &FeatureRemoteInterface_String_Call{Call: _e.mock.On("String")} +} + +func (_c *FeatureRemoteInterface_String_Call) Run(run func()) *FeatureRemoteInterface_String_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_String_Call) Return(_a0 string) *FeatureRemoteInterface_String_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_String_Call) RunAndReturn(run func() string) *FeatureRemoteInterface_String_Call { + _c.Call.Return(run) + return _c +} + +// Type provides a mock function with given fields: +func (_m *FeatureRemoteInterface) Type() model.FeatureTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Type") + } + + var r0 model.FeatureTypeType + if rf, ok := ret.Get(0).(func() model.FeatureTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FeatureTypeType) + } + + return r0 +} + +// FeatureRemoteInterface_Type_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Type' +type FeatureRemoteInterface_Type_Call struct { + *mock.Call +} + +// Type is a helper method to define mock.On call +func (_e *FeatureRemoteInterface_Expecter) Type() *FeatureRemoteInterface_Type_Call { + return &FeatureRemoteInterface_Type_Call{Call: _e.mock.On("Type")} +} + +func (_c *FeatureRemoteInterface_Type_Call) Run(run func()) *FeatureRemoteInterface_Type_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FeatureRemoteInterface_Type_Call) Return(_a0 model.FeatureTypeType) *FeatureRemoteInterface_Type_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FeatureRemoteInterface_Type_Call) RunAndReturn(run func() model.FeatureTypeType) *FeatureRemoteInterface_Type_Call { + _c.Call.Return(run) + return _c +} + +// UpdateData provides a mock function with given fields: persist, function, data, filterPartial, filterDelete +func (_m *FeatureRemoteInterface) UpdateData(persist bool, function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType) (interface{}, *model.ErrorType) { + ret := _m.Called(persist, function, data, filterPartial, filterDelete) + + if len(ret) == 0 { + panic("no return value specified for UpdateData") + } + + var r0 interface{} + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(bool, model.FunctionType, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)); ok { + return rf(persist, function, data, filterPartial, filterDelete) + } + if rf, ok := ret.Get(0).(func(bool, model.FunctionType, interface{}, *model.FilterType, *model.FilterType) interface{}); ok { + r0 = rf(persist, function, data, filterPartial, filterDelete) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + if rf, ok := ret.Get(1).(func(bool, model.FunctionType, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType); ok { + r1 = rf(persist, function, data, filterPartial, filterDelete) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FeatureRemoteInterface_UpdateData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateData' +type FeatureRemoteInterface_UpdateData_Call struct { + *mock.Call +} + +// UpdateData is a helper method to define mock.On call +// - persist bool +// - function model.FunctionType +// - data interface{} +// - filterPartial *model.FilterType +// - filterDelete *model.FilterType +func (_e *FeatureRemoteInterface_Expecter) UpdateData(persist interface{}, function interface{}, data interface{}, filterPartial interface{}, filterDelete interface{}) *FeatureRemoteInterface_UpdateData_Call { + return &FeatureRemoteInterface_UpdateData_Call{Call: _e.mock.On("UpdateData", persist, function, data, filterPartial, filterDelete)} +} + +func (_c *FeatureRemoteInterface_UpdateData_Call) Run(run func(persist bool, function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType)) *FeatureRemoteInterface_UpdateData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool), args[1].(model.FunctionType), args[2].(interface{}), args[3].(*model.FilterType), args[4].(*model.FilterType)) + }) + return _c +} + +func (_c *FeatureRemoteInterface_UpdateData_Call) Return(_a0 interface{}, _a1 *model.ErrorType) *FeatureRemoteInterface_UpdateData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FeatureRemoteInterface_UpdateData_Call) RunAndReturn(run func(bool, model.FunctionType, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)) *FeatureRemoteInterface_UpdateData_Call { + _c.Call.Return(run) + return _c +} + +// NewFeatureRemoteInterface creates a new instance of FeatureRemoteInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFeatureRemoteInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FeatureRemoteInterface { + mock := &FeatureRemoteInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataCmdInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataCmdInterface.go new file mode 100644 index 0000000..469ac59 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataCmdInterface.go @@ -0,0 +1,378 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// FunctionDataCmdInterface is an autogenerated mock type for the FunctionDataCmdInterface type +type FunctionDataCmdInterface struct { + mock.Mock +} + +type FunctionDataCmdInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FunctionDataCmdInterface) EXPECT() *FunctionDataCmdInterface_Expecter { + return &FunctionDataCmdInterface_Expecter{mock: &_m.Mock} +} + +// DataCopyAny provides a mock function with given fields: +func (_m *FunctionDataCmdInterface) DataCopyAny() interface{} { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DataCopyAny") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func() interface{}); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// FunctionDataCmdInterface_DataCopyAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DataCopyAny' +type FunctionDataCmdInterface_DataCopyAny_Call struct { + *mock.Call +} + +// DataCopyAny is a helper method to define mock.On call +func (_e *FunctionDataCmdInterface_Expecter) DataCopyAny() *FunctionDataCmdInterface_DataCopyAny_Call { + return &FunctionDataCmdInterface_DataCopyAny_Call{Call: _e.mock.On("DataCopyAny")} +} + +func (_c *FunctionDataCmdInterface_DataCopyAny_Call) Run(run func()) *FunctionDataCmdInterface_DataCopyAny_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataCmdInterface_DataCopyAny_Call) Return(_a0 interface{}) *FunctionDataCmdInterface_DataCopyAny_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_DataCopyAny_Call) RunAndReturn(run func() interface{}) *FunctionDataCmdInterface_DataCopyAny_Call { + _c.Call.Return(run) + return _c +} + +// FunctionType provides a mock function with given fields: +func (_m *FunctionDataCmdInterface) FunctionType() model.FunctionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FunctionType") + } + + var r0 model.FunctionType + if rf, ok := ret.Get(0).(func() model.FunctionType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FunctionType) + } + + return r0 +} + +// FunctionDataCmdInterface_FunctionType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FunctionType' +type FunctionDataCmdInterface_FunctionType_Call struct { + *mock.Call +} + +// FunctionType is a helper method to define mock.On call +func (_e *FunctionDataCmdInterface_Expecter) FunctionType() *FunctionDataCmdInterface_FunctionType_Call { + return &FunctionDataCmdInterface_FunctionType_Call{Call: _e.mock.On("FunctionType")} +} + +func (_c *FunctionDataCmdInterface_FunctionType_Call) Run(run func()) *FunctionDataCmdInterface_FunctionType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataCmdInterface_FunctionType_Call) Return(_a0 model.FunctionType) *FunctionDataCmdInterface_FunctionType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_FunctionType_Call) RunAndReturn(run func() model.FunctionType) *FunctionDataCmdInterface_FunctionType_Call { + _c.Call.Return(run) + return _c +} + +// NotifyOrWriteCmdType provides a mock function with given fields: deleteSelector, partialSelector, partialWithoutSelector, deleteElements +func (_m *FunctionDataCmdInterface) NotifyOrWriteCmdType(deleteSelector interface{}, partialSelector interface{}, partialWithoutSelector bool, deleteElements interface{}) model.CmdType { + ret := _m.Called(deleteSelector, partialSelector, partialWithoutSelector, deleteElements) + + if len(ret) == 0 { + panic("no return value specified for NotifyOrWriteCmdType") + } + + var r0 model.CmdType + if rf, ok := ret.Get(0).(func(interface{}, interface{}, bool, interface{}) model.CmdType); ok { + r0 = rf(deleteSelector, partialSelector, partialWithoutSelector, deleteElements) + } else { + r0 = ret.Get(0).(model.CmdType) + } + + return r0 +} + +// FunctionDataCmdInterface_NotifyOrWriteCmdType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NotifyOrWriteCmdType' +type FunctionDataCmdInterface_NotifyOrWriteCmdType_Call struct { + *mock.Call +} + +// NotifyOrWriteCmdType is a helper method to define mock.On call +// - deleteSelector interface{} +// - partialSelector interface{} +// - partialWithoutSelector bool +// - deleteElements interface{} +func (_e *FunctionDataCmdInterface_Expecter) NotifyOrWriteCmdType(deleteSelector interface{}, partialSelector interface{}, partialWithoutSelector interface{}, deleteElements interface{}) *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call { + return &FunctionDataCmdInterface_NotifyOrWriteCmdType_Call{Call: _e.mock.On("NotifyOrWriteCmdType", deleteSelector, partialSelector, partialWithoutSelector, deleteElements)} +} + +func (_c *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call) Run(run func(deleteSelector interface{}, partialSelector interface{}, partialWithoutSelector bool, deleteElements interface{})) *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{}), args[2].(bool), args[3].(interface{})) + }) + return _c +} + +func (_c *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call) Return(_a0 model.CmdType) *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call) RunAndReturn(run func(interface{}, interface{}, bool, interface{}) model.CmdType) *FunctionDataCmdInterface_NotifyOrWriteCmdType_Call { + _c.Call.Return(run) + return _c +} + +// ReadCmdType provides a mock function with given fields: partialSelector, elements +func (_m *FunctionDataCmdInterface) ReadCmdType(partialSelector interface{}, elements interface{}) model.CmdType { + ret := _m.Called(partialSelector, elements) + + if len(ret) == 0 { + panic("no return value specified for ReadCmdType") + } + + var r0 model.CmdType + if rf, ok := ret.Get(0).(func(interface{}, interface{}) model.CmdType); ok { + r0 = rf(partialSelector, elements) + } else { + r0 = ret.Get(0).(model.CmdType) + } + + return r0 +} + +// FunctionDataCmdInterface_ReadCmdType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadCmdType' +type FunctionDataCmdInterface_ReadCmdType_Call struct { + *mock.Call +} + +// ReadCmdType is a helper method to define mock.On call +// - partialSelector interface{} +// - elements interface{} +func (_e *FunctionDataCmdInterface_Expecter) ReadCmdType(partialSelector interface{}, elements interface{}) *FunctionDataCmdInterface_ReadCmdType_Call { + return &FunctionDataCmdInterface_ReadCmdType_Call{Call: _e.mock.On("ReadCmdType", partialSelector, elements)} +} + +func (_c *FunctionDataCmdInterface_ReadCmdType_Call) Run(run func(partialSelector interface{}, elements interface{})) *FunctionDataCmdInterface_ReadCmdType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{}), args[1].(interface{})) + }) + return _c +} + +func (_c *FunctionDataCmdInterface_ReadCmdType_Call) Return(_a0 model.CmdType) *FunctionDataCmdInterface_ReadCmdType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_ReadCmdType_Call) RunAndReturn(run func(interface{}, interface{}) model.CmdType) *FunctionDataCmdInterface_ReadCmdType_Call { + _c.Call.Return(run) + return _c +} + +// ReplyCmdType provides a mock function with given fields: partial +func (_m *FunctionDataCmdInterface) ReplyCmdType(partial bool) model.CmdType { + ret := _m.Called(partial) + + if len(ret) == 0 { + panic("no return value specified for ReplyCmdType") + } + + var r0 model.CmdType + if rf, ok := ret.Get(0).(func(bool) model.CmdType); ok { + r0 = rf(partial) + } else { + r0 = ret.Get(0).(model.CmdType) + } + + return r0 +} + +// FunctionDataCmdInterface_ReplyCmdType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReplyCmdType' +type FunctionDataCmdInterface_ReplyCmdType_Call struct { + *mock.Call +} + +// ReplyCmdType is a helper method to define mock.On call +// - partial bool +func (_e *FunctionDataCmdInterface_Expecter) ReplyCmdType(partial interface{}) *FunctionDataCmdInterface_ReplyCmdType_Call { + return &FunctionDataCmdInterface_ReplyCmdType_Call{Call: _e.mock.On("ReplyCmdType", partial)} +} + +func (_c *FunctionDataCmdInterface_ReplyCmdType_Call) Run(run func(partial bool)) *FunctionDataCmdInterface_ReplyCmdType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *FunctionDataCmdInterface_ReplyCmdType_Call) Return(_a0 model.CmdType) *FunctionDataCmdInterface_ReplyCmdType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_ReplyCmdType_Call) RunAndReturn(run func(bool) model.CmdType) *FunctionDataCmdInterface_ReplyCmdType_Call { + _c.Call.Return(run) + return _c +} + +// SupportsPartialWrite provides a mock function with given fields: +func (_m *FunctionDataCmdInterface) SupportsPartialWrite() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SupportsPartialWrite") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FunctionDataCmdInterface_SupportsPartialWrite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SupportsPartialWrite' +type FunctionDataCmdInterface_SupportsPartialWrite_Call struct { + *mock.Call +} + +// SupportsPartialWrite is a helper method to define mock.On call +func (_e *FunctionDataCmdInterface_Expecter) SupportsPartialWrite() *FunctionDataCmdInterface_SupportsPartialWrite_Call { + return &FunctionDataCmdInterface_SupportsPartialWrite_Call{Call: _e.mock.On("SupportsPartialWrite")} +} + +func (_c *FunctionDataCmdInterface_SupportsPartialWrite_Call) Run(run func()) *FunctionDataCmdInterface_SupportsPartialWrite_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataCmdInterface_SupportsPartialWrite_Call) Return(_a0 bool) *FunctionDataCmdInterface_SupportsPartialWrite_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataCmdInterface_SupportsPartialWrite_Call) RunAndReturn(run func() bool) *FunctionDataCmdInterface_SupportsPartialWrite_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataAny provides a mock function with given fields: remoteWrite, persist, data, filterPartial, filterDelete +func (_m *FunctionDataCmdInterface) UpdateDataAny(remoteWrite bool, persist bool, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType) (interface{}, *model.ErrorType) { + ret := _m.Called(remoteWrite, persist, data, filterPartial, filterDelete) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataAny") + } + + var r0 interface{} + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)); ok { + return rf(remoteWrite, persist, data, filterPartial, filterDelete) + } + if rf, ok := ret.Get(0).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) interface{}); ok { + r0 = rf(remoteWrite, persist, data, filterPartial, filterDelete) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + if rf, ok := ret.Get(1).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType); ok { + r1 = rf(remoteWrite, persist, data, filterPartial, filterDelete) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FunctionDataCmdInterface_UpdateDataAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataAny' +type FunctionDataCmdInterface_UpdateDataAny_Call struct { + *mock.Call +} + +// UpdateDataAny is a helper method to define mock.On call +// - remoteWrite bool +// - persist bool +// - data interface{} +// - filterPartial *model.FilterType +// - filterDelete *model.FilterType +func (_e *FunctionDataCmdInterface_Expecter) UpdateDataAny(remoteWrite interface{}, persist interface{}, data interface{}, filterPartial interface{}, filterDelete interface{}) *FunctionDataCmdInterface_UpdateDataAny_Call { + return &FunctionDataCmdInterface_UpdateDataAny_Call{Call: _e.mock.On("UpdateDataAny", remoteWrite, persist, data, filterPartial, filterDelete)} +} + +func (_c *FunctionDataCmdInterface_UpdateDataAny_Call) Run(run func(remoteWrite bool, persist bool, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType)) *FunctionDataCmdInterface_UpdateDataAny_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool), args[1].(bool), args[2].(interface{}), args[3].(*model.FilterType), args[4].(*model.FilterType)) + }) + return _c +} + +func (_c *FunctionDataCmdInterface_UpdateDataAny_Call) Return(_a0 interface{}, _a1 *model.ErrorType) *FunctionDataCmdInterface_UpdateDataAny_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FunctionDataCmdInterface_UpdateDataAny_Call) RunAndReturn(run func(bool, bool, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)) *FunctionDataCmdInterface_UpdateDataAny_Call { + _c.Call.Return(run) + return _c +} + +// NewFunctionDataCmdInterface creates a new instance of FunctionDataCmdInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFunctionDataCmdInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FunctionDataCmdInterface { + mock := &FunctionDataCmdInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataInterface.go new file mode 100644 index 0000000..0041b85 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/FunctionDataInterface.go @@ -0,0 +1,236 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// FunctionDataInterface is an autogenerated mock type for the FunctionDataInterface type +type FunctionDataInterface struct { + mock.Mock +} + +type FunctionDataInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *FunctionDataInterface) EXPECT() *FunctionDataInterface_Expecter { + return &FunctionDataInterface_Expecter{mock: &_m.Mock} +} + +// DataCopyAny provides a mock function with given fields: +func (_m *FunctionDataInterface) DataCopyAny() interface{} { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DataCopyAny") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func() interface{}); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// FunctionDataInterface_DataCopyAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DataCopyAny' +type FunctionDataInterface_DataCopyAny_Call struct { + *mock.Call +} + +// DataCopyAny is a helper method to define mock.On call +func (_e *FunctionDataInterface_Expecter) DataCopyAny() *FunctionDataInterface_DataCopyAny_Call { + return &FunctionDataInterface_DataCopyAny_Call{Call: _e.mock.On("DataCopyAny")} +} + +func (_c *FunctionDataInterface_DataCopyAny_Call) Run(run func()) *FunctionDataInterface_DataCopyAny_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataInterface_DataCopyAny_Call) Return(_a0 interface{}) *FunctionDataInterface_DataCopyAny_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataInterface_DataCopyAny_Call) RunAndReturn(run func() interface{}) *FunctionDataInterface_DataCopyAny_Call { + _c.Call.Return(run) + return _c +} + +// FunctionType provides a mock function with given fields: +func (_m *FunctionDataInterface) FunctionType() model.FunctionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for FunctionType") + } + + var r0 model.FunctionType + if rf, ok := ret.Get(0).(func() model.FunctionType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FunctionType) + } + + return r0 +} + +// FunctionDataInterface_FunctionType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FunctionType' +type FunctionDataInterface_FunctionType_Call struct { + *mock.Call +} + +// FunctionType is a helper method to define mock.On call +func (_e *FunctionDataInterface_Expecter) FunctionType() *FunctionDataInterface_FunctionType_Call { + return &FunctionDataInterface_FunctionType_Call{Call: _e.mock.On("FunctionType")} +} + +func (_c *FunctionDataInterface_FunctionType_Call) Run(run func()) *FunctionDataInterface_FunctionType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataInterface_FunctionType_Call) Return(_a0 model.FunctionType) *FunctionDataInterface_FunctionType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataInterface_FunctionType_Call) RunAndReturn(run func() model.FunctionType) *FunctionDataInterface_FunctionType_Call { + _c.Call.Return(run) + return _c +} + +// SupportsPartialWrite provides a mock function with given fields: +func (_m *FunctionDataInterface) SupportsPartialWrite() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for SupportsPartialWrite") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// FunctionDataInterface_SupportsPartialWrite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SupportsPartialWrite' +type FunctionDataInterface_SupportsPartialWrite_Call struct { + *mock.Call +} + +// SupportsPartialWrite is a helper method to define mock.On call +func (_e *FunctionDataInterface_Expecter) SupportsPartialWrite() *FunctionDataInterface_SupportsPartialWrite_Call { + return &FunctionDataInterface_SupportsPartialWrite_Call{Call: _e.mock.On("SupportsPartialWrite")} +} + +func (_c *FunctionDataInterface_SupportsPartialWrite_Call) Run(run func()) *FunctionDataInterface_SupportsPartialWrite_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *FunctionDataInterface_SupportsPartialWrite_Call) Return(_a0 bool) *FunctionDataInterface_SupportsPartialWrite_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *FunctionDataInterface_SupportsPartialWrite_Call) RunAndReturn(run func() bool) *FunctionDataInterface_SupportsPartialWrite_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataAny provides a mock function with given fields: remoteWrite, persist, data, filterPartial, filterDelete +func (_m *FunctionDataInterface) UpdateDataAny(remoteWrite bool, persist bool, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType) (interface{}, *model.ErrorType) { + ret := _m.Called(remoteWrite, persist, data, filterPartial, filterDelete) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataAny") + } + + var r0 interface{} + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)); ok { + return rf(remoteWrite, persist, data, filterPartial, filterDelete) + } + if rf, ok := ret.Get(0).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) interface{}); ok { + r0 = rf(remoteWrite, persist, data, filterPartial, filterDelete) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + if rf, ok := ret.Get(1).(func(bool, bool, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType); ok { + r1 = rf(remoteWrite, persist, data, filterPartial, filterDelete) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// FunctionDataInterface_UpdateDataAny_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataAny' +type FunctionDataInterface_UpdateDataAny_Call struct { + *mock.Call +} + +// UpdateDataAny is a helper method to define mock.On call +// - remoteWrite bool +// - persist bool +// - data interface{} +// - filterPartial *model.FilterType +// - filterDelete *model.FilterType +func (_e *FunctionDataInterface_Expecter) UpdateDataAny(remoteWrite interface{}, persist interface{}, data interface{}, filterPartial interface{}, filterDelete interface{}) *FunctionDataInterface_UpdateDataAny_Call { + return &FunctionDataInterface_UpdateDataAny_Call{Call: _e.mock.On("UpdateDataAny", remoteWrite, persist, data, filterPartial, filterDelete)} +} + +func (_c *FunctionDataInterface_UpdateDataAny_Call) Run(run func(remoteWrite bool, persist bool, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType)) *FunctionDataInterface_UpdateDataAny_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool), args[1].(bool), args[2].(interface{}), args[3].(*model.FilterType), args[4].(*model.FilterType)) + }) + return _c +} + +func (_c *FunctionDataInterface_UpdateDataAny_Call) Return(_a0 interface{}, _a1 *model.ErrorType) *FunctionDataInterface_UpdateDataAny_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *FunctionDataInterface_UpdateDataAny_Call) RunAndReturn(run func(bool, bool, interface{}, *model.FilterType, *model.FilterType) (interface{}, *model.ErrorType)) *FunctionDataInterface_UpdateDataAny_Call { + _c.Call.Return(run) + return _c +} + +// NewFunctionDataInterface creates a new instance of FunctionDataInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFunctionDataInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *FunctionDataInterface { + mock := &FunctionDataInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/HeartbeatManagerInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/HeartbeatManagerInterface.go new file mode 100644 index 0000000..3b33f25 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/HeartbeatManagerInterface.go @@ -0,0 +1,191 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" +) + +// HeartbeatManagerInterface is an autogenerated mock type for the HeartbeatManagerInterface type +type HeartbeatManagerInterface struct { + mock.Mock +} + +type HeartbeatManagerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *HeartbeatManagerInterface) EXPECT() *HeartbeatManagerInterface_Expecter { + return &HeartbeatManagerInterface_Expecter{mock: &_m.Mock} +} + +// IsHeartbeatRunning provides a mock function with given fields: +func (_m *HeartbeatManagerInterface) IsHeartbeatRunning() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatRunning") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// HeartbeatManagerInterface_IsHeartbeatRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatRunning' +type HeartbeatManagerInterface_IsHeartbeatRunning_Call struct { + *mock.Call +} + +// IsHeartbeatRunning is a helper method to define mock.On call +func (_e *HeartbeatManagerInterface_Expecter) IsHeartbeatRunning() *HeartbeatManagerInterface_IsHeartbeatRunning_Call { + return &HeartbeatManagerInterface_IsHeartbeatRunning_Call{Call: _e.mock.On("IsHeartbeatRunning")} +} + +func (_c *HeartbeatManagerInterface_IsHeartbeatRunning_Call) Run(run func()) *HeartbeatManagerInterface_IsHeartbeatRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HeartbeatManagerInterface_IsHeartbeatRunning_Call) Return(_a0 bool) *HeartbeatManagerInterface_IsHeartbeatRunning_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HeartbeatManagerInterface_IsHeartbeatRunning_Call) RunAndReturn(run func() bool) *HeartbeatManagerInterface_IsHeartbeatRunning_Call { + _c.Call.Return(run) + return _c +} + +// SetLocalFeature provides a mock function with given fields: entity, feature +func (_m *HeartbeatManagerInterface) SetLocalFeature(entity api.EntityLocalInterface, feature api.FeatureLocalInterface) { + _m.Called(entity, feature) +} + +// HeartbeatManagerInterface_SetLocalFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLocalFeature' +type HeartbeatManagerInterface_SetLocalFeature_Call struct { + *mock.Call +} + +// SetLocalFeature is a helper method to define mock.On call +// - entity api.EntityLocalInterface +// - feature api.FeatureLocalInterface +func (_e *HeartbeatManagerInterface_Expecter) SetLocalFeature(entity interface{}, feature interface{}) *HeartbeatManagerInterface_SetLocalFeature_Call { + return &HeartbeatManagerInterface_SetLocalFeature_Call{Call: _e.mock.On("SetLocalFeature", entity, feature)} +} + +func (_c *HeartbeatManagerInterface_SetLocalFeature_Call) Run(run func(entity api.EntityLocalInterface, feature api.FeatureLocalInterface)) *HeartbeatManagerInterface_SetLocalFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityLocalInterface), args[1].(api.FeatureLocalInterface)) + }) + return _c +} + +func (_c *HeartbeatManagerInterface_SetLocalFeature_Call) Return() *HeartbeatManagerInterface_SetLocalFeature_Call { + _c.Call.Return() + return _c +} + +func (_c *HeartbeatManagerInterface_SetLocalFeature_Call) RunAndReturn(run func(api.EntityLocalInterface, api.FeatureLocalInterface)) *HeartbeatManagerInterface_SetLocalFeature_Call { + _c.Call.Return(run) + return _c +} + +// StartHeartbeat provides a mock function with given fields: +func (_m *HeartbeatManagerInterface) StartHeartbeat() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for StartHeartbeat") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// HeartbeatManagerInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type HeartbeatManagerInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *HeartbeatManagerInterface_Expecter) StartHeartbeat() *HeartbeatManagerInterface_StartHeartbeat_Call { + return &HeartbeatManagerInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *HeartbeatManagerInterface_StartHeartbeat_Call) Run(run func()) *HeartbeatManagerInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HeartbeatManagerInterface_StartHeartbeat_Call) Return(_a0 error) *HeartbeatManagerInterface_StartHeartbeat_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HeartbeatManagerInterface_StartHeartbeat_Call) RunAndReturn(run func() error) *HeartbeatManagerInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *HeartbeatManagerInterface) StopHeartbeat() { + _m.Called() +} + +// HeartbeatManagerInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type HeartbeatManagerInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *HeartbeatManagerInterface_Expecter) StopHeartbeat() *HeartbeatManagerInterface_StopHeartbeat_Call { + return &HeartbeatManagerInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *HeartbeatManagerInterface_StopHeartbeat_Call) Run(run func()) *HeartbeatManagerInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HeartbeatManagerInterface_StopHeartbeat_Call) Return() *HeartbeatManagerInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *HeartbeatManagerInterface_StopHeartbeat_Call) RunAndReturn(run func()) *HeartbeatManagerInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// NewHeartbeatManagerInterface creates a new instance of HeartbeatManagerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewHeartbeatManagerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *HeartbeatManagerInterface { + mock := &HeartbeatManagerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/NodeManagementInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/NodeManagementInterface.go new file mode 100644 index 0000000..1705630 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/NodeManagementInterface.go @@ -0,0 +1,1600 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + time "time" +) + +// NodeManagementInterface is an autogenerated mock type for the NodeManagementInterface type +type NodeManagementInterface struct { + mock.Mock +} + +type NodeManagementInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *NodeManagementInterface) EXPECT() *NodeManagementInterface_Expecter { + return &NodeManagementInterface_Expecter{mock: &_m.Mock} +} + +// AddFunctionType provides a mock function with given fields: function, read, write +func (_m *NodeManagementInterface) AddFunctionType(function model.FunctionType, read bool, write bool) { + _m.Called(function, read, write) +} + +// NodeManagementInterface_AddFunctionType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFunctionType' +type NodeManagementInterface_AddFunctionType_Call struct { + *mock.Call +} + +// AddFunctionType is a helper method to define mock.On call +// - function model.FunctionType +// - read bool +// - write bool +func (_e *NodeManagementInterface_Expecter) AddFunctionType(function interface{}, read interface{}, write interface{}) *NodeManagementInterface_AddFunctionType_Call { + return &NodeManagementInterface_AddFunctionType_Call{Call: _e.mock.On("AddFunctionType", function, read, write)} +} + +func (_c *NodeManagementInterface_AddFunctionType_Call) Run(run func(function model.FunctionType, read bool, write bool)) *NodeManagementInterface_AddFunctionType_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(bool), args[2].(bool)) + }) + return _c +} + +func (_c *NodeManagementInterface_AddFunctionType_Call) Return() *NodeManagementInterface_AddFunctionType_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_AddFunctionType_Call) RunAndReturn(run func(model.FunctionType, bool, bool)) *NodeManagementInterface_AddFunctionType_Call { + _c.Call.Return(run) + return _c +} + +// AddResponseCallback provides a mock function with given fields: msgCounterReference, function +func (_m *NodeManagementInterface) AddResponseCallback(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage)) error { + ret := _m.Called(msgCounterReference, function) + + if len(ret) == 0 { + panic("no return value specified for AddResponseCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.MsgCounterType, func(api.ResponseMessage)) error); ok { + r0 = rf(msgCounterReference, function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NodeManagementInterface_AddResponseCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResponseCallback' +type NodeManagementInterface_AddResponseCallback_Call struct { + *mock.Call +} + +// AddResponseCallback is a helper method to define mock.On call +// - msgCounterReference model.MsgCounterType +// - function func(api.ResponseMessage) +func (_e *NodeManagementInterface_Expecter) AddResponseCallback(msgCounterReference interface{}, function interface{}) *NodeManagementInterface_AddResponseCallback_Call { + return &NodeManagementInterface_AddResponseCallback_Call{Call: _e.mock.On("AddResponseCallback", msgCounterReference, function)} +} + +func (_c *NodeManagementInterface_AddResponseCallback_Call) Run(run func(msgCounterReference model.MsgCounterType, function func(api.ResponseMessage))) *NodeManagementInterface_AddResponseCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType), args[1].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *NodeManagementInterface_AddResponseCallback_Call) Return(_a0 error) *NodeManagementInterface_AddResponseCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_AddResponseCallback_Call) RunAndReturn(run func(model.MsgCounterType, func(api.ResponseMessage)) error) *NodeManagementInterface_AddResponseCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddResultCallback provides a mock function with given fields: function +func (_m *NodeManagementInterface) AddResultCallback(function func(api.ResponseMessage)) { + _m.Called(function) +} + +// NodeManagementInterface_AddResultCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddResultCallback' +type NodeManagementInterface_AddResultCallback_Call struct { + *mock.Call +} + +// AddResultCallback is a helper method to define mock.On call +// - function func(api.ResponseMessage) +func (_e *NodeManagementInterface_Expecter) AddResultCallback(function interface{}) *NodeManagementInterface_AddResultCallback_Call { + return &NodeManagementInterface_AddResultCallback_Call{Call: _e.mock.On("AddResultCallback", function)} +} + +func (_c *NodeManagementInterface_AddResultCallback_Call) Run(run func(function func(api.ResponseMessage))) *NodeManagementInterface_AddResultCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(api.ResponseMessage))) + }) + return _c +} + +func (_c *NodeManagementInterface_AddResultCallback_Call) Return() *NodeManagementInterface_AddResultCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_AddResultCallback_Call) RunAndReturn(run func(func(api.ResponseMessage))) *NodeManagementInterface_AddResultCallback_Call { + _c.Call.Return(run) + return _c +} + +// AddWriteApprovalCallback provides a mock function with given fields: function +func (_m *NodeManagementInterface) AddWriteApprovalCallback(function api.WriteApprovalCallbackFunc) error { + ret := _m.Called(function) + + if len(ret) == 0 { + panic("no return value specified for AddWriteApprovalCallback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.WriteApprovalCallbackFunc) error); ok { + r0 = rf(function) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// NodeManagementInterface_AddWriteApprovalCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddWriteApprovalCallback' +type NodeManagementInterface_AddWriteApprovalCallback_Call struct { + *mock.Call +} + +// AddWriteApprovalCallback is a helper method to define mock.On call +// - function api.WriteApprovalCallbackFunc +func (_e *NodeManagementInterface_Expecter) AddWriteApprovalCallback(function interface{}) *NodeManagementInterface_AddWriteApprovalCallback_Call { + return &NodeManagementInterface_AddWriteApprovalCallback_Call{Call: _e.mock.On("AddWriteApprovalCallback", function)} +} + +func (_c *NodeManagementInterface_AddWriteApprovalCallback_Call) Run(run func(function api.WriteApprovalCallbackFunc)) *NodeManagementInterface_AddWriteApprovalCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.WriteApprovalCallbackFunc)) + }) + return _c +} + +func (_c *NodeManagementInterface_AddWriteApprovalCallback_Call) Return(_a0 error) *NodeManagementInterface_AddWriteApprovalCallback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_AddWriteApprovalCallback_Call) RunAndReturn(run func(api.WriteApprovalCallbackFunc) error) *NodeManagementInterface_AddWriteApprovalCallback_Call { + _c.Call.Return(run) + return _c +} + +// Address provides a mock function with given fields: +func (_m *NodeManagementInterface) Address() *model.FeatureAddressType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Address") + } + + var r0 *model.FeatureAddressType + if rf, ok := ret.Get(0).(func() *model.FeatureAddressType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.FeatureAddressType) + } + } + + return r0 +} + +// NodeManagementInterface_Address_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Address' +type NodeManagementInterface_Address_Call struct { + *mock.Call +} + +// Address is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Address() *NodeManagementInterface_Address_Call { + return &NodeManagementInterface_Address_Call{Call: _e.mock.On("Address")} +} + +func (_c *NodeManagementInterface_Address_Call) Run(run func()) *NodeManagementInterface_Address_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Address_Call) Return(_a0 *model.FeatureAddressType) *NodeManagementInterface_Address_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Address_Call) RunAndReturn(run func() *model.FeatureAddressType) *NodeManagementInterface_Address_Call { + _c.Call.Return(run) + return _c +} + +// ApproveOrDenyWrite provides a mock function with given fields: msg, err +func (_m *NodeManagementInterface) ApproveOrDenyWrite(msg *api.Message, err model.ErrorType) { + _m.Called(msg, err) +} + +// NodeManagementInterface_ApproveOrDenyWrite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApproveOrDenyWrite' +type NodeManagementInterface_ApproveOrDenyWrite_Call struct { + *mock.Call +} + +// ApproveOrDenyWrite is a helper method to define mock.On call +// - msg *api.Message +// - err model.ErrorType +func (_e *NodeManagementInterface_Expecter) ApproveOrDenyWrite(msg interface{}, err interface{}) *NodeManagementInterface_ApproveOrDenyWrite_Call { + return &NodeManagementInterface_ApproveOrDenyWrite_Call{Call: _e.mock.On("ApproveOrDenyWrite", msg, err)} +} + +func (_c *NodeManagementInterface_ApproveOrDenyWrite_Call) Run(run func(msg *api.Message, err model.ErrorType)) *NodeManagementInterface_ApproveOrDenyWrite_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*api.Message), args[1].(model.ErrorType)) + }) + return _c +} + +func (_c *NodeManagementInterface_ApproveOrDenyWrite_Call) Return() *NodeManagementInterface_ApproveOrDenyWrite_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_ApproveOrDenyWrite_Call) RunAndReturn(run func(*api.Message, model.ErrorType)) *NodeManagementInterface_ApproveOrDenyWrite_Call { + _c.Call.Return(run) + return _c +} + +// BindToRemote provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) BindToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for BindToRemote") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_BindToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BindToRemote' +type NodeManagementInterface_BindToRemote_Call struct { + *mock.Call +} + +// BindToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) BindToRemote(remoteAddress interface{}) *NodeManagementInterface_BindToRemote_Call { + return &NodeManagementInterface_BindToRemote_Call{Call: _e.mock.On("BindToRemote", remoteAddress)} +} + +func (_c *NodeManagementInterface_BindToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_BindToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_BindToRemote_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_BindToRemote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_BindToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_BindToRemote_Call { + _c.Call.Return(run) + return _c +} + +// CleanRemoteDeviceCaches provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) CleanRemoteDeviceCaches(remoteAddress *model.DeviceAddressType) { + _m.Called(remoteAddress) +} + +// NodeManagementInterface_CleanRemoteDeviceCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanRemoteDeviceCaches' +type NodeManagementInterface_CleanRemoteDeviceCaches_Call struct { + *mock.Call +} + +// CleanRemoteDeviceCaches is a helper method to define mock.On call +// - remoteAddress *model.DeviceAddressType +func (_e *NodeManagementInterface_Expecter) CleanRemoteDeviceCaches(remoteAddress interface{}) *NodeManagementInterface_CleanRemoteDeviceCaches_Call { + return &NodeManagementInterface_CleanRemoteDeviceCaches_Call{Call: _e.mock.On("CleanRemoteDeviceCaches", remoteAddress)} +} + +func (_c *NodeManagementInterface_CleanRemoteDeviceCaches_Call) Run(run func(remoteAddress *model.DeviceAddressType)) *NodeManagementInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DeviceAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_CleanRemoteDeviceCaches_Call) Return() *NodeManagementInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_CleanRemoteDeviceCaches_Call) RunAndReturn(run func(*model.DeviceAddressType)) *NodeManagementInterface_CleanRemoteDeviceCaches_Call { + _c.Call.Return(run) + return _c +} + +// CleanRemoteEntityCaches provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) { + _m.Called(remoteAddress) +} + +// NodeManagementInterface_CleanRemoteEntityCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanRemoteEntityCaches' +type NodeManagementInterface_CleanRemoteEntityCaches_Call struct { + *mock.Call +} + +// CleanRemoteEntityCaches is a helper method to define mock.On call +// - remoteAddress *model.EntityAddressType +func (_e *NodeManagementInterface_Expecter) CleanRemoteEntityCaches(remoteAddress interface{}) *NodeManagementInterface_CleanRemoteEntityCaches_Call { + return &NodeManagementInterface_CleanRemoteEntityCaches_Call{Call: _e.mock.On("CleanRemoteEntityCaches", remoteAddress)} +} + +func (_c *NodeManagementInterface_CleanRemoteEntityCaches_Call) Run(run func(remoteAddress *model.EntityAddressType)) *NodeManagementInterface_CleanRemoteEntityCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.EntityAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_CleanRemoteEntityCaches_Call) Return() *NodeManagementInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_CleanRemoteEntityCaches_Call) RunAndReturn(run func(*model.EntityAddressType)) *NodeManagementInterface_CleanRemoteEntityCaches_Call { + _c.Call.Return(run) + return _c +} + +// CleanWriteApprovalCaches provides a mock function with given fields: ski +func (_m *NodeManagementInterface) CleanWriteApprovalCaches(ski string) { + _m.Called(ski) +} + +// NodeManagementInterface_CleanWriteApprovalCaches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanWriteApprovalCaches' +type NodeManagementInterface_CleanWriteApprovalCaches_Call struct { + *mock.Call +} + +// CleanWriteApprovalCaches is a helper method to define mock.On call +// - ski string +func (_e *NodeManagementInterface_Expecter) CleanWriteApprovalCaches(ski interface{}) *NodeManagementInterface_CleanWriteApprovalCaches_Call { + return &NodeManagementInterface_CleanWriteApprovalCaches_Call{Call: _e.mock.On("CleanWriteApprovalCaches", ski)} +} + +func (_c *NodeManagementInterface_CleanWriteApprovalCaches_Call) Run(run func(ski string)) *NodeManagementInterface_CleanWriteApprovalCaches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *NodeManagementInterface_CleanWriteApprovalCaches_Call) Return() *NodeManagementInterface_CleanWriteApprovalCaches_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_CleanWriteApprovalCaches_Call) RunAndReturn(run func(string)) *NodeManagementInterface_CleanWriteApprovalCaches_Call { + _c.Call.Return(run) + return _c +} + +// DataCopy provides a mock function with given fields: function +func (_m *NodeManagementInterface) DataCopy(function model.FunctionType) interface{} { + ret := _m.Called(function) + + if len(ret) == 0 { + panic("no return value specified for DataCopy") + } + + var r0 interface{} + if rf, ok := ret.Get(0).(func(model.FunctionType) interface{}); ok { + r0 = rf(function) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(interface{}) + } + } + + return r0 +} + +// NodeManagementInterface_DataCopy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DataCopy' +type NodeManagementInterface_DataCopy_Call struct { + *mock.Call +} + +// DataCopy is a helper method to define mock.On call +// - function model.FunctionType +func (_e *NodeManagementInterface_Expecter) DataCopy(function interface{}) *NodeManagementInterface_DataCopy_Call { + return &NodeManagementInterface_DataCopy_Call{Call: _e.mock.On("DataCopy", function)} +} + +func (_c *NodeManagementInterface_DataCopy_Call) Run(run func(function model.FunctionType)) *NodeManagementInterface_DataCopy_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType)) + }) + return _c +} + +func (_c *NodeManagementInterface_DataCopy_Call) Return(_a0 interface{}) *NodeManagementInterface_DataCopy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_DataCopy_Call) RunAndReturn(run func(model.FunctionType) interface{}) *NodeManagementInterface_DataCopy_Call { + _c.Call.Return(run) + return _c +} + +// Description provides a mock function with given fields: +func (_m *NodeManagementInterface) Description() *model.DescriptionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Description") + } + + var r0 *model.DescriptionType + if rf, ok := ret.Get(0).(func() *model.DescriptionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.DescriptionType) + } + } + + return r0 +} + +// NodeManagementInterface_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description' +type NodeManagementInterface_Description_Call struct { + *mock.Call +} + +// Description is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Description() *NodeManagementInterface_Description_Call { + return &NodeManagementInterface_Description_Call{Call: _e.mock.On("Description")} +} + +func (_c *NodeManagementInterface_Description_Call) Run(run func()) *NodeManagementInterface_Description_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Description_Call) Return(_a0 *model.DescriptionType) *NodeManagementInterface_Description_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Description_Call) RunAndReturn(run func() *model.DescriptionType) *NodeManagementInterface_Description_Call { + _c.Call.Return(run) + return _c +} + +// Device provides a mock function with given fields: +func (_m *NodeManagementInterface) Device() api.DeviceLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Device") + } + + var r0 api.DeviceLocalInterface + if rf, ok := ret.Get(0).(func() api.DeviceLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.DeviceLocalInterface) + } + } + + return r0 +} + +// NodeManagementInterface_Device_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Device' +type NodeManagementInterface_Device_Call struct { + *mock.Call +} + +// Device is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Device() *NodeManagementInterface_Device_Call { + return &NodeManagementInterface_Device_Call{Call: _e.mock.On("Device")} +} + +func (_c *NodeManagementInterface_Device_Call) Run(run func()) *NodeManagementInterface_Device_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Device_Call) Return(_a0 api.DeviceLocalInterface) *NodeManagementInterface_Device_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Device_Call) RunAndReturn(run func() api.DeviceLocalInterface) *NodeManagementInterface_Device_Call { + _c.Call.Return(run) + return _c +} + +// Entity provides a mock function with given fields: +func (_m *NodeManagementInterface) Entity() api.EntityLocalInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Entity") + } + + var r0 api.EntityLocalInterface + if rf, ok := ret.Get(0).(func() api.EntityLocalInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.EntityLocalInterface) + } + } + + return r0 +} + +// NodeManagementInterface_Entity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Entity' +type NodeManagementInterface_Entity_Call struct { + *mock.Call +} + +// Entity is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Entity() *NodeManagementInterface_Entity_Call { + return &NodeManagementInterface_Entity_Call{Call: _e.mock.On("Entity")} +} + +func (_c *NodeManagementInterface_Entity_Call) Run(run func()) *NodeManagementInterface_Entity_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Entity_Call) Return(_a0 api.EntityLocalInterface) *NodeManagementInterface_Entity_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Entity_Call) RunAndReturn(run func() api.EntityLocalInterface) *NodeManagementInterface_Entity_Call { + _c.Call.Return(run) + return _c +} + +// Functions provides a mock function with given fields: +func (_m *NodeManagementInterface) Functions() []model.FunctionType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Functions") + } + + var r0 []model.FunctionType + if rf, ok := ret.Get(0).(func() []model.FunctionType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]model.FunctionType) + } + } + + return r0 +} + +// NodeManagementInterface_Functions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Functions' +type NodeManagementInterface_Functions_Call struct { + *mock.Call +} + +// Functions is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Functions() *NodeManagementInterface_Functions_Call { + return &NodeManagementInterface_Functions_Call{Call: _e.mock.On("Functions")} +} + +func (_c *NodeManagementInterface_Functions_Call) Run(run func()) *NodeManagementInterface_Functions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Functions_Call) Return(_a0 []model.FunctionType) *NodeManagementInterface_Functions_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Functions_Call) RunAndReturn(run func() []model.FunctionType) *NodeManagementInterface_Functions_Call { + _c.Call.Return(run) + return _c +} + +// HandleMessage provides a mock function with given fields: message +func (_m *NodeManagementInterface) HandleMessage(message *api.Message) *model.ErrorType { + ret := _m.Called(message) + + if len(ret) == 0 { + panic("no return value specified for HandleMessage") + } + + var r0 *model.ErrorType + if rf, ok := ret.Get(0).(func(*api.Message) *model.ErrorType); ok { + r0 = rf(message) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ErrorType) + } + } + + return r0 +} + +// NodeManagementInterface_HandleMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleMessage' +type NodeManagementInterface_HandleMessage_Call struct { + *mock.Call +} + +// HandleMessage is a helper method to define mock.On call +// - message *api.Message +func (_e *NodeManagementInterface_Expecter) HandleMessage(message interface{}) *NodeManagementInterface_HandleMessage_Call { + return &NodeManagementInterface_HandleMessage_Call{Call: _e.mock.On("HandleMessage", message)} +} + +func (_c *NodeManagementInterface_HandleMessage_Call) Run(run func(message *api.Message)) *NodeManagementInterface_HandleMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*api.Message)) + }) + return _c +} + +func (_c *NodeManagementInterface_HandleMessage_Call) Return(_a0 *model.ErrorType) *NodeManagementInterface_HandleMessage_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_HandleMessage_Call) RunAndReturn(run func(*api.Message) *model.ErrorType) *NodeManagementInterface_HandleMessage_Call { + _c.Call.Return(run) + return _c +} + +// HasBindingToRemote provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) HasBindingToRemote(remoteAddress *model.FeatureAddressType) bool { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for HasBindingToRemote") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) bool); ok { + r0 = rf(remoteAddress) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// NodeManagementInterface_HasBindingToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasBindingToRemote' +type NodeManagementInterface_HasBindingToRemote_Call struct { + *mock.Call +} + +// HasBindingToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) HasBindingToRemote(remoteAddress interface{}) *NodeManagementInterface_HasBindingToRemote_Call { + return &NodeManagementInterface_HasBindingToRemote_Call{Call: _e.mock.On("HasBindingToRemote", remoteAddress)} +} + +func (_c *NodeManagementInterface_HasBindingToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_HasBindingToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_HasBindingToRemote_Call) Return(_a0 bool) *NodeManagementInterface_HasBindingToRemote_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_HasBindingToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) bool) *NodeManagementInterface_HasBindingToRemote_Call { + _c.Call.Return(run) + return _c +} + +// HasSubscriptionToRemote provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) HasSubscriptionToRemote(remoteAddress *model.FeatureAddressType) bool { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for HasSubscriptionToRemote") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) bool); ok { + r0 = rf(remoteAddress) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// NodeManagementInterface_HasSubscriptionToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasSubscriptionToRemote' +type NodeManagementInterface_HasSubscriptionToRemote_Call struct { + *mock.Call +} + +// HasSubscriptionToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) HasSubscriptionToRemote(remoteAddress interface{}) *NodeManagementInterface_HasSubscriptionToRemote_Call { + return &NodeManagementInterface_HasSubscriptionToRemote_Call{Call: _e.mock.On("HasSubscriptionToRemote", remoteAddress)} +} + +func (_c *NodeManagementInterface_HasSubscriptionToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_HasSubscriptionToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_HasSubscriptionToRemote_Call) Return(_a0 bool) *NodeManagementInterface_HasSubscriptionToRemote_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_HasSubscriptionToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) bool) *NodeManagementInterface_HasSubscriptionToRemote_Call { + _c.Call.Return(run) + return _c +} + +// Information provides a mock function with given fields: +func (_m *NodeManagementInterface) Information() *model.NodeManagementDetailedDiscoveryFeatureInformationType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Information") + } + + var r0 *model.NodeManagementDetailedDiscoveryFeatureInformationType + if rf, ok := ret.Get(0).(func() *model.NodeManagementDetailedDiscoveryFeatureInformationType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.NodeManagementDetailedDiscoveryFeatureInformationType) + } + } + + return r0 +} + +// NodeManagementInterface_Information_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Information' +type NodeManagementInterface_Information_Call struct { + *mock.Call +} + +// Information is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Information() *NodeManagementInterface_Information_Call { + return &NodeManagementInterface_Information_Call{Call: _e.mock.On("Information")} +} + +func (_c *NodeManagementInterface_Information_Call) Run(run func()) *NodeManagementInterface_Information_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Information_Call) Return(_a0 *model.NodeManagementDetailedDiscoveryFeatureInformationType) *NodeManagementInterface_Information_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Information_Call) RunAndReturn(run func() *model.NodeManagementDetailedDiscoveryFeatureInformationType) *NodeManagementInterface_Information_Call { + _c.Call.Return(run) + return _c +} + +// Operations provides a mock function with given fields: +func (_m *NodeManagementInterface) Operations() map[model.FunctionType]api.OperationsInterface { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Operations") + } + + var r0 map[model.FunctionType]api.OperationsInterface + if rf, ok := ret.Get(0).(func() map[model.FunctionType]api.OperationsInterface); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[model.FunctionType]api.OperationsInterface) + } + } + + return r0 +} + +// NodeManagementInterface_Operations_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Operations' +type NodeManagementInterface_Operations_Call struct { + *mock.Call +} + +// Operations is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Operations() *NodeManagementInterface_Operations_Call { + return &NodeManagementInterface_Operations_Call{Call: _e.mock.On("Operations")} +} + +func (_c *NodeManagementInterface_Operations_Call) Run(run func()) *NodeManagementInterface_Operations_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Operations_Call) Return(_a0 map[model.FunctionType]api.OperationsInterface) *NodeManagementInterface_Operations_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Operations_Call) RunAndReturn(run func() map[model.FunctionType]api.OperationsInterface) *NodeManagementInterface_Operations_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllRemoteBindings provides a mock function with given fields: +func (_m *NodeManagementInterface) RemoveAllRemoteBindings() { + _m.Called() +} + +// NodeManagementInterface_RemoveAllRemoteBindings_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllRemoteBindings' +type NodeManagementInterface_RemoveAllRemoteBindings_Call struct { + *mock.Call +} + +// RemoveAllRemoteBindings is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) RemoveAllRemoteBindings() *NodeManagementInterface_RemoveAllRemoteBindings_Call { + return &NodeManagementInterface_RemoveAllRemoteBindings_Call{Call: _e.mock.On("RemoveAllRemoteBindings")} +} + +func (_c *NodeManagementInterface_RemoveAllRemoteBindings_Call) Run(run func()) *NodeManagementInterface_RemoveAllRemoteBindings_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_RemoveAllRemoteBindings_Call) Return() *NodeManagementInterface_RemoveAllRemoteBindings_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_RemoveAllRemoteBindings_Call) RunAndReturn(run func()) *NodeManagementInterface_RemoveAllRemoteBindings_Call { + _c.Call.Return(run) + return _c +} + +// RemoveAllRemoteSubscriptions provides a mock function with given fields: +func (_m *NodeManagementInterface) RemoveAllRemoteSubscriptions() { + _m.Called() +} + +// NodeManagementInterface_RemoveAllRemoteSubscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllRemoteSubscriptions' +type NodeManagementInterface_RemoveAllRemoteSubscriptions_Call struct { + *mock.Call +} + +// RemoveAllRemoteSubscriptions is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) RemoveAllRemoteSubscriptions() *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call { + return &NodeManagementInterface_RemoveAllRemoteSubscriptions_Call{Call: _e.mock.On("RemoveAllRemoteSubscriptions")} +} + +func (_c *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call) Run(run func()) *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call) Return() *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call) RunAndReturn(run func()) *NodeManagementInterface_RemoveAllRemoteSubscriptions_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteBinding provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) RemoveRemoteBinding(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for RemoveRemoteBinding") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_RemoveRemoteBinding_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteBinding' +type NodeManagementInterface_RemoveRemoteBinding_Call struct { + *mock.Call +} + +// RemoveRemoteBinding is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) RemoveRemoteBinding(remoteAddress interface{}) *NodeManagementInterface_RemoveRemoteBinding_Call { + return &NodeManagementInterface_RemoveRemoteBinding_Call{Call: _e.mock.On("RemoveRemoteBinding", remoteAddress)} +} + +func (_c *NodeManagementInterface_RemoveRemoteBinding_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_RemoveRemoteBinding_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_RemoveRemoteBinding_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_RemoveRemoteBinding_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_RemoveRemoteBinding_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_RemoveRemoteBinding_Call { + _c.Call.Return(run) + return _c +} + +// RemoveRemoteSubscription provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) RemoveRemoteSubscription(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for RemoveRemoteSubscription") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_RemoveRemoteSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRemoteSubscription' +type NodeManagementInterface_RemoveRemoteSubscription_Call struct { + *mock.Call +} + +// RemoveRemoteSubscription is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) RemoveRemoteSubscription(remoteAddress interface{}) *NodeManagementInterface_RemoveRemoteSubscription_Call { + return &NodeManagementInterface_RemoveRemoteSubscription_Call{Call: _e.mock.On("RemoveRemoteSubscription", remoteAddress)} +} + +func (_c *NodeManagementInterface_RemoveRemoteSubscription_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_RemoveRemoteSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_RemoveRemoteSubscription_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_RemoveRemoteSubscription_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_RemoveRemoteSubscription_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_RemoveRemoteSubscription_Call { + _c.Call.Return(run) + return _c +} + +// RequestRemoteData provides a mock function with given fields: function, selector, elements, destination +func (_m *NodeManagementInterface) RequestRemoteData(function model.FunctionType, selector interface{}, elements interface{}, destination api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(function, selector, elements, destination) + + if len(ret) == 0 { + panic("no return value specified for RequestRemoteData") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(function, selector, elements, destination) + } + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) *model.MsgCounterType); ok { + r0 = rf(function, selector, elements, destination) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) *model.ErrorType); ok { + r1 = rf(function, selector, elements, destination) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_RequestRemoteData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestRemoteData' +type NodeManagementInterface_RequestRemoteData_Call struct { + *mock.Call +} + +// RequestRemoteData is a helper method to define mock.On call +// - function model.FunctionType +// - selector interface{} +// - elements interface{} +// - destination api.FeatureRemoteInterface +func (_e *NodeManagementInterface_Expecter) RequestRemoteData(function interface{}, selector interface{}, elements interface{}, destination interface{}) *NodeManagementInterface_RequestRemoteData_Call { + return &NodeManagementInterface_RequestRemoteData_Call{Call: _e.mock.On("RequestRemoteData", function, selector, elements, destination)} +} + +func (_c *NodeManagementInterface_RequestRemoteData_Call) Run(run func(function model.FunctionType, selector interface{}, elements interface{}, destination api.FeatureRemoteInterface)) *NodeManagementInterface_RequestRemoteData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{}), args[2].(interface{}), args[3].(api.FeatureRemoteInterface)) + }) + return _c +} + +func (_c *NodeManagementInterface_RequestRemoteData_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_RequestRemoteData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_RequestRemoteData_Call) RunAndReturn(run func(model.FunctionType, interface{}, interface{}, api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_RequestRemoteData_Call { + _c.Call.Return(run) + return _c +} + +// RequestRemoteDataBySenderAddress provides a mock function with given fields: cmd, sender, destinationSki, destinationAddress, maxDelay +func (_m *NodeManagementInterface) RequestRemoteDataBySenderAddress(cmd model.CmdType, sender api.SenderInterface, destinationSki string, destinationAddress *model.FeatureAddressType, maxDelay time.Duration) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(cmd, sender, destinationSki, destinationAddress, maxDelay) + + if len(ret) == 0 { + panic("no return value specified for RequestRemoteDataBySenderAddress") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } + if rf, ok := ret.Get(0).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) *model.MsgCounterType); ok { + r0 = rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) *model.ErrorType); ok { + r1 = rf(cmd, sender, destinationSki, destinationAddress, maxDelay) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_RequestRemoteDataBySenderAddress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RequestRemoteDataBySenderAddress' +type NodeManagementInterface_RequestRemoteDataBySenderAddress_Call struct { + *mock.Call +} + +// RequestRemoteDataBySenderAddress is a helper method to define mock.On call +// - cmd model.CmdType +// - sender api.SenderInterface +// - destinationSki string +// - destinationAddress *model.FeatureAddressType +// - maxDelay time.Duration +func (_e *NodeManagementInterface_Expecter) RequestRemoteDataBySenderAddress(cmd interface{}, sender interface{}, destinationSki interface{}, destinationAddress interface{}, maxDelay interface{}) *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call { + return &NodeManagementInterface_RequestRemoteDataBySenderAddress_Call{Call: _e.mock.On("RequestRemoteDataBySenderAddress", cmd, sender, destinationSki, destinationAddress, maxDelay)} +} + +func (_c *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call) Run(run func(cmd model.CmdType, sender api.SenderInterface, destinationSki string, destinationAddress *model.FeatureAddressType, maxDelay time.Duration)) *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.CmdType), args[1].(api.SenderInterface), args[2].(string), args[3].(*model.FeatureAddressType), args[4].(time.Duration)) + }) + return _c +} + +func (_c *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call) RunAndReturn(run func(model.CmdType, api.SenderInterface, string, *model.FeatureAddressType, time.Duration) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_RequestRemoteDataBySenderAddress_Call { + _c.Call.Return(run) + return _c +} + +// Role provides a mock function with given fields: +func (_m *NodeManagementInterface) Role() model.RoleType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Role") + } + + var r0 model.RoleType + if rf, ok := ret.Get(0).(func() model.RoleType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.RoleType) + } + + return r0 +} + +// NodeManagementInterface_Role_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Role' +type NodeManagementInterface_Role_Call struct { + *mock.Call +} + +// Role is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Role() *NodeManagementInterface_Role_Call { + return &NodeManagementInterface_Role_Call{Call: _e.mock.On("Role")} +} + +func (_c *NodeManagementInterface_Role_Call) Run(run func()) *NodeManagementInterface_Role_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Role_Call) Return(_a0 model.RoleType) *NodeManagementInterface_Role_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Role_Call) RunAndReturn(run func() model.RoleType) *NodeManagementInterface_Role_Call { + _c.Call.Return(run) + return _c +} + +// SetData provides a mock function with given fields: function, data +func (_m *NodeManagementInterface) SetData(function model.FunctionType, data interface{}) { + _m.Called(function, data) +} + +// NodeManagementInterface_SetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetData' +type NodeManagementInterface_SetData_Call struct { + *mock.Call +} + +// SetData is a helper method to define mock.On call +// - function model.FunctionType +// - data interface{} +func (_e *NodeManagementInterface_Expecter) SetData(function interface{}, data interface{}) *NodeManagementInterface_SetData_Call { + return &NodeManagementInterface_SetData_Call{Call: _e.mock.On("SetData", function, data)} +} + +func (_c *NodeManagementInterface_SetData_Call) Run(run func(function model.FunctionType, data interface{})) *NodeManagementInterface_SetData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{})) + }) + return _c +} + +func (_c *NodeManagementInterface_SetData_Call) Return() *NodeManagementInterface_SetData_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_SetData_Call) RunAndReturn(run func(model.FunctionType, interface{})) *NodeManagementInterface_SetData_Call { + _c.Call.Return(run) + return _c +} + +// SetDescription provides a mock function with given fields: desc +func (_m *NodeManagementInterface) SetDescription(desc *model.DescriptionType) { + _m.Called(desc) +} + +// NodeManagementInterface_SetDescription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescription' +type NodeManagementInterface_SetDescription_Call struct { + *mock.Call +} + +// SetDescription is a helper method to define mock.On call +// - desc *model.DescriptionType +func (_e *NodeManagementInterface_Expecter) SetDescription(desc interface{}) *NodeManagementInterface_SetDescription_Call { + return &NodeManagementInterface_SetDescription_Call{Call: _e.mock.On("SetDescription", desc)} +} + +func (_c *NodeManagementInterface_SetDescription_Call) Run(run func(desc *model.DescriptionType)) *NodeManagementInterface_SetDescription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.DescriptionType)) + }) + return _c +} + +func (_c *NodeManagementInterface_SetDescription_Call) Return() *NodeManagementInterface_SetDescription_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_SetDescription_Call) RunAndReturn(run func(*model.DescriptionType)) *NodeManagementInterface_SetDescription_Call { + _c.Call.Return(run) + return _c +} + +// SetDescriptionString provides a mock function with given fields: s +func (_m *NodeManagementInterface) SetDescriptionString(s string) { + _m.Called(s) +} + +// NodeManagementInterface_SetDescriptionString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetDescriptionString' +type NodeManagementInterface_SetDescriptionString_Call struct { + *mock.Call +} + +// SetDescriptionString is a helper method to define mock.On call +// - s string +func (_e *NodeManagementInterface_Expecter) SetDescriptionString(s interface{}) *NodeManagementInterface_SetDescriptionString_Call { + return &NodeManagementInterface_SetDescriptionString_Call{Call: _e.mock.On("SetDescriptionString", s)} +} + +func (_c *NodeManagementInterface_SetDescriptionString_Call) Run(run func(s string)) *NodeManagementInterface_SetDescriptionString_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *NodeManagementInterface_SetDescriptionString_Call) Return() *NodeManagementInterface_SetDescriptionString_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_SetDescriptionString_Call) RunAndReturn(run func(string)) *NodeManagementInterface_SetDescriptionString_Call { + _c.Call.Return(run) + return _c +} + +// SetWriteApprovalTimeout provides a mock function with given fields: duration +func (_m *NodeManagementInterface) SetWriteApprovalTimeout(duration time.Duration) { + _m.Called(duration) +} + +// NodeManagementInterface_SetWriteApprovalTimeout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetWriteApprovalTimeout' +type NodeManagementInterface_SetWriteApprovalTimeout_Call struct { + *mock.Call +} + +// SetWriteApprovalTimeout is a helper method to define mock.On call +// - duration time.Duration +func (_e *NodeManagementInterface_Expecter) SetWriteApprovalTimeout(duration interface{}) *NodeManagementInterface_SetWriteApprovalTimeout_Call { + return &NodeManagementInterface_SetWriteApprovalTimeout_Call{Call: _e.mock.On("SetWriteApprovalTimeout", duration)} +} + +func (_c *NodeManagementInterface_SetWriteApprovalTimeout_Call) Run(run func(duration time.Duration)) *NodeManagementInterface_SetWriteApprovalTimeout_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration)) + }) + return _c +} + +func (_c *NodeManagementInterface_SetWriteApprovalTimeout_Call) Return() *NodeManagementInterface_SetWriteApprovalTimeout_Call { + _c.Call.Return() + return _c +} + +func (_c *NodeManagementInterface_SetWriteApprovalTimeout_Call) RunAndReturn(run func(time.Duration)) *NodeManagementInterface_SetWriteApprovalTimeout_Call { + _c.Call.Return(run) + return _c +} + +// String provides a mock function with given fields: +func (_m *NodeManagementInterface) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// NodeManagementInterface_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' +type NodeManagementInterface_String_Call struct { + *mock.Call +} + +// String is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) String() *NodeManagementInterface_String_Call { + return &NodeManagementInterface_String_Call{Call: _e.mock.On("String")} +} + +func (_c *NodeManagementInterface_String_Call) Run(run func()) *NodeManagementInterface_String_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_String_Call) Return(_a0 string) *NodeManagementInterface_String_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_String_Call) RunAndReturn(run func() string) *NodeManagementInterface_String_Call { + _c.Call.Return(run) + return _c +} + +// SubscribeToRemote provides a mock function with given fields: remoteAddress +func (_m *NodeManagementInterface) SubscribeToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + ret := _m.Called(remoteAddress) + + if len(ret) == 0 { + panic("no return value specified for SubscribeToRemote") + } + + var r0 *model.MsgCounterType + var r1 *model.ErrorType + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)); ok { + return rf(remoteAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(remoteAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType) *model.ErrorType); ok { + r1 = rf(remoteAddress) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*model.ErrorType) + } + } + + return r0, r1 +} + +// NodeManagementInterface_SubscribeToRemote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeToRemote' +type NodeManagementInterface_SubscribeToRemote_Call struct { + *mock.Call +} + +// SubscribeToRemote is a helper method to define mock.On call +// - remoteAddress *model.FeatureAddressType +func (_e *NodeManagementInterface_Expecter) SubscribeToRemote(remoteAddress interface{}) *NodeManagementInterface_SubscribeToRemote_Call { + return &NodeManagementInterface_SubscribeToRemote_Call{Call: _e.mock.On("SubscribeToRemote", remoteAddress)} +} + +func (_c *NodeManagementInterface_SubscribeToRemote_Call) Run(run func(remoteAddress *model.FeatureAddressType)) *NodeManagementInterface_SubscribeToRemote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *NodeManagementInterface_SubscribeToRemote_Call) Return(_a0 *model.MsgCounterType, _a1 *model.ErrorType) *NodeManagementInterface_SubscribeToRemote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *NodeManagementInterface_SubscribeToRemote_Call) RunAndReturn(run func(*model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType)) *NodeManagementInterface_SubscribeToRemote_Call { + _c.Call.Return(run) + return _c +} + +// Type provides a mock function with given fields: +func (_m *NodeManagementInterface) Type() model.FeatureTypeType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Type") + } + + var r0 model.FeatureTypeType + if rf, ok := ret.Get(0).(func() model.FeatureTypeType); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(model.FeatureTypeType) + } + + return r0 +} + +// NodeManagementInterface_Type_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Type' +type NodeManagementInterface_Type_Call struct { + *mock.Call +} + +// Type is a helper method to define mock.On call +func (_e *NodeManagementInterface_Expecter) Type() *NodeManagementInterface_Type_Call { + return &NodeManagementInterface_Type_Call{Call: _e.mock.On("Type")} +} + +func (_c *NodeManagementInterface_Type_Call) Run(run func()) *NodeManagementInterface_Type_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *NodeManagementInterface_Type_Call) Return(_a0 model.FeatureTypeType) *NodeManagementInterface_Type_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_Type_Call) RunAndReturn(run func() model.FeatureTypeType) *NodeManagementInterface_Type_Call { + _c.Call.Return(run) + return _c +} + +// UpdateData provides a mock function with given fields: function, data, filterPartial, filterDelete +func (_m *NodeManagementInterface) UpdateData(function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType) *model.ErrorType { + ret := _m.Called(function, data, filterPartial, filterDelete) + + if len(ret) == 0 { + panic("no return value specified for UpdateData") + } + + var r0 *model.ErrorType + if rf, ok := ret.Get(0).(func(model.FunctionType, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType); ok { + r0 = rf(function, data, filterPartial, filterDelete) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ErrorType) + } + } + + return r0 +} + +// NodeManagementInterface_UpdateData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateData' +type NodeManagementInterface_UpdateData_Call struct { + *mock.Call +} + +// UpdateData is a helper method to define mock.On call +// - function model.FunctionType +// - data interface{} +// - filterPartial *model.FilterType +// - filterDelete *model.FilterType +func (_e *NodeManagementInterface_Expecter) UpdateData(function interface{}, data interface{}, filterPartial interface{}, filterDelete interface{}) *NodeManagementInterface_UpdateData_Call { + return &NodeManagementInterface_UpdateData_Call{Call: _e.mock.On("UpdateData", function, data, filterPartial, filterDelete)} +} + +func (_c *NodeManagementInterface_UpdateData_Call) Run(run func(function model.FunctionType, data interface{}, filterPartial *model.FilterType, filterDelete *model.FilterType)) *NodeManagementInterface_UpdateData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FunctionType), args[1].(interface{}), args[2].(*model.FilterType), args[3].(*model.FilterType)) + }) + return _c +} + +func (_c *NodeManagementInterface_UpdateData_Call) Return(_a0 *model.ErrorType) *NodeManagementInterface_UpdateData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *NodeManagementInterface_UpdateData_Call) RunAndReturn(run func(model.FunctionType, interface{}, *model.FilterType, *model.FilterType) *model.ErrorType) *NodeManagementInterface_UpdateData_Call { + _c.Call.Return(run) + return _c +} + +// NewNodeManagementInterface creates a new instance of NodeManagementInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewNodeManagementInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *NodeManagementInterface { + mock := &NodeManagementInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/OperationsInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/OperationsInterface.go new file mode 100644 index 0000000..e226e03 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/OperationsInterface.go @@ -0,0 +1,307 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// OperationsInterface is an autogenerated mock type for the OperationsInterface type +type OperationsInterface struct { + mock.Mock +} + +type OperationsInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *OperationsInterface) EXPECT() *OperationsInterface_Expecter { + return &OperationsInterface_Expecter{mock: &_m.Mock} +} + +// Information provides a mock function with given fields: +func (_m *OperationsInterface) Information() *model.PossibleOperationsType { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Information") + } + + var r0 *model.PossibleOperationsType + if rf, ok := ret.Get(0).(func() *model.PossibleOperationsType); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.PossibleOperationsType) + } + } + + return r0 +} + +// OperationsInterface_Information_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Information' +type OperationsInterface_Information_Call struct { + *mock.Call +} + +// Information is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) Information() *OperationsInterface_Information_Call { + return &OperationsInterface_Information_Call{Call: _e.mock.On("Information")} +} + +func (_c *OperationsInterface_Information_Call) Run(run func()) *OperationsInterface_Information_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_Information_Call) Return(_a0 *model.PossibleOperationsType) *OperationsInterface_Information_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_Information_Call) RunAndReturn(run func() *model.PossibleOperationsType) *OperationsInterface_Information_Call { + _c.Call.Return(run) + return _c +} + +// Read provides a mock function with given fields: +func (_m *OperationsInterface) Read() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Read") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// OperationsInterface_Read_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Read' +type OperationsInterface_Read_Call struct { + *mock.Call +} + +// Read is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) Read() *OperationsInterface_Read_Call { + return &OperationsInterface_Read_Call{Call: _e.mock.On("Read")} +} + +func (_c *OperationsInterface_Read_Call) Run(run func()) *OperationsInterface_Read_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_Read_Call) Return(_a0 bool) *OperationsInterface_Read_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_Read_Call) RunAndReturn(run func() bool) *OperationsInterface_Read_Call { + _c.Call.Return(run) + return _c +} + +// ReadPartial provides a mock function with given fields: +func (_m *OperationsInterface) ReadPartial() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ReadPartial") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// OperationsInterface_ReadPartial_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadPartial' +type OperationsInterface_ReadPartial_Call struct { + *mock.Call +} + +// ReadPartial is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) ReadPartial() *OperationsInterface_ReadPartial_Call { + return &OperationsInterface_ReadPartial_Call{Call: _e.mock.On("ReadPartial")} +} + +func (_c *OperationsInterface_ReadPartial_Call) Run(run func()) *OperationsInterface_ReadPartial_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_ReadPartial_Call) Return(_a0 bool) *OperationsInterface_ReadPartial_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_ReadPartial_Call) RunAndReturn(run func() bool) *OperationsInterface_ReadPartial_Call { + _c.Call.Return(run) + return _c +} + +// String provides a mock function with given fields: +func (_m *OperationsInterface) String() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for String") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// OperationsInterface_String_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'String' +type OperationsInterface_String_Call struct { + *mock.Call +} + +// String is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) String() *OperationsInterface_String_Call { + return &OperationsInterface_String_Call{Call: _e.mock.On("String")} +} + +func (_c *OperationsInterface_String_Call) Run(run func()) *OperationsInterface_String_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_String_Call) Return(_a0 string) *OperationsInterface_String_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_String_Call) RunAndReturn(run func() string) *OperationsInterface_String_Call { + _c.Call.Return(run) + return _c +} + +// Write provides a mock function with given fields: +func (_m *OperationsInterface) Write() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Write") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// OperationsInterface_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write' +type OperationsInterface_Write_Call struct { + *mock.Call +} + +// Write is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) Write() *OperationsInterface_Write_Call { + return &OperationsInterface_Write_Call{Call: _e.mock.On("Write")} +} + +func (_c *OperationsInterface_Write_Call) Run(run func()) *OperationsInterface_Write_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_Write_Call) Return(_a0 bool) *OperationsInterface_Write_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_Write_Call) RunAndReturn(run func() bool) *OperationsInterface_Write_Call { + _c.Call.Return(run) + return _c +} + +// WritePartial provides a mock function with given fields: +func (_m *OperationsInterface) WritePartial() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for WritePartial") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// OperationsInterface_WritePartial_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WritePartial' +type OperationsInterface_WritePartial_Call struct { + *mock.Call +} + +// WritePartial is a helper method to define mock.On call +func (_e *OperationsInterface_Expecter) WritePartial() *OperationsInterface_WritePartial_Call { + return &OperationsInterface_WritePartial_Call{Call: _e.mock.On("WritePartial")} +} + +func (_c *OperationsInterface_WritePartial_Call) Run(run func()) *OperationsInterface_WritePartial_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *OperationsInterface_WritePartial_Call) Return(_a0 bool) *OperationsInterface_WritePartial_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *OperationsInterface_WritePartial_Call) RunAndReturn(run func() bool) *OperationsInterface_WritePartial_Call { + _c.Call.Return(run) + return _c +} + +// NewOperationsInterface creates a new instance of OperationsInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewOperationsInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *OperationsInterface { + mock := &OperationsInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/SenderInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/SenderInterface.go new file mode 100644 index 0000000..8d62fac --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/SenderInterface.go @@ -0,0 +1,687 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + model "github.com/enbility/spine-go/model" + mock "github.com/stretchr/testify/mock" +) + +// SenderInterface is an autogenerated mock type for the SenderInterface type +type SenderInterface struct { + mock.Mock +} + +type SenderInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *SenderInterface) EXPECT() *SenderInterface_Expecter { + return &SenderInterface_Expecter{mock: &_m.Mock} +} + +// Bind provides a mock function with given fields: senderAddress, destinationAddress, serverFeatureType +func (_m *SenderInterface) Bind(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress, serverFeatureType) + + if len(ret) == 0 { + panic("no return value specified for Bind") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress, serverFeatureType) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress, serverFeatureType) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) error); ok { + r1 = rf(senderAddress, destinationAddress, serverFeatureType) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Bind_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bind' +type SenderInterface_Bind_Call struct { + *mock.Call +} + +// Bind is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +// - serverFeatureType model.FeatureTypeType +func (_e *SenderInterface_Expecter) Bind(senderAddress interface{}, destinationAddress interface{}, serverFeatureType interface{}) *SenderInterface_Bind_Call { + return &SenderInterface_Bind_Call{Call: _e.mock.On("Bind", senderAddress, destinationAddress, serverFeatureType)} +} + +func (_c *SenderInterface_Bind_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType)) *SenderInterface_Bind_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType), args[2].(model.FeatureTypeType)) + }) + return _c +} + +func (_c *SenderInterface_Bind_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Bind_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Bind_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) (*model.MsgCounterType, error)) *SenderInterface_Bind_Call { + _c.Call.Return(run) + return _c +} + +// DatagramForMsgCounter provides a mock function with given fields: msgCounter +func (_m *SenderInterface) DatagramForMsgCounter(msgCounter model.MsgCounterType) (model.DatagramType, error) { + ret := _m.Called(msgCounter) + + if len(ret) == 0 { + panic("no return value specified for DatagramForMsgCounter") + } + + var r0 model.DatagramType + var r1 error + if rf, ok := ret.Get(0).(func(model.MsgCounterType) (model.DatagramType, error)); ok { + return rf(msgCounter) + } + if rf, ok := ret.Get(0).(func(model.MsgCounterType) model.DatagramType); ok { + r0 = rf(msgCounter) + } else { + r0 = ret.Get(0).(model.DatagramType) + } + + if rf, ok := ret.Get(1).(func(model.MsgCounterType) error); ok { + r1 = rf(msgCounter) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_DatagramForMsgCounter_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DatagramForMsgCounter' +type SenderInterface_DatagramForMsgCounter_Call struct { + *mock.Call +} + +// DatagramForMsgCounter is a helper method to define mock.On call +// - msgCounter model.MsgCounterType +func (_e *SenderInterface_Expecter) DatagramForMsgCounter(msgCounter interface{}) *SenderInterface_DatagramForMsgCounter_Call { + return &SenderInterface_DatagramForMsgCounter_Call{Call: _e.mock.On("DatagramForMsgCounter", msgCounter)} +} + +func (_c *SenderInterface_DatagramForMsgCounter_Call) Run(run func(msgCounter model.MsgCounterType)) *SenderInterface_DatagramForMsgCounter_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.MsgCounterType)) + }) + return _c +} + +func (_c *SenderInterface_DatagramForMsgCounter_Call) Return(_a0 model.DatagramType, _a1 error) *SenderInterface_DatagramForMsgCounter_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_DatagramForMsgCounter_Call) RunAndReturn(run func(model.MsgCounterType) (model.DatagramType, error)) *SenderInterface_DatagramForMsgCounter_Call { + _c.Call.Return(run) + return _c +} + +// Notify provides a mock function with given fields: senderAddress, destinationAddress, cmd +func (_m *SenderInterface) Notify(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress, cmd) + + if len(ret) == 0 { + panic("no return value specified for Notify") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress, cmd) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress, cmd) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) error); ok { + r1 = rf(senderAddress, destinationAddress, cmd) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Notify_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Notify' +type SenderInterface_Notify_Call struct { + *mock.Call +} + +// Notify is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +// - cmd model.CmdType +func (_e *SenderInterface_Expecter) Notify(senderAddress interface{}, destinationAddress interface{}, cmd interface{}) *SenderInterface_Notify_Call { + return &SenderInterface_Notify_Call{Call: _e.mock.On("Notify", senderAddress, destinationAddress, cmd)} +} + +func (_c *SenderInterface_Notify_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, cmd model.CmdType)) *SenderInterface_Notify_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType), args[2].(model.CmdType)) + }) + return _c +} + +func (_c *SenderInterface_Notify_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Notify_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Notify_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) (*model.MsgCounterType, error)) *SenderInterface_Notify_Call { + _c.Call.Return(run) + return _c +} + +// ProcessResponseForMsgCounterReference provides a mock function with given fields: msgCounterRef +func (_m *SenderInterface) ProcessResponseForMsgCounterReference(msgCounterRef *model.MsgCounterType) { + _m.Called(msgCounterRef) +} + +// SenderInterface_ProcessResponseForMsgCounterReference_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessResponseForMsgCounterReference' +type SenderInterface_ProcessResponseForMsgCounterReference_Call struct { + *mock.Call +} + +// ProcessResponseForMsgCounterReference is a helper method to define mock.On call +// - msgCounterRef *model.MsgCounterType +func (_e *SenderInterface_Expecter) ProcessResponseForMsgCounterReference(msgCounterRef interface{}) *SenderInterface_ProcessResponseForMsgCounterReference_Call { + return &SenderInterface_ProcessResponseForMsgCounterReference_Call{Call: _e.mock.On("ProcessResponseForMsgCounterReference", msgCounterRef)} +} + +func (_c *SenderInterface_ProcessResponseForMsgCounterReference_Call) Run(run func(msgCounterRef *model.MsgCounterType)) *SenderInterface_ProcessResponseForMsgCounterReference_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.MsgCounterType)) + }) + return _c +} + +func (_c *SenderInterface_ProcessResponseForMsgCounterReference_Call) Return() *SenderInterface_ProcessResponseForMsgCounterReference_Call { + _c.Call.Return() + return _c +} + +func (_c *SenderInterface_ProcessResponseForMsgCounterReference_Call) RunAndReturn(run func(*model.MsgCounterType)) *SenderInterface_ProcessResponseForMsgCounterReference_Call { + _c.Call.Return(run) + return _c +} + +// Reply provides a mock function with given fields: requestHeader, senderAddress, cmd +func (_m *SenderInterface) Reply(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, cmd model.CmdType) error { + ret := _m.Called(requestHeader, senderAddress, cmd) + + if len(ret) == 0 { + panic("no return value specified for Reply") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*model.HeaderType, *model.FeatureAddressType, model.CmdType) error); ok { + r0 = rf(requestHeader, senderAddress, cmd) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SenderInterface_Reply_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Reply' +type SenderInterface_Reply_Call struct { + *mock.Call +} + +// Reply is a helper method to define mock.On call +// - requestHeader *model.HeaderType +// - senderAddress *model.FeatureAddressType +// - cmd model.CmdType +func (_e *SenderInterface_Expecter) Reply(requestHeader interface{}, senderAddress interface{}, cmd interface{}) *SenderInterface_Reply_Call { + return &SenderInterface_Reply_Call{Call: _e.mock.On("Reply", requestHeader, senderAddress, cmd)} +} + +func (_c *SenderInterface_Reply_Call) Run(run func(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, cmd model.CmdType)) *SenderInterface_Reply_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.HeaderType), args[1].(*model.FeatureAddressType), args[2].(model.CmdType)) + }) + return _c +} + +func (_c *SenderInterface_Reply_Call) Return(_a0 error) *SenderInterface_Reply_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SenderInterface_Reply_Call) RunAndReturn(run func(*model.HeaderType, *model.FeatureAddressType, model.CmdType) error) *SenderInterface_Reply_Call { + _c.Call.Return(run) + return _c +} + +// Request provides a mock function with given fields: cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd +func (_m *SenderInterface) Request(cmdClassifier model.CmdClassifierType, senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, ackRequest bool, cmd []model.CmdType) (*model.MsgCounterType, error) { + ret := _m.Called(cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd) + + if len(ret) == 0 { + panic("no return value specified for Request") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(model.CmdClassifierType, *model.FeatureAddressType, *model.FeatureAddressType, bool, []model.CmdType) (*model.MsgCounterType, error)); ok { + return rf(cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd) + } + if rf, ok := ret.Get(0).(func(model.CmdClassifierType, *model.FeatureAddressType, *model.FeatureAddressType, bool, []model.CmdType) *model.MsgCounterType); ok { + r0 = rf(cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(model.CmdClassifierType, *model.FeatureAddressType, *model.FeatureAddressType, bool, []model.CmdType) error); ok { + r1 = rf(cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Request_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Request' +type SenderInterface_Request_Call struct { + *mock.Call +} + +// Request is a helper method to define mock.On call +// - cmdClassifier model.CmdClassifierType +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +// - ackRequest bool +// - cmd []model.CmdType +func (_e *SenderInterface_Expecter) Request(cmdClassifier interface{}, senderAddress interface{}, destinationAddress interface{}, ackRequest interface{}, cmd interface{}) *SenderInterface_Request_Call { + return &SenderInterface_Request_Call{Call: _e.mock.On("Request", cmdClassifier, senderAddress, destinationAddress, ackRequest, cmd)} +} + +func (_c *SenderInterface_Request_Call) Run(run func(cmdClassifier model.CmdClassifierType, senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, ackRequest bool, cmd []model.CmdType)) *SenderInterface_Request_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.CmdClassifierType), args[1].(*model.FeatureAddressType), args[2].(*model.FeatureAddressType), args[3].(bool), args[4].([]model.CmdType)) + }) + return _c +} + +func (_c *SenderInterface_Request_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Request_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Request_Call) RunAndReturn(run func(model.CmdClassifierType, *model.FeatureAddressType, *model.FeatureAddressType, bool, []model.CmdType) (*model.MsgCounterType, error)) *SenderInterface_Request_Call { + _c.Call.Return(run) + return _c +} + +// ResultError provides a mock function with given fields: requestHeader, senderAddress, err +func (_m *SenderInterface) ResultError(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, err *model.ErrorType) error { + ret := _m.Called(requestHeader, senderAddress, err) + + if len(ret) == 0 { + panic("no return value specified for ResultError") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*model.HeaderType, *model.FeatureAddressType, *model.ErrorType) error); ok { + r0 = rf(requestHeader, senderAddress, err) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SenderInterface_ResultError_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultError' +type SenderInterface_ResultError_Call struct { + *mock.Call +} + +// ResultError is a helper method to define mock.On call +// - requestHeader *model.HeaderType +// - senderAddress *model.FeatureAddressType +// - err *model.ErrorType +func (_e *SenderInterface_Expecter) ResultError(requestHeader interface{}, senderAddress interface{}, err interface{}) *SenderInterface_ResultError_Call { + return &SenderInterface_ResultError_Call{Call: _e.mock.On("ResultError", requestHeader, senderAddress, err)} +} + +func (_c *SenderInterface_ResultError_Call) Run(run func(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, err *model.ErrorType)) *SenderInterface_ResultError_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.HeaderType), args[1].(*model.FeatureAddressType), args[2].(*model.ErrorType)) + }) + return _c +} + +func (_c *SenderInterface_ResultError_Call) Return(_a0 error) *SenderInterface_ResultError_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SenderInterface_ResultError_Call) RunAndReturn(run func(*model.HeaderType, *model.FeatureAddressType, *model.ErrorType) error) *SenderInterface_ResultError_Call { + _c.Call.Return(run) + return _c +} + +// ResultSuccess provides a mock function with given fields: requestHeader, senderAddress +func (_m *SenderInterface) ResultSuccess(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType) error { + ret := _m.Called(requestHeader, senderAddress) + + if len(ret) == 0 { + panic("no return value specified for ResultSuccess") + } + + var r0 error + if rf, ok := ret.Get(0).(func(*model.HeaderType, *model.FeatureAddressType) error); ok { + r0 = rf(requestHeader, senderAddress) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SenderInterface_ResultSuccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultSuccess' +type SenderInterface_ResultSuccess_Call struct { + *mock.Call +} + +// ResultSuccess is a helper method to define mock.On call +// - requestHeader *model.HeaderType +// - senderAddress *model.FeatureAddressType +func (_e *SenderInterface_Expecter) ResultSuccess(requestHeader interface{}, senderAddress interface{}) *SenderInterface_ResultSuccess_Call { + return &SenderInterface_ResultSuccess_Call{Call: _e.mock.On("ResultSuccess", requestHeader, senderAddress)} +} + +func (_c *SenderInterface_ResultSuccess_Call) Run(run func(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType)) *SenderInterface_ResultSuccess_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.HeaderType), args[1].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *SenderInterface_ResultSuccess_Call) Return(_a0 error) *SenderInterface_ResultSuccess_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SenderInterface_ResultSuccess_Call) RunAndReturn(run func(*model.HeaderType, *model.FeatureAddressType) error) *SenderInterface_ResultSuccess_Call { + _c.Call.Return(run) + return _c +} + +// Subscribe provides a mock function with given fields: senderAddress, destinationAddress, serverFeatureType +func (_m *SenderInterface) Subscribe(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress, serverFeatureType) + + if len(ret) == 0 { + panic("no return value specified for Subscribe") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress, serverFeatureType) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress, serverFeatureType) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) error); ok { + r1 = rf(senderAddress, destinationAddress, serverFeatureType) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe' +type SenderInterface_Subscribe_Call struct { + *mock.Call +} + +// Subscribe is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +// - serverFeatureType model.FeatureTypeType +func (_e *SenderInterface_Expecter) Subscribe(senderAddress interface{}, destinationAddress interface{}, serverFeatureType interface{}) *SenderInterface_Subscribe_Call { + return &SenderInterface_Subscribe_Call{Call: _e.mock.On("Subscribe", senderAddress, destinationAddress, serverFeatureType)} +} + +func (_c *SenderInterface_Subscribe_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType)) *SenderInterface_Subscribe_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType), args[2].(model.FeatureTypeType)) + }) + return _c +} + +func (_c *SenderInterface_Subscribe_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Subscribe_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Subscribe_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType, model.FeatureTypeType) (*model.MsgCounterType, error)) *SenderInterface_Subscribe_Call { + _c.Call.Return(run) + return _c +} + +// Unbind provides a mock function with given fields: senderAddress, destinationAddress +func (_m *SenderInterface) Unbind(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress) + + if len(ret) == 0 { + panic("no return value specified for Unbind") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType) error); ok { + r1 = rf(senderAddress, destinationAddress) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Unbind_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unbind' +type SenderInterface_Unbind_Call struct { + *mock.Call +} + +// Unbind is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +func (_e *SenderInterface_Expecter) Unbind(senderAddress interface{}, destinationAddress interface{}) *SenderInterface_Unbind_Call { + return &SenderInterface_Unbind_Call{Call: _e.mock.On("Unbind", senderAddress, destinationAddress)} +} + +func (_c *SenderInterface_Unbind_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType)) *SenderInterface_Unbind_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *SenderInterface_Unbind_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Unbind_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Unbind_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType) (*model.MsgCounterType, error)) *SenderInterface_Unbind_Call { + _c.Call.Return(run) + return _c +} + +// Unsubscribe provides a mock function with given fields: senderAddress, destinationAddress +func (_m *SenderInterface) Unsubscribe(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress) + + if len(ret) == 0 { + panic("no return value specified for Unsubscribe") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType) error); ok { + r1 = rf(senderAddress, destinationAddress) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Unsubscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Unsubscribe' +type SenderInterface_Unsubscribe_Call struct { + *mock.Call +} + +// Unsubscribe is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +func (_e *SenderInterface_Expecter) Unsubscribe(senderAddress interface{}, destinationAddress interface{}) *SenderInterface_Unsubscribe_Call { + return &SenderInterface_Unsubscribe_Call{Call: _e.mock.On("Unsubscribe", senderAddress, destinationAddress)} +} + +func (_c *SenderInterface_Unsubscribe_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType)) *SenderInterface_Unsubscribe_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType)) + }) + return _c +} + +func (_c *SenderInterface_Unsubscribe_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Unsubscribe_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Unsubscribe_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType) (*model.MsgCounterType, error)) *SenderInterface_Unsubscribe_Call { + _c.Call.Return(run) + return _c +} + +// Write provides a mock function with given fields: senderAddress, destinationAddress, cmd +func (_m *SenderInterface) Write(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) { + ret := _m.Called(senderAddress, destinationAddress, cmd) + + if len(ret) == 0 { + panic("no return value specified for Write") + } + + var r0 *model.MsgCounterType + var r1 error + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) (*model.MsgCounterType, error)); ok { + return rf(senderAddress, destinationAddress, cmd) + } + if rf, ok := ret.Get(0).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) *model.MsgCounterType); ok { + r0 = rf(senderAddress, destinationAddress, cmd) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.MsgCounterType) + } + } + + if rf, ok := ret.Get(1).(func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) error); ok { + r1 = rf(senderAddress, destinationAddress, cmd) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// SenderInterface_Write_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Write' +type SenderInterface_Write_Call struct { + *mock.Call +} + +// Write is a helper method to define mock.On call +// - senderAddress *model.FeatureAddressType +// - destinationAddress *model.FeatureAddressType +// - cmd model.CmdType +func (_e *SenderInterface_Expecter) Write(senderAddress interface{}, destinationAddress interface{}, cmd interface{}) *SenderInterface_Write_Call { + return &SenderInterface_Write_Call{Call: _e.mock.On("Write", senderAddress, destinationAddress, cmd)} +} + +func (_c *SenderInterface_Write_Call) Run(run func(senderAddress *model.FeatureAddressType, destinationAddress *model.FeatureAddressType, cmd model.CmdType)) *SenderInterface_Write_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*model.FeatureAddressType), args[1].(*model.FeatureAddressType), args[2].(model.CmdType)) + }) + return _c +} + +func (_c *SenderInterface_Write_Call) Return(_a0 *model.MsgCounterType, _a1 error) *SenderInterface_Write_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SenderInterface_Write_Call) RunAndReturn(run func(*model.FeatureAddressType, *model.FeatureAddressType, model.CmdType) (*model.MsgCounterType, error)) *SenderInterface_Write_Call { + _c.Call.Return(run) + return _c +} + +// NewSenderInterface creates a new instance of SenderInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSenderInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *SenderInterface { + mock := &SenderInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/SubscriptionManagerInterface.go b/src/eebus-bridge/third_party/spine-go/mocks/SubscriptionManagerInterface.go new file mode 100644 index 0000000..e999d44 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/SubscriptionManagerInterface.go @@ -0,0 +1,293 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" +) + +// SubscriptionManagerInterface is an autogenerated mock type for the SubscriptionManagerInterface type +type SubscriptionManagerInterface struct { + mock.Mock +} + +type SubscriptionManagerInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *SubscriptionManagerInterface) EXPECT() *SubscriptionManagerInterface_Expecter { + return &SubscriptionManagerInterface_Expecter{mock: &_m.Mock} +} + +// AddSubscription provides a mock function with given fields: remoteDevice, data +func (_m *SubscriptionManagerInterface) AddSubscription(remoteDevice api.DeviceRemoteInterface, data model.SubscriptionManagementRequestCallType) error { + ret := _m.Called(remoteDevice, data) + + if len(ret) == 0 { + panic("no return value specified for AddSubscription") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface, model.SubscriptionManagementRequestCallType) error); ok { + r0 = rf(remoteDevice, data) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubscriptionManagerInterface_AddSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddSubscription' +type SubscriptionManagerInterface_AddSubscription_Call struct { + *mock.Call +} + +// AddSubscription is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +// - data model.SubscriptionManagementRequestCallType +func (_e *SubscriptionManagerInterface_Expecter) AddSubscription(remoteDevice interface{}, data interface{}) *SubscriptionManagerInterface_AddSubscription_Call { + return &SubscriptionManagerInterface_AddSubscription_Call{Call: _e.mock.On("AddSubscription", remoteDevice, data)} +} + +func (_c *SubscriptionManagerInterface_AddSubscription_Call) Run(run func(remoteDevice api.DeviceRemoteInterface, data model.SubscriptionManagementRequestCallType)) *SubscriptionManagerInterface_AddSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface), args[1].(model.SubscriptionManagementRequestCallType)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_AddSubscription_Call) Return(_a0 error) *SubscriptionManagerInterface_AddSubscription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SubscriptionManagerInterface_AddSubscription_Call) RunAndReturn(run func(api.DeviceRemoteInterface, model.SubscriptionManagementRequestCallType) error) *SubscriptionManagerInterface_AddSubscription_Call { + _c.Call.Return(run) + return _c +} + +// RemoveSubscription provides a mock function with given fields: data, remoteDevice +func (_m *SubscriptionManagerInterface) RemoveSubscription(data model.SubscriptionManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface) error { + ret := _m.Called(data, remoteDevice) + + if len(ret) == 0 { + panic("no return value specified for RemoveSubscription") + } + + var r0 error + if rf, ok := ret.Get(0).(func(model.SubscriptionManagementDeleteCallType, api.DeviceRemoteInterface) error); ok { + r0 = rf(data, remoteDevice) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SubscriptionManagerInterface_RemoveSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveSubscription' +type SubscriptionManagerInterface_RemoveSubscription_Call struct { + *mock.Call +} + +// RemoveSubscription is a helper method to define mock.On call +// - data model.SubscriptionManagementDeleteCallType +// - remoteDevice api.DeviceRemoteInterface +func (_e *SubscriptionManagerInterface_Expecter) RemoveSubscription(data interface{}, remoteDevice interface{}) *SubscriptionManagerInterface_RemoveSubscription_Call { + return &SubscriptionManagerInterface_RemoveSubscription_Call{Call: _e.mock.On("RemoveSubscription", data, remoteDevice)} +} + +func (_c *SubscriptionManagerInterface_RemoveSubscription_Call) Run(run func(data model.SubscriptionManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface)) *SubscriptionManagerInterface_RemoveSubscription_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.SubscriptionManagementDeleteCallType), args[1].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscription_Call) Return(_a0 error) *SubscriptionManagerInterface_RemoveSubscription_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscription_Call) RunAndReturn(run func(model.SubscriptionManagementDeleteCallType, api.DeviceRemoteInterface) error) *SubscriptionManagerInterface_RemoveSubscription_Call { + _c.Call.Return(run) + return _c +} + +// RemoveSubscriptionsForDevice provides a mock function with given fields: remoteDevice +func (_m *SubscriptionManagerInterface) RemoveSubscriptionsForDevice(remoteDevice api.DeviceRemoteInterface) { + _m.Called(remoteDevice) +} + +// SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveSubscriptionsForDevice' +type SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call struct { + *mock.Call +} + +// RemoveSubscriptionsForDevice is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +func (_e *SubscriptionManagerInterface_Expecter) RemoveSubscriptionsForDevice(remoteDevice interface{}) *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call { + return &SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call{Call: _e.mock.On("RemoveSubscriptionsForDevice", remoteDevice)} +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call) Run(run func(remoteDevice api.DeviceRemoteInterface)) *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call) Return() *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call { + _c.Call.Return() + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call) RunAndReturn(run func(api.DeviceRemoteInterface)) *SubscriptionManagerInterface_RemoveSubscriptionsForDevice_Call { + _c.Call.Return(run) + return _c +} + +// RemoveSubscriptionsForEntity provides a mock function with given fields: remoteEntity +func (_m *SubscriptionManagerInterface) RemoveSubscriptionsForEntity(remoteEntity api.EntityRemoteInterface) { + _m.Called(remoteEntity) +} + +// SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveSubscriptionsForEntity' +type SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call struct { + *mock.Call +} + +// RemoveSubscriptionsForEntity is a helper method to define mock.On call +// - remoteEntity api.EntityRemoteInterface +func (_e *SubscriptionManagerInterface_Expecter) RemoveSubscriptionsForEntity(remoteEntity interface{}) *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call { + return &SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call{Call: _e.mock.On("RemoveSubscriptionsForEntity", remoteEntity)} +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call) Run(run func(remoteEntity api.EntityRemoteInterface)) *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.EntityRemoteInterface)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call) Return() *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call { + _c.Call.Return() + return _c +} + +func (_c *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call) RunAndReturn(run func(api.EntityRemoteInterface)) *SubscriptionManagerInterface_RemoveSubscriptionsForEntity_Call { + _c.Call.Return(run) + return _c +} + +// Subscriptions provides a mock function with given fields: remoteDevice +func (_m *SubscriptionManagerInterface) Subscriptions(remoteDevice api.DeviceRemoteInterface) []*api.SubscriptionEntry { + ret := _m.Called(remoteDevice) + + if len(ret) == 0 { + panic("no return value specified for Subscriptions") + } + + var r0 []*api.SubscriptionEntry + if rf, ok := ret.Get(0).(func(api.DeviceRemoteInterface) []*api.SubscriptionEntry); ok { + r0 = rf(remoteDevice) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*api.SubscriptionEntry) + } + } + + return r0 +} + +// SubscriptionManagerInterface_Subscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscriptions' +type SubscriptionManagerInterface_Subscriptions_Call struct { + *mock.Call +} + +// Subscriptions is a helper method to define mock.On call +// - remoteDevice api.DeviceRemoteInterface +func (_e *SubscriptionManagerInterface_Expecter) Subscriptions(remoteDevice interface{}) *SubscriptionManagerInterface_Subscriptions_Call { + return &SubscriptionManagerInterface_Subscriptions_Call{Call: _e.mock.On("Subscriptions", remoteDevice)} +} + +func (_c *SubscriptionManagerInterface_Subscriptions_Call) Run(run func(remoteDevice api.DeviceRemoteInterface)) *SubscriptionManagerInterface_Subscriptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(api.DeviceRemoteInterface)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_Subscriptions_Call) Return(_a0 []*api.SubscriptionEntry) *SubscriptionManagerInterface_Subscriptions_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SubscriptionManagerInterface_Subscriptions_Call) RunAndReturn(run func(api.DeviceRemoteInterface) []*api.SubscriptionEntry) *SubscriptionManagerInterface_Subscriptions_Call { + _c.Call.Return(run) + return _c +} + +// SubscriptionsOnFeature provides a mock function with given fields: featureAddress +func (_m *SubscriptionManagerInterface) SubscriptionsOnFeature(featureAddress model.FeatureAddressType) []*api.SubscriptionEntry { + ret := _m.Called(featureAddress) + + if len(ret) == 0 { + panic("no return value specified for SubscriptionsOnFeature") + } + + var r0 []*api.SubscriptionEntry + if rf, ok := ret.Get(0).(func(model.FeatureAddressType) []*api.SubscriptionEntry); ok { + r0 = rf(featureAddress) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*api.SubscriptionEntry) + } + } + + return r0 +} + +// SubscriptionManagerInterface_SubscriptionsOnFeature_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscriptionsOnFeature' +type SubscriptionManagerInterface_SubscriptionsOnFeature_Call struct { + *mock.Call +} + +// SubscriptionsOnFeature is a helper method to define mock.On call +// - featureAddress model.FeatureAddressType +func (_e *SubscriptionManagerInterface_Expecter) SubscriptionsOnFeature(featureAddress interface{}) *SubscriptionManagerInterface_SubscriptionsOnFeature_Call { + return &SubscriptionManagerInterface_SubscriptionsOnFeature_Call{Call: _e.mock.On("SubscriptionsOnFeature", featureAddress)} +} + +func (_c *SubscriptionManagerInterface_SubscriptionsOnFeature_Call) Run(run func(featureAddress model.FeatureAddressType)) *SubscriptionManagerInterface_SubscriptionsOnFeature_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.FeatureAddressType)) + }) + return _c +} + +func (_c *SubscriptionManagerInterface_SubscriptionsOnFeature_Call) Return(_a0 []*api.SubscriptionEntry) *SubscriptionManagerInterface_SubscriptionsOnFeature_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SubscriptionManagerInterface_SubscriptionsOnFeature_Call) RunAndReturn(run func(model.FeatureAddressType) []*api.SubscriptionEntry) *SubscriptionManagerInterface_SubscriptionsOnFeature_Call { + _c.Call.Return(run) + return _c +} + +// NewSubscriptionManagerInterface creates a new instance of SubscriptionManagerInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewSubscriptionManagerInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *SubscriptionManagerInterface { + mock := &SubscriptionManagerInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/mocks/WriteApprovalCallbackFunc.go b/src/eebus-bridge/third_party/spine-go/mocks/WriteApprovalCallbackFunc.go new file mode 100644 index 0000000..67c4aba --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/mocks/WriteApprovalCallbackFunc.go @@ -0,0 +1,68 @@ +// Code generated by mockery v2.45.0. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/spine-go/api" + mock "github.com/stretchr/testify/mock" +) + +// WriteApprovalCallbackFunc is an autogenerated mock type for the WriteApprovalCallbackFunc type +type WriteApprovalCallbackFunc struct { + mock.Mock +} + +type WriteApprovalCallbackFunc_Expecter struct { + mock *mock.Mock +} + +func (_m *WriteApprovalCallbackFunc) EXPECT() *WriteApprovalCallbackFunc_Expecter { + return &WriteApprovalCallbackFunc_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: msg +func (_m *WriteApprovalCallbackFunc) Execute(msg *api.Message) { + _m.Called(msg) +} + +// WriteApprovalCallbackFunc_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type WriteApprovalCallbackFunc_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - msg *api.Message +func (_e *WriteApprovalCallbackFunc_Expecter) Execute(msg interface{}) *WriteApprovalCallbackFunc_Execute_Call { + return &WriteApprovalCallbackFunc_Execute_Call{Call: _e.mock.On("Execute", msg)} +} + +func (_c *WriteApprovalCallbackFunc_Execute_Call) Run(run func(msg *api.Message)) *WriteApprovalCallbackFunc_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*api.Message)) + }) + return _c +} + +func (_c *WriteApprovalCallbackFunc_Execute_Call) Return() *WriteApprovalCallbackFunc_Execute_Call { + _c.Call.Return() + return _c +} + +func (_c *WriteApprovalCallbackFunc_Execute_Call) RunAndReturn(run func(*api.Message)) *WriteApprovalCallbackFunc_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewWriteApprovalCallbackFunc creates a new instance of WriteApprovalCallbackFunc. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewWriteApprovalCallbackFunc(t interface { + mock.TestingT + Cleanup(func()) +}) *WriteApprovalCallbackFunc { + mock := &WriteApprovalCallbackFunc{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/eebus-bridge/third_party/spine-go/model/actuatorlevel.go b/src/eebus-bridge/third_party/spine-go/model/actuatorlevel.go new file mode 100644 index 0000000..64e4077 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/actuatorlevel.go @@ -0,0 +1,36 @@ +package model + +type ActuatorLevelFctType string + +const ( + ActuatorLevelFctTypeStart ActuatorLevelFctType = "start" + ActuatorLevelFctTypeUp ActuatorLevelFctType = "up" + ActuatorLevelFctTypeDown ActuatorLevelFctType = "down" + ActuatorLevelFctTypeStop ActuatorLevelFctType = "stop" + ActuatorLevelFctTypePercentageAbsolute ActuatorLevelFctType = "percentageAbsolute" + ActuatorLevelFctTypePercentageRelative ActuatorLevelFctType = "percentageRelative" + ActuatorLevelFctTypeAbsolut ActuatorLevelFctType = "absolut" + ActuatorLevelFctTypeRelative ActuatorLevelFctType = "relative" +) + +type ActuatorLevelDataType struct { + Function *ActuatorLevelFctType `json:"function,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` +} + +type ActuatorLevelDataElementsType struct { + Function *ElementTagType `json:"function,omitempty"` + Value *ElementTagType `json:"value,omitempty"` +} + +type ActuatorLevelDescriptionDataType struct { + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` + LevelDefaultUnit *UnitOfMeasurementType `json:"levelDefaultUnit,omitempty"` +} + +type ActuatorLevelDescriptionDataElementsType struct { + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + LevelDefaultUnit *ElementTagType `json:"levelDefaultUnit,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/actuatorswitch.go b/src/eebus-bridge/third_party/spine-go/model/actuatorswitch.go new file mode 100644 index 0000000..cd76d39 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/actuatorswitch.go @@ -0,0 +1,27 @@ +package model + +type ActuatorSwitchFctType string + +const ( + ActuatorSwitchFctTypeOn ActuatorSwitchFctType = "on" + ActuatorSwitchFctTypeOff ActuatorSwitchFctType = "off" + ActuatorSwitchFctTypeToggle ActuatorSwitchFctType = "toggle" +) + +type ActuatorSwitchDataType struct { + Function *ActuatorSwitchFctType `json:"function,omitempty"` +} + +type ActuatorSwitchDataElementsType struct { + Function *ElementTagType `json:"function,omitempty"` +} + +type ActuatorSwitchDescriptionDataType struct { + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type ActuatorSwitchDescriptionDataElementsType struct { + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/alarm.go b/src/eebus-bridge/third_party/spine-go/model/alarm.go new file mode 100644 index 0000000..7158fce --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/alarm.go @@ -0,0 +1,44 @@ +package model + +type AlarmIdType uint + +type AlarmTypeType string + +const ( + AlarmTypeTypeAlarmCancelled AlarmTypeType = "alarmCancelled" + AlarmTypeTypeUnderThreshold AlarmTypeType = "underThreshold" + AlarmTypeTypeOverThreshold AlarmTypeType = "overThreshold" +) + +type AlarmDataType struct { + AlarmId *AlarmIdType `json:"alarmId,omitempty" eebus:"key"` + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + AlarmType *AlarmTypeType `json:"alarmType,omitempty"` + MeasuredValue *ScaledNumberType `json:"measuredValue,omitempty"` + EvaluationPeriod *TimePeriodType `json:"evaluationPeriod,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type AlarmDataElementsType struct { + AlarmId *ElementTagType `json:"alarmId,omitempty"` + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + AlarmType *ElementTagType `json:"alarmType,omitempty"` + MeasuredValue *ScaledNumberElementsType `json:"measuredValue,omitempty"` + EvaluationPeriod *TimePeriodElementsType `json:"evaluationPeriod,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type AlarmListDataType struct { + AlarmListData []AlarmDataType `json:"alarmListData,omitempty"` +} + +type AlarmListDataSelectorsType struct { + AlarmId *AlarmIdType `json:"alarmId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/alarm_additions.go b/src/eebus-bridge/third_party/spine-go/model/alarm_additions.go new file mode 100644 index 0000000..5a7ba27 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/alarm_additions.go @@ -0,0 +1,20 @@ +package model + +// AlarmListDataType + +var _ Updater = (*AlarmListDataType)(nil) + +func (r *AlarmListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []AlarmDataType + if newList != nil { + newData = newList.(*AlarmListDataType).AlarmListData + } + + data, success := UpdateList(remoteWrite, r.AlarmListData, newData, filterPartial, filterDelete) + + if success && persist { + r.AlarmListData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/bill.go b/src/eebus-bridge/third_party/spine-go/model/bill.go new file mode 100644 index 0000000..1d876d4 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/bill.go @@ -0,0 +1,157 @@ +package model + +type BillIdType uint + +type BillTypeType string + +const ( + BillTypeTypeChargingSummary BillTypeType = "chargingSummary" +) + +type BillPositionIdType uint + +type BillPositionCountType BillPositionIdType + +type BillPositionTypeType string + +const ( + BillPositionTypeTypeGridElectricEnergy BillPositionTypeType = "gridElectricEnergy" + BillPositionTypeTypeSelfProducedElectricEnergy BillPositionTypeType = "selfProducedElectricEnergy" +) + +type BillValueIdType uint + +type BillCostIdType uint + +type BillCostTypeType string + +const ( + BillCostTypeTypeAbsolutePrice BillCostTypeType = "absolutePrice" + BillCostTypeTypeRelativePrice BillCostTypeType = "relativePrice" + BillCostTypeTypeCo2Emission BillCostTypeType = "co2Emission" + BillCostTypeTypeRenewableEnergy BillCostTypeType = "renewableEnergy" + BillCostTypeTypeRadioactiveWaste BillCostTypeType = "radioactiveWaste" +) + +type BillValueType struct { + ValueId *BillValueIdType `json:"valueId,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` + ValuePercentage *ScaledNumberType `json:"valuePercentage,omitempty"` +} + +type BillValueElementsType struct { + ValueId *ElementTagType `json:"valueId,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + Value *ElementTagType `json:"value,omitempty"` + ValuePercentage *ElementTagType `json:"valuePercentage,omitempty"` +} + +type BillCostType struct { + CostId *BillCostIdType `json:"costId,omitempty"` + CostType *BillCostTypeType `json:"costType,omitempty"` + ValueId *BillValueIdType `json:"valueId,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + Currency *CurrencyType `json:"currency,omitempty"` + Cost *ScaledNumberType `json:"cost,omitempty"` + CostPercentage *ScaledNumberType `json:"costPercentage,omitempty"` +} + +type BillCostElementsType struct { + CostId *ElementTagType `json:"costId,omitempty"` + CostType *ElementTagType `json:"costType,omitempty"` + ValueId *ElementTagType `json:"valueId,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + Currency *ElementTagType `json:"currency,omitempty"` + Cost *ScaledNumberElementsType `json:"cost,omitempty"` + CostPercentage *ScaledNumberElementsType `json:"costPercentage,omitempty"` +} + +type BillPositionType struct { + PositionId *BillPositionIdType `json:"positionId,omitempty"` + PositionType *BillPositionTypeType `json:"positionType,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + Value *BillValueType `json:"value,omitempty"` + Cost *BillCostType `json:"cost,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type BillPositionElementsType struct { + PositionId *ElementTagType `json:"positionId,omitempty"` + PositionType *ElementTagType `json:"positionType,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` + Value *BillValueElementsType `json:"value,omitempty"` + Cost *BillCostElementsType `json:"cost,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type BillDataType struct { + BillId *BillIdType `json:"billId,omitempty" eebus:"key"` + BillType *BillTypeType `json:"billType,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Total *BillPositionType `json:"total,omitempty"` + Position []BillPositionType `json:"position,omitempty"` +} + +type BillDataElementsType struct { + BillId *ElementTagType `json:"billId,omitempty"` + BillType *ElementTagType `json:"billType,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Total *BillPositionElementsType `json:"total,omitempty"` + Position *BillPositionElementsType `json:"position,omitempty"` +} + +type BillListDataType struct { + BillData []BillDataType `json:"billData,omitempty"` +} + +type BillListDataSelectorsType struct { + BillId *BillIdType `json:"billId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type BillConstraintsDataType struct { + BillId *BillIdType `json:"billId,omitempty" eebus:"key"` + PositionCountMin *BillPositionCountType `json:"positionCountMin,omitempty"` + PositionCountMax *BillPositionCountType `json:"positionCountMax,omitempty"` +} + +type BillConstraintsDataElementsType struct { + BillId *ElementTagType `json:"billId,omitempty"` + PositionCountMin *ElementTagType `json:"positionCountMin,omitempty"` + PositionCountMax *ElementTagType `json:"positionCountMax,omitempty"` +} + +type BillConstraintsListDataType struct { + BillConstraintsData []BillConstraintsDataType `json:"billConstraintsData,omitempty"` +} + +type BillConstraintsListDataSelectorsType struct { + BillId *BillIdType `json:"billId,omitempty"` +} + +type BillDescriptionDataType struct { + BillId *BillIdType `json:"billId,omitempty" eebus:"key"` + BillWriteable *bool `json:"billWriteable,omitempty"` + UpdateRequired *bool `json:"updateRequired,omitempty"` + SupportedBillType []BillTypeType `json:"supportedBillType,omitempty"` + SessionId *SessionIdType `json:"sessionId,omitempty"` +} + +type BillDescriptionDataElementsType struct { + BillId *ElementTagType `json:"billId,omitempty"` + BillWriteable *ElementTagType `json:"billWriteable,omitempty"` + UpdateRequired *ElementTagType `json:"updateRequired,omitempty"` + SupportedBillType *ElementTagType `json:"supportedBillType,omitempty"` + SessionId *ElementTagType `json:"sessionId,omitempty"` +} + +type BillDescriptionListDataType struct { + BillDescriptionData []BillDescriptionDataType `json:"billDescriptionData,omitempty"` +} + +type BillDescriptionListDataSelectorsType struct { + BillId *BillIdType `json:"billId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/bill_additions.go b/src/eebus-bridge/third_party/spine-go/model/bill_additions.go new file mode 100644 index 0000000..b5bca22 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/bill_additions.go @@ -0,0 +1,58 @@ +package model + +// BillListDataType + +var _ Updater = (*BillListDataType)(nil) + +func (r *BillListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []BillDataType + if newList != nil { + newData = newList.(*BillListDataType).BillData + } + + data, success := UpdateList(remoteWrite, r.BillData, newData, filterPartial, filterDelete) + + if success && persist { + r.BillData = data + } + + return data, success +} + +// BillConstraintsListDataType + +var _ Updater = (*BillConstraintsListDataType)(nil) + +func (r *BillConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []BillConstraintsDataType + if newList != nil { + newData = newList.(*BillConstraintsListDataType).BillConstraintsData + } + + data, success := UpdateList(remoteWrite, r.BillConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.BillConstraintsData = data + } + + return data, success +} + +// BillDescriptionListDataType + +var _ Updater = (*BillDescriptionListDataType)(nil) + +func (r *BillDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []BillDescriptionDataType + if newList != nil { + newData = newList.(*BillDescriptionListDataType).BillDescriptionData + } + + data, success := UpdateList(remoteWrite, r.BillDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.BillDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/bindingmanagement.go b/src/eebus-bridge/third_party/spine-go/model/bindingmanagement.go new file mode 100644 index 0000000..719d671 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/bindingmanagement.go @@ -0,0 +1,53 @@ +package model + +type BindingIdType uint + +type BindingManagementEntryDataType struct { + BindingId *BindingIdType `json:"bindingId,omitempty" eebus:"key"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type BindingManagementEntryDataElementsType struct { + BindingId *ElementTagType `json:"bindingId,omitempty"` + ClientAddress *ElementTagType `json:"clientAddress,omitempty"` + ServerAddress *ElementTagType `json:"serverAddress,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type BindingManagementEntryListDataType struct { + BindingManagementEntryData []BindingManagementEntryDataType `json:"bindingManagementEntryData,omitempty"` +} + +type BindingManagementEntryListDataSelectorsType struct { + BindingId *BindingIdType `json:"bindingId,omitempty"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` +} + +type BindingManagementRequestCallType struct { + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` + ServerFeatureType *FeatureTypeType `json:"serverFeatureType,omitempty"` +} + +type BindingManagementRequestCallElementsType struct { + ClientAddress *ElementTagType `json:"clientAddress,omitempty"` + ServerAddress *ElementTagType `json:"serverAddress,omitempty"` + ServerFeatureType *ElementTagType `json:"serverFeatureType,omitempty"` +} + +type BindingManagementDeleteCallType struct { + BindingId *BindingIdType `json:"bindingId,omitempty"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` +} + +type BindingManagementDeleteCallElementsType struct { + BindingId *ElementTagType `json:"bindingId,omitempty"` + ClientAddress *ElementTagType `json:"clientAddress,omitempty"` + ServerAddress *ElementTagType `json:"serverAddress,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/bindingmanagement_additions.go b/src/eebus-bridge/third_party/spine-go/model/bindingmanagement_additions.go new file mode 100644 index 0000000..b2fad45 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/bindingmanagement_additions.go @@ -0,0 +1,20 @@ +package model + +// BindingManagementEntryListDataType + +var _ Updater = (*BindingManagementEntryListDataType)(nil) + +func (r *BindingManagementEntryListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []BindingManagementEntryDataType + if newList != nil { + newData = newList.(*BindingManagementEntryListDataType).BindingManagementEntryData + } + + data, success := UpdateList(remoteWrite, r.BindingManagementEntryData, newData, filterPartial, filterDelete) + + if success && persist { + r.BindingManagementEntryData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/collection_operations.go b/src/eebus-bridge/third_party/spine-go/model/collection_operations.go new file mode 100644 index 0000000..5c03f1e --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/collection_operations.go @@ -0,0 +1,194 @@ +package model + +import ( + "fmt" + "reflect" + "slices" +) + +// creates an hash key by using fields that have eebus tag "key" +func hashKey(data any) string { + result := "" + + keys := fieldNamesWithEEBusTag(EEBusTagKey, data) + + if len(keys) == 0 { + return result + } + + v := reflect.ValueOf(data) + + for _, fieldName := range keys { + f := v.FieldByName(fieldName) + + if f.IsNil() || !f.IsValid() { + return result + } + + switch f.Elem().Kind() { + case reflect.String: + value := f.Elem().String() + + if len(result) > 0 { + result = fmt.Sprintf("%s|", result) + } + result = fmt.Sprintf("%s%s", result, value) + + case reflect.Uint: + value := f.Elem().Uint() + + if len(result) > 0 { + result = fmt.Sprintf("%s|", result) + } + result = fmt.Sprintf("%s%d", result, value) + + case reflect.Struct: + value := f.Type() + fmt.Println(value) + + if !f.CanInterface() { + return result + } + + c, ok := f.Interface().(UpdateHelper) + if !ok { + return result + } + + if len(result) > 0 { + result = fmt.Sprintf("%s|", result) + } + result = fmt.Sprintf("%s%s", result, c.String()) + + return result + default: + return result + } + } + + return result +} + +// check the eebus tag if is has a "writecheck" item +// and if so, if the value of that field is true +func writeAllowed(data any) bool { + fields := fieldNamesWithEEBusTag(EEBusTagWriteCheck, data) + // only one field in a struct may have this tag + if len(fields) != 1 { + return true + } + + fieldName := fields[0] + v := reflect.ValueOf(data) + f := v.FieldByName(fieldName) + + if f.IsNil() || !f.IsValid() { + return false + } + + // if this is not a boolean, the tag is wrong which shouldn't happen + // and we allow overwriting + if f.Elem().Kind() != reflect.Bool { + return true + } + + value := f.Elem().Bool() + return value +} + +// update missing fields in destination with values from source +func updateFields[T any](remoteWrite bool, source T, destination *T) { + if destination == nil { + return + } + + writeCheckFields := fieldNamesWithEEBusTag(EEBusTagWriteCheck, source) + + sV := reflect.ValueOf(source) + sT := reflect.TypeOf(source) + dV := reflect.ValueOf(destination).Elem() + + // if the fields don't match, don't do anything + if sV.Kind() != reflect.Struct || sV.NumField() != dV.NumField() { + return + } + + for i := 0; i < sV.NumField(); i++ { + value := sV.Field(i) + fieldName := sT.Field(i).Name + f := dV.FieldByName(fieldName) + + if !f.IsValid() || + !f.CanSet() { + continue + } + + // on local merge set all nil values + // on remote writes only set nil values if it is not a "writecheck" tagged field + if f.IsNil() || + (remoteWrite && len(writeCheckFields) > 0 && slices.Contains(writeCheckFields, fieldName)) { + f.Set(value) + } + } +} + +// Merges two slices into one. The item in the first slice will be replaced by the one in the second slice +// if the hash key is the same. Items in the second slice which are not in the first will be added. +// +// Parameter remoteWrite defines if this data came on from a remote service, as that is then to +// ignore the "writecheck" tagges fields and should only be allowed to write if the "writecheck" tagged field +// boolean is set to true +// +// returns: +// - the new data set +// - true if everything was successful, false if not +func Merge[T any](remoteWrite bool, s1 []T, s2 []T) ([]T, bool) { + var result []T + success := true + + m2 := ToMap(s2) + + // go through the first slice + m1 := make(map[string]T, len(s1)) + for _, s1Item := range s1 { + s1ItemHash := hashKey(s1Item) + s2Item, exist := m2[s1ItemHash] + writeAllowed := writeAllowed(s1Item) + if !writeAllowed && remoteWrite { + success = false + } + // if exists and overwriting is allowed + if exist && (!remoteWrite || writeAllowed) { + // add values from s1Item that don't exist in s2Item or shouldn't be + // set in s2Item + updateFields(remoteWrite, s1Item, &s2Item) + + // the item in the first slice will be replaced by the one of the second slice + result = append(result, s2Item) + } else { + result = append(result, s1Item) + } + + m1[s1ItemHash] = s1Item + } + + // append items which were not in the first slice + for _, s2Item := range s2 { + s2ItemHash := hashKey(s2Item) + _, exist := m1[s2ItemHash] + if !exist && !remoteWrite { + // only local updates can append data + result = append(result, s2Item) + } + } + + return result, success +} + +func ToMap[T any](s []T) map[string]T { + result := make(map[string]T, len(s)) + for _, item := range s { + result[hashKey(item)] = item + } + return result +} diff --git a/src/eebus-bridge/third_party/spine-go/model/commandframe.go b/src/eebus-bridge/third_party/spine-go/model/commandframe.go new file mode 100644 index 0000000..537e207 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/commandframe.go @@ -0,0 +1,426 @@ +package model + +type MsgCounterType uint64 + +type CmdClassifierType string + +const ( + CmdClassifierTypeRead CmdClassifierType = "read" + CmdClassifierTypeReply CmdClassifierType = "reply" + CmdClassifierTypeNotify CmdClassifierType = "notify" + CmdClassifierTypeWrite CmdClassifierType = "write" + CmdClassifierTypeCall CmdClassifierType = "call" + CmdClassifierTypeResult CmdClassifierType = "result" +) + +type FilterIdType uint + +type FilterType struct { + FilterId *FilterIdType `json:"filterId,omitempty"` + CmdControl *CmdControlType `json:"cmdControl,omitempty"` + + // DataSelectorsChoiceGroup + AlarmListDataSelectors *AlarmListDataSelectorsType `json:"alarmListDataSelectors,omitempty" eebus:"typ:selector,fct:alarmListData"` + BillConstraintsListDataSelectors *BillConstraintsListDataSelectorsType `json:"billConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:billConstraintsListData"` + BillDescriptionListDataSelectors *BillDescriptionListDataSelectorsType `json:"billDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:billDescriptionListData"` + BillListDataSelectors *BillListDataSelectorsType `json:"billListDataSelectors,omitempty" eebus:"typ:selector,fct:billListData"` + BindingManagementEntryListDataSelectors *BindingManagementEntryListDataSelectorsType `json:"bindingManagementEntryListDataSelectors,omitempty" eebus:"typ:selector,fct:bindingManagementEntryListData"` + CommodityListDataSelectors *CommodityListDataSelectorsType `json:"commodityListDataSelectors,omitempty" eebus:"typ:selector,fct:commodityListData"` + DeviceConfigurationKeyValueConstraintsListDataSelectors *DeviceConfigurationKeyValueConstraintsListDataSelectorsType `json:"deviceConfigurationKeyValueConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:deviceConfigurationKeyValueConstraintsListData"` + DeviceConfigurationKeyValueDescriptionListDataSelectors *DeviceConfigurationKeyValueDescriptionListDataSelectorsType `json:"deviceConfigurationKeyValueDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:deviceConfigurationKeyValueDescriptionListData"` + DeviceConfigurationKeyValueListDataSelectors *DeviceConfigurationKeyValueListDataSelectorsType `json:"deviceConfigurationKeyValueListDataSelectors,omitempty" eebus:"typ:selector,fct:deviceConfigurationKeyValueListData"` + DirectControlActivityListDataSelectors *DirectControlActivityListDataSelectorsType `json:"directControlActivityListDataSelectors,omitempty" eebus:"typ:selector,fct:directControlActivityListData"` + ElectricalConnectionDescriptionListDataSelectors *ElectricalConnectionDescriptionListDataSelectorsType `json:"electricalConnectionDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:electricalConnectionDescriptionListData"` + ElectricalConnectionParameterDescriptionListDataSelectors *ElectricalConnectionParameterDescriptionListDataSelectorsType `json:"electricalConnectionParameterDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:electricalConnectionParameterDescriptionListData"` + ElectricalConnectionPermittedValueSetListDataSelectors *ElectricalConnectionPermittedValueSetListDataSelectorsType `json:"electricalConnectionPermittedValueSetListDataSelectors,omitempty" eebus:"typ:selector,fct:electricalConnectionPermittedValueSetListData"` + ElectricalConnectionStateListDataSelectors *ElectricalConnectionStateListDataSelectorsType `json:"electricalConnectionStateListDataSelectors,omitempty" eebus:"typ:selector,fct:electricalConnectionStateListData"` + ElectricalConnectionCharacteristicListDataSelectors *ElectricalConnectionCharacteristicListDataSelectorsType `json:"electricalConnectionCharacteristicListDataSelectors,omitempty" eebus:"typ:selector,fct:electricalConnectionCharacteristicListData"` + HvacOperationModeDescriptionListDataSelectors *HvacOperationModeDescriptionListDataSelectorsType `json:"hvacOperationModeDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacOperationModeDescriptionListData"` + HvacOverrunDescriptionListDataSelectors *HvacOverrunDescriptionListDataSelectorsType `json:"hvacOverrunDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacOverrunDescriptionListData"` + HvacOverrunListDataSelectors *HvacOverrunListDataSelectorsType `json:"hvacOverrunListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacOverrunListData"` + HvacSystemFunctionDescriptionListDataSelectors *HvacSystemFunctionDescriptionListDataSelectorsType `json:"hvacSystemFunctionDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacSystemFunctionDescriptionListData"` + HvacSystemFunctionListDataSelectors *HvacSystemFunctionListDataSelectorsType `json:"hvacSystemFunctionListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacSystemFunctionListData"` + HvacSystemFunctionOperationModeRelationListDataSelectors *HvacSystemFunctionOperationModeRelationListDataSelectorsType `json:"hvacSystemFunctionOperationModeRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacSystemFunctionOperationModeRelationListData"` + HvacSystemFunctionPowerSequenceRelationListDataSelectors *HvacSystemFunctionPowerSequenceRelationListDataSelectorsType `json:"hvacSystemFunctionPowerSequenceRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacSystemFunctionPowerSequenceRelationListData"` + HvacSystemFunctionSetpointRelationListDataSelectors *HvacSystemFunctionSetpointRelationListDataSelectorsType `json:"hvacSystemFunctionSetpointRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:hvacSystemFunctionSetpointRelationListData"` + IdentificationListDataSelectors *IdentificationListDataSelectorsType `json:"identificationListDataSelectors,omitempty" eebus:"typ:selector,fct:identificationListData"` + IncentiveDescriptionListDataSelectors *IncentiveDescriptionListDataSelectorsType `json:"incentiveDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:incentiveDescriptionListData"` + IncentiveListDataSelectors *IncentiveListDataSelectorsType `json:"incentiveListDataSelectors,omitempty" eebus:"typ:selector,fct:incentiveListData"` + IncentiveTableConstraintsDataSelectors *IncentiveTableConstraintsDataSelectorsType `json:"incentiveTableConstraintsDataSelectors,omitempty" eebus:"typ:selector,fct:incentiveTableConstraintsData"` + IncentiveTableDataSelectors *IncentiveTableDataSelectorsType `json:"incentiveTableDataSelectors,omitempty" eebus:"typ:selector,fct:incentiveTableData"` + IncentiveTableDescriptionDataSelectors *IncentiveTableDescriptionDataSelectorsType `json:"incentiveTableDescriptionDataSelectors,omitempty" eebus:"typ:selector,fct:incentiveTableDescriptionData"` + LoadControlEventListDataSelectors *LoadControlEventListDataSelectorsType `json:"loadControlEventListDataSelectors,omitempty" eebus:"typ:selector,fct:loadControlEventListData"` + LoadControlLimitConstraintsListDataSelectors *LoadControlLimitConstraintsListDataSelectorsType `json:"loadControlLimitConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:loadControlLimitConstraintsListData"` + LoadControlLimitDescriptionListDataSelectors *LoadControlLimitDescriptionListDataSelectorsType `json:"loadControlLimitDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:loadControlLimitDescriptionListData"` + LoadControlLimitListDataSelectors *LoadControlLimitListDataSelectorsType `json:"loadControlLimitListDataSelectors,omitempty" eebus:"typ:selector,fct:loadControlLimitListData"` + LoadControlStateListDataSelectors *LoadControlStateListDataSelectorsType `json:"loadControlStateListDataSelectors,omitempty" eebus:"typ:selector,fct:loadControlStateListData"` + MeasurementConstraintsListDataSelectors *MeasurementConstraintsListDataSelectorsType `json:"measurementConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:measurementConstraintsListData"` + MeasurementDescriptionListDataSelectors *MeasurementDescriptionListDataSelectorsType `json:"measurementDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:measurementDescriptionListData"` + MeasurementListDataSelectors *MeasurementListDataSelectorsType `json:"measurementListDataSelectors,omitempty" eebus:"typ:selector,fct:measurementListData"` + MeasurementSeriesListDataSelectors *MeasurementSeriesListDataSelectorsType `json:"measurementSeriesListDataSelectors,omitempty" eebus:"measurementSeriesListData"` + MeasurementThresholdRelationListDataSelectors *MeasurementThresholdRelationListDataSelectorsType `json:"measurementThresholdRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:measurementThresholdRelationListData"` + MessagingListDataSelectors *MessagingListDataSelectorsType `json:"messagingListDataSelectors,omitempty" eebus:"typ:selector,fct:messagingListData"` + NetworkManagementDeviceDescriptionListDataSelectors *NetworkManagementDeviceDescriptionListDataSelectorsType `json:"networkManagementDeviceDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:networkManagementDeviceDescriptionListData"` + NetworkManagementEntityDescriptionListDataSelectors *NetworkManagementEntityDescriptionListDataSelectorsType `json:"networkManagementEntityDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:networkManagementEntityDescriptionListData"` + NetworkManagementFeatureDescriptionListDataSelectors *NetworkManagementFeatureDescriptionListDataSelectorsType `json:"networkManagementFeatureDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:networkManagementFeatureDescriptionList"` + NodeManagementBindingDataSelectors *NodeManagementBindingDataSelectorsType `json:"nodeManagementBindingDataSelectors,omitempty" eebus:"typ:selector,fct:nodeManagementBindingData"` + NodeManagementDestinationListDataSelectors *NodeManagementDestinationListDataSelectorsType `json:"nodeManagementDestinationListDataSelectors,omitempty" eebus:"typ:selector,fct:nodeManagementDestinationListData"` + NodeManagementDetailedDiscoveryDataSelectors *NodeManagementDetailedDiscoveryDataSelectorsType `json:"nodeManagementDetailedDiscoveryDataSelectors,omitempty" eebus:"typ:selector,fct:nodeManagementDetailedDiscoveryData"` + NodeManagementSubscriptionDataSelectors *NodeManagementSubscriptionDataSelectorsType `json:"nodeManagementSubscriptionDataSelectors,omitempty" eebus:"typ:selector,fct:nodeManagementSubscriptionData"` + NodeManagementUseCaseDataSelectors *NodeManagementUseCaseDataSelectorsType `json:"nodeManagementUseCaseDataSelectors,omitempty" eebus:"typ:selector,fct:nodeManagementUseCaseData"` + OperatingConstraintsDurationListDataSelectors *OperatingConstraintsDurationListDataSelectorsType `json:"operatingConstraintsDurationListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsDurationListData"` + OperatingConstraintsInterruptListDataSelectors *OperatingConstraintsInterruptListDataSelectorsType `json:"operatingConstraintsInterruptListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsInterruptListData"` + OperatingConstraintsPowerDescriptionListDataSelectors *OperatingConstraintsPowerDescriptionListDataSelectorsType `json:"operatingConstraintsPowerDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsPowerDescriptionListData"` + OperatingConstraintsPowerLevelListDataSelectors *OperatingConstraintsPowerLevelListDataSelectorsType `json:"operatingConstraintsPowerLevelListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsPowerLevelListData"` + OperatingConstraintsPowerRangeListDataSelectors *OperatingConstraintsPowerRangeListDataSelectorsType `json:"operatingConstraintsPowerRangeListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsPowerRangeListData"` + OperatingConstraintsResumeImplicationListDataSelectors *OperatingConstraintsResumeImplicationListDataSelectorsType `json:"operatingConstraintsResumeImplicationListDataSelectors,omitempty" eebus:"typ:selector,fct:operatingConstraintsResumeImplicationListData"` + PowerSequenceAlternativesRelationListDataSelectors *PowerSequenceAlternativesRelationListDataSelectorsType `json:"powerSequenceAlternativesRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceAlternativesRelationListData"` + PowerSequenceDescriptionListDataSelectors *PowerSequenceDescriptionListDataSelectorsType `json:"powerSequenceDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceDescriptionListData"` + PowerSequencePriceListDataSelectors *PowerSequencePriceListDataSelectorsType `json:"powerSequencePriceListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequencePriceListData"` + PowerSequenceScheduleConstraintsListDataSelectors *PowerSequenceScheduleConstraintsListDataSelectorsType `json:"powerSequenceScheduleConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceScheduleConstraintsListData"` + PowerSequenceScheduleListDataSelectors *PowerSequenceScheduleListDataSelectorsType `json:"powerSequenceScheduleListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceScheduleListData"` + PowerSequenceSchedulePreferenceListDataSelectors *PowerSequenceSchedulePreferenceListDataSelectorsType `json:"powerSequenceSchedulePreferenceListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceSchedulePreferenceListData"` + PowerSequenceStateListDataSelectors *PowerSequenceStateListDataSelectorsType `json:"powerSequenceStateListDataSelectors,omitempty" eebus:"typ:selector,fct:powerSequenceStateListData"` + PowerTimeSlotScheduleConstraintsListDataSelectors *PowerTimeSlotScheduleConstraintsListDataSelectorsType `json:"powerTimeSlotScheduleConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:powerTimeSlotScheduleConstraintsListData"` + PowerTimeSlotScheduleListDataSelectors *PowerTimeSlotScheduleListDataSelectorsType `json:"powerTimeSlotScheduleListDataSelectors,omitempty" eebus:"typ:selector,fct:powerTimeSlotScheduleListData"` + PowerTimeSlotValueListDataSelectors *PowerTimeSlotValueListDataSelectorsType `json:"powerTimeSlotValueListDataSelectors,omitempty" eebus:"typ:selector,fct:powerTimeSlotValueListData"` + SensingListDataSelectors *SensingListDataSelectorsType `json:"sensingListDataSelectors,omitempty" eebus:"typ:selector,fct:sensingListData"` + SessionIdentificationListDataSelectors *SessionIdentificationListDataSelectorsType `json:"sessionIdentificationListDataSelectors,omitempty" eebus:"typ:selector,fct:sessionIdentificationListData"` + SessionMeasurementRelationListDataSelectors *SessionMeasurementRelationListDataSelectorsType `json:"sessionMeasurementRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:sessionMeasurementRelationListData"` + SetpointConstraintsListDataSelectors *SetpointConstraintsListDataSelectorsType `json:"setpointConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:setpointConstraintsListData"` + SetpointDescriptionListDataSelectors *SetpointDescriptionListDataSelectorsType `json:"setpointDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:setpointDescriptionListData"` + SetpointListDataSelectors *SetpointListDataSelectorsType `json:"setpointListDataSelectors,omitempty" eebus:"typ:selector,fct:setpointListData"` + SmartEnergyManagementPsDataSelectors *SmartEnergyManagementPsDataSelectorsType `json:"smartEnergyManagementPsDataSelectors,omitempty" eebus:"typ:selector,fct:smartEnergyManagementPsData"` + SmartEnergyManagementPsPriceDataSelectors *SmartEnergyManagementPsPriceDataSelectorsType `json:"smartEnergyManagementPsPriceDataSelectors,omitempty" eebus:"typ:selector,fct:smartEnergyManagementPsPriceData"` + SpecificationVersionListDataSelectors *SpecificationVersionListDataSelectorsType `json:"specificationVersionListDataSelectors,omitempty" eebus:"typ:selector,fct:specificationVersionListData"` + StateInformationListDataSelectors *StateInformationListDataSelectorsType `json:"stateInformationListDataSelectors,omitempty" eebus:"typ:selector,fct:stateInformationListData"` + SubscriptionManagementEntryListDataSelectors *SubscriptionManagementEntryListDataSelectorsType `json:"subscriptionManagementEntryListDataSelectors,omitempty" eebus:"typ:selector,fct:subscriptionManagementEntryListData"` + SupplyConditionDescriptionListDataSelectors *SupplyConditionDescriptionListDataSelectorsType `json:"supplyConditionDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:supplyConditionDescriptionListData"` + SupplyConditionListDataSelectors *SupplyConditionListDataSelectorsType `json:"supplyConditionListDataSelectors,omitempty" eebus:"typ:selector,fct:supplyConditionListData"` + SupplyConditionThresholdRelationListDataSelectors *SupplyConditionThresholdRelationListDataSelectorsType `json:"supplyConditionThresholdRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:supplyConditionThresholdRelationListData"` + TariffBoundaryRelationListDataSelectors *TariffBoundaryRelationListDataSelectorsType `json:"tariffBoundaryRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:tariffBoundaryRelationListData"` + TariffDescriptionListDataSelectors *TariffDescriptionListDataSelectorsType `json:"tariffDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:tariffDescriptionListData"` + TariffListDataSelectors *TariffListDataSelectorsType `json:"tariffListDataSelectors,omitempty" eebus:"typ:selector,fct:tariffListData"` + TariffTierRelationListDataSelectors *TariffTierRelationListDataSelectorsType `json:"tariffTierRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:tariffTierRelationListData"` + TaskManagementJobDescriptionListDataSelectors *TaskManagementJobDescriptionListDataSelectorsType `json:"taskManagementJobDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:taskManagementJobDescriptionListData"` + TaskManagementJobListDataSelectors *TaskManagementJobListDataSelectorsType `json:"taskManagementJobListDataSelectors,omitempty" eebus:"typ:selector,fct:taskManagementJobListData"` + TaskManagementJobRelationListDataSelectors *TaskManagementJobRelationListDataSelectorsType `json:"taskManagementJobRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:taskManagementJobRelationListData"` + ThresholdConstraintsListDataSelectors *ThresholdConstraintsListDataSelectorsType `json:"thresholdConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:thresholdConstraintsListData"` + ThresholdDescriptionListDataSelectors *ThresholdDescriptionListDataSelectorsType `json:"thresholdDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:thresholdDescriptionListData"` + ThresholdListDataSelectors *ThresholdListDataSelectorsType `json:"thresholdListDataSelectors,omitempty" eebus:"typ:selector,fct:thresholdListData"` + TierBoundaryDescriptionListDataSelectors *TierBoundaryDescriptionListDataSelectorsType `json:"tierBoundaryDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:tierBoundaryDescriptionListData"` + TierBoundaryListDataSelectors *TierBoundaryListDataSelectorsType `json:"tierBoundaryListDataSelectors,omitempty" eebus:"typ:selector,fct:tierBoundaryListData"` + TierDescriptionListDataSelectors *TierDescriptionListDataSelectorsType `json:"tierDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:tierDescriptionListData"` + TierIncentiveRelationListDataSelectors *TierIncentiveRelationListDataSelectorsType `json:"tierIncentiveRelationListDataSelectors,omitempty" eebus:"typ:selector,fct:tierIncentiveRelationListData"` + TierListDataSelectors *TierListDataSelectorsType `json:"tierListDataSelectors,omitempty" eebus:"typ:selector,fct:tierListData"` + TimeSeriesConstraintsListDataSelectors *TimeSeriesConstraintsListDataSelectorsType `json:"timeSeriesConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:timeSeriesConstraintsListData"` + TimeSeriesDescriptionListDataSelectors *TimeSeriesDescriptionListDataSelectorsType `json:"timeSeriesDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:timeSeriesDescriptionListData"` + TimeSeriesListDataSelectors *TimeSeriesListDataSelectorsType `json:"timeSeriesListDataSelectors,omitempty" eebus:"typ:selector,fct:timeSeriesListData"` + TimeTableConstraintsListDataSelectors *TimeTableConstraintsListDataSelectorsType `json:"timeTableConstraintsListDataSelectors,omitempty" eebus:"typ:selector,fct:timeTableConstraintsListData"` + TimeTableDescriptionListDataSelectors *TimeTableDescriptionListDataSelectorsType `json:"timeTableDescriptionListDataSelectors,omitempty" eebus:"typ:selector,fct:timeTableDescriptionListData"` + TimeTableListDataSelectors *TimeTableListDataSelectorsType `json:"timeTableListDataSelectors,omitempty" eebus:"typ:selector,fct:timeTableListData"` + UseCaseInformationListDataSelectors *UseCaseInformationListDataSelectorsType `json:"useCaseInformationListDataSelectors,omitempty" eebus:"typ:selector,fct:useCaseInformationListData"` + + // DataElementsChoiceGroup + ActuatorLevelDataElements *ActuatorLevelDataElementsType `json:"actuatorLevelDataElements,omitempty" eebus:"typ:elements,fct:actuatorLevelData"` + ActuatorLevelDescriptionDataElements *ActuatorLevelDescriptionDataElementsType `json:"actuatorLevelDescriptionDataElements,omitempty" eebus:"typ:elements,fct:actuatorLevelDescriptionData"` + ActuatorSwitchDataElements *ActuatorSwitchDataElementsType `json:"actuatorSwitchDataElements,omitempty" eebus:"typ:elements,fct:actuatorSwitchData"` + ActuatorSwitchDescriptionDataElements *ActuatorSwitchDescriptionDataElementsType `json:"actuatorSwitchDescriptionDataElements,omitempty" eebus:"typ:elements,fct:actuatorSwitchDescriptionData"` + AlarmDataElements *AlarmDataElementsType `json:"alarmDataElements,omitempty" eebus:"typ:elements,fct:alarmListData"` + BillConstraintsDataElements *BillConstraintsDataElementsType `json:"billConstraintsDataElements,omitempty" eebus:"typ:elements,fct:billConstraintsListData"` + BillDataElements *BillDataElementsType `json:"billDataElements,omitempty" eebus:"typ:elements,fct:billListData"` + BillDescriptionDataElements *BillDescriptionDataElementsType `json:"billDescriptionDataElements,omitempty" eebus:"typ:elements,fct:billDescriptionListData"` + BindingManagementDeleteCallElements *BindingManagementDeleteCallElementsType `json:"bindingManagementDeleteCallElements,omitempty" eebus:"typ:elements,fct:bindingManagementDeleteCall"` + BindingManagementEntryDataElements *BindingManagementEntryDataElementsType `json:"bindingManagementEntryDataElements,omitempty" eebus:"typ:elements,fct:bindingManagementEntryListData"` + BindingManagementRequestCallElements *BindingManagementRequestCallElementsType `json:"bindingManagementRequestCallElements,omitempty" eebus:"typ:elements,fct:bindingManagementRequestCall"` + CommodityDataElements *CommodityDataElementsType `json:"commodityDataElements,omitempty" eebus:"typ:elements,fct:commodityListData"` + DataTunnelingCallElements *DataTunnelingCallElementsType `json:"dataTunnelingCallElements,omitempty" eebus:"typ:elements,fct:dataTunnelingCall"` + DeviceClassificationManufacturerDataElements *DeviceClassificationManufacturerDataElementsType `json:"deviceClassificationManufacturerDataElements,omitempty" eebus:"typ:elements,fct:deviceClassificationManufacturerData"` + DeviceClassificationUserDataElements *DeviceClassificationUserDataElementsType `json:"deviceClassificationUserDataElements,omitempty" eebus:"typ:elements,fct:deviceClassificationUserData"` + DeviceConfigurationKeyValueConstraintsDataElements *DeviceConfigurationKeyValueConstraintsDataElementsType `json:"deviceConfigurationKeyValueConstraintsDataElements,omitempty" eebus:"typ:elements,fct:deviceConfigurationKeyValueConstraintsListData"` + DeviceConfigurationKeyValueDataElements *DeviceConfigurationKeyValueDataElementsType `json:"deviceConfigurationKeyValueDataElements,omitempty" eebus:"typ:elements,fct:deviceConfigurationKeyValueListData"` + DeviceConfigurationKeyValueDescriptionDataElements *DeviceConfigurationKeyValueDescriptionDataElementsType `json:"deviceConfigurationKeyValueDescriptionDataElements,omitempty" eebus:"typ:elements,fct:deviceConfigurationKeyValueDescriptionListData"` + DeviceDiagnosisHeartbeatDataElements *DeviceDiagnosisHeartbeatDataElementsType `json:"deviceDiagnosisHeartbeatDataElements,omitempty" eebus:"typ:elements,fct:deviceDiagnosisHeartbeatData"` + DeviceDiagnosisServiceDataElements *DeviceDiagnosisServiceDataElementsType `json:"deviceDiagnosisServiceDataElements,omitempty" eebus:"typ:elements,fct:deviceDiagnosisServiceData"` + DeviceDiagnosisStateDataElements *DeviceDiagnosisStateDataElementsType `json:"deviceDiagnosisStateDataElements,omitempty" eebus:"typ:elements,fct:deviceDiagnosisStateData"` + DirectControlActivityDataElements *DirectControlActivityDataElementsType `json:"directControlActivityDataElements,omitempty" eebus:"typ:elements,fct:directControlActivityListData"` + DirectControlDescriptionDataElements *DirectControlDescriptionDataElementsType `json:"directControlDescriptionDataElements,omitempty" eebus:"typ:elements,fct:directControlDescriptionData"` + ElectricalConnectionDescriptionDataElements *ElectricalConnectionDescriptionDataElementsType `json:"electricalConnectionDescriptionDataElements,omitempty" eebus:"typ:elements,fct:electricalConnectionDescriptionListData"` + ElectricalConnectionParameterDescriptionDataElements *ElectricalConnectionParameterDescriptionDataElementsType `json:"electricalConnectionParameterDescriptionDataElements,omitempty" eebus:"typ:elements,fct:electricalConnectionParameterDescriptionListData"` + ElectricalConnectionPermittedValueSetDataElements *ElectricalConnectionPermittedValueSetDataElementsType `json:"electricalConnectionPermittedValueSetDataElements,omitempty" eebus:"typ:elements,fct:electricalConnectionPermittedValueSetListData"` + ElectricalConnectionStateDataElements *ElectricalConnectionStateDataElementsType `json:"electricalConnectionStateDataElements,omitempty" eebus:"typ:elements,fct:electricalConnectionStateListData"` + ElectricalConnectionCharacteristicDataElements *ElectricalConnectionCharacteristicDataElementsType `json:"electricalConnectionCharacteristicDataElements,omitempty" eebus:"typ:elements,fct:electricalConnectionCharacteristicListData"` + HvacOperationModeDescriptionDataElements *HvacOperationModeDescriptionDataElementsType `json:"hvacOperationModeDescriptionDataElements,omitempty" eebus:"typ:elements,fct:hvacOperationModeDescriptionListData"` + HvacOverrunDataElements *HvacOverrunDataElementsType `json:"hvacOverrunDataElements,omitempty" eebus:"typ:elements,fct:hvacOverrunListData"` + HvacOverrunDescriptionDataElements *HvacOverrunDescriptionDataElementsType `json:"hvacOverrunDescriptionDataElements,omitempty" eebus:"typ:elements,fct:hvacOverrunDescriptionListData"` + HvacSystemFunctionDataElements *HvacSystemFunctionDataElementsType `json:"hvacSystemFunctionDataElements,omitempty" eebus:"typ:elements,fct:hvacSystemFunctionListData"` + HvacSystemFunctionDescriptionDataElements *HvacSystemFunctionDescriptionDataElementsType `json:"hvacSystemFunctionDescriptionDataElements,omitempty" eebus:"typ:elements,fct:hvacSystemFunctionDescriptionListData"` + HvacSystemFunctionOperationModeRelationDataElements *HvacSystemFunctionOperationModeRelationDataElementsType `json:"hvacSystemFunctionOperationModeRelationDataElements,omitempty" eebus:"typ:elements,fct:hvacSystemFunctionOperationModeRelationListData"` + HvacSystemFunctionPowerSequenceRelationDataElements *HvacSystemFunctionPowerSequenceRelationDataElementsType `json:"hvacSystemFunctionPowerSequenceRelationDataElements,omitempty" eebus:"typ:elements,fct:hvacSystemFunctionPowerSequenceRelationListData"` + HvacSystemFunctionSetpointRelationDataElements *HvacSystemFunctionSetpointRelationDataElementsType `json:"hvacSystemFunctionSetpointRelationDataElements,omitempty" eebus:"typ:elements,fct:hvacSystemFunctionSetpointRelationListData"` + IdentificationDataElements *IdentificationDataElementsType `json:"identificationDataElements,omitempty" eebus:"typ:elements,fct:identificationListData"` + IncentiveDataElements *IncentiveDataElementsType `json:"incentiveDataElements,omitempty" eebus:"typ:elements,fct:incentiveListData"` + IncentiveDescriptionDataElements *IncentiveDescriptionDataElementsType `json:"incentiveDescriptionDataElements,omitempty" eebus:"typ:elements,fct:incentiveDescriptionListData"` + IncentiveTableConstraintsDataElements *IncentiveTableConstraintsDataElementsType `json:"incentiveTableConstraintsDataElements,omitempty" eebus:"typ:elements,fct:incentiveTableConstraintsData"` + IncentiveTableDataElements *IncentiveTableDataElementsType `json:"incentiveTableDataElements,omitempty" eebus:"typ:elements,fct:incentiveTableData"` + IncentiveTableDescriptionDataElements *IncentiveTableDescriptionDataElementsType `json:"incentiveTableDescriptionDataElements,omitempty" eebus:"typ:elements,fct:incentiveTableDescriptionData"` + LoadControlEventDataElements *LoadControlEventDataElementsType `json:"loadControlEventDataElements,omitempty" eebus:"typ:elements,fct:loadControlEventListData"` + LoadControlLimitConstraintsDataElements *LoadControlLimitConstraintsDataElementsType `json:"loadControlLimitConstraintsDataElements,omitempty" eebus:"typ:elements,fct:loadControlLimitConstraintsListData"` + LoadControlLimitDataElements *LoadControlLimitDataElementsType `json:"loadControlLimitDataElements,omitempty" eebus:"typ:elements,fct:loadControlLimitListData"` + LoadControlLimitDescriptionDataElements *LoadControlLimitDescriptionDataElementsType `json:"loadControlLimitDescriptionDataElements,omitempty" eebus:"typ:elements,fct:loadControlLimitDescriptionListData"` + LoadControlNodeDataElements *LoadControlNodeDataElementsType `json:"loadControlNodeDataElements,omitempty" eebus:"typ:elements,fct:loadControlNodeData"` + LoadControlStateDataElements *LoadControlStateDataElementsType `json:"loadControlStateDataElements,omitempty" eebus:"typ:elements,fct:loadControlStateListData"` + MeasurementConstraintsDataElements *MeasurementConstraintsDataElementsType `json:"measurementConstraintsDataElements,omitempty" eebus:"typ:elements,fct:measurementConstraintsListData"` + MeasurementDataElements *MeasurementDataElementsType `json:"measurementDataElements,omitempty" eebus:"typ:elements,fct:measurementListData"` + MeasurementDescriptionDataElements *MeasurementDescriptionDataElementsType `json:"measurementDescriptionDataElements,omitempty" eebus:"typ:elements,fct:measurementDescriptionListData"` + MeasurementSeriesDataElements *MeasurementSeriesDataElementsType `json:"measurementSeriesDataElements,omitempty" eebus:"typ:elements,fct:measurementSeriesListData"` + MeasurementThresholdRelationDataElements *MeasurementThresholdRelationDataElementsType `json:"measurementThresholdRelationDataElements,omitempty" eebus:"typ:elements,fct:measurementThresholdRelationListData"` + MessagingDataElements *MessagingDataElementsType `json:"messagingDataElements,omitempty" eebus:"typ:elements,fct:messagingListData"` + NetworkManagementAbortCallElements *NetworkManagementAbortCallElementsType `json:"networkManagementAbortCallElements,omitempty" eebus:"typ:elements,fct:networkManagementAbortCall"` + NetworkManagementAddNodeCallElements *NetworkManagementAddNodeCallElementsType `json:"networkManagementAddNodeCallElements,omitempty" eebus:"typ:elements,fct:networkManagementAddNodeCall"` + NetworkManagementDeviceDescriptionDataElements *NetworkManagementDeviceDescriptionDataElementsType `json:"networkManagementDeviceDescriptionDataElements,omitempty" eebus:"typ:elements,fct:networkManagementDeviceDescriptionListData"` + NetworkManagementDiscoverCallElements *NetworkManagementDiscoverCallElementsType `json:"networkManagementDiscoverCallElements,omitempty" eebus:"typ:elements,fct:networkManagementDiscoverCall"` + NetworkManagementEntityDescriptionDataElements *NetworkManagementEntityDescriptionDataElementsType `json:"networkManagementEntityDescriptionDataElements,omitempty" eebus:"typ:elements,fct:networkManagementEntityDescriptionListData"` + NetworkManagementFeatureDescriptionDataElements *NetworkManagementFeatureDescriptionDataElementsType `json:"networkManagementFeatureDescriptionDataElements,omitempty" eebus:"typ:elements,fct:networkManagementFeatureDescriptionListData"` + NetworkManagementJoiningModeDataElements *NetworkManagementJoiningModeDataElementsType `json:"networkManagementJoiningModeDataElements,omitempty" eebus:"typ:elements,fct:networkManagementJoiningModeData"` + NetworkManagementModifyNodeCallElements *NetworkManagementModifyNodeCallElementsType `json:"networkManagementModifyNodeCallElements,omitempty" eebus:"typ:elements,fct:networkManagementModifyNodeCall"` + NetworkManagementProcessStateDataElements *NetworkManagementProcessStateDataElementsType `json:"networkManagementProcessStateDataElements,omitempty" eebus:"typ:elements,fct:networkManagementProcessStateData"` + NetworkManagementRemoveNodeCallElements *NetworkManagementRemoveNodeCallElementsType `json:"networkManagementRemoveNodeCallElements,omitempty" eebus:"typ:elements,fct:networkManagementRemoveNodeCall"` + NetworkManagementReportCandidateDataElements *NetworkManagementReportCandidateDataElementsType `json:"networkManagementReportCandidateDataElements,omitempty" eebus:"typ:elements,fct:networkManagementReportCandidateData"` + NetworkManagementScanNetworkCallElements *NetworkManagementScanNetworkCallElementsType `json:"networkManagementScanNetworkCallElements,omitempty" eebus:"typ:elements,fct:networkManagementScanNetworkCall"` + NodeManagementBindingDataElements *NodeManagementBindingDataElementsType `json:"nodeManagementBindingDataElements,omitempty" eebus:"typ:elements,fct:nodeManagementBindingData"` + NodeManagementBindingDeleteCallElements *NodeManagementBindingDeleteCallElementsType `json:"nodeManagementBindingDeleteCallElements,omitempty" eebus:"typ:elements,fct:nodeManagementBindingDeleteCall"` + NodeManagementBindingRequestCallElements *NodeManagementBindingRequestCallElementsType `json:"nodeManagementBindingRequestCallElements,omitempty" eebus:"typ:elements,fct:nodeManagementBindingRequestCall"` + NodeManagementDestinationDataElements *NodeManagementDestinationDataElementsType `json:"nodeManagementDestinationDataElements,omitempty" eebus:"typ:elements,fct:nodeManagementDestinationListData"` + NodeManagementDetailedDiscoveryDataElements *NodeManagementDetailedDiscoveryDataElementsType `json:"nodeManagementDetailedDiscoveryDataElements,omitempty" eebus:"typ:elements,fct:nodeManagementDetailedDiscoveryData"` + NodeManagementSubscriptionDataElements *NodeManagementSubscriptionDataElementsType `json:"nodeManagementSubscriptionDataElements,omitempty" eebus:"typ:elements,fct:nodeManagementSubscriptionData"` + NodeManagementSubscriptionDeleteCallElements *NodeManagementSubscriptionDeleteCallElementsType `json:"nodeManagementSubscriptionDeleteCallElements,omitempty" eebus:"typ:elements,fct:nodeManagementSubscriptionDeleteCall"` + NodeManagementSubscriptionRequestCallElements *NodeManagementSubscriptionRequestCallElementsType `json:"nodeManagementSubscriptionRequestCallElements,omitempty" eebus:"typ:elements,fct:nodeManagementSubscriptionRequestCall"` + NodeManagementUseCaseDataElements *NodeManagementUseCaseDataElementsType `json:"nodeManagementUseCaseDataElements,omitempty" eebus:"typ:elements,fct:nodeManagementUseCaseData"` + OperatingConstraintsDurationDataElements *OperatingConstraintsDurationDataElementsType `json:"operatingConstraintsDurationDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsDurationListData"` + OperatingConstraintsInterruptDataElements *OperatingConstraintsInterruptDataElementsType `json:"operatingConstraintsInterruptDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsInterruptListData"` + OperatingConstraintsPowerDescriptionDataElements *OperatingConstraintsPowerDescriptionDataElementsType `json:"operatingConstraintsPowerDescriptionDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsPowerDescriptionListData"` + OperatingConstraintsPowerLevelDataElements *OperatingConstraintsPowerLevelDataElementsType `json:"operatingConstraintsPowerLevelDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsPowerLevelListData"` + OperatingConstraintsPowerRangeDataElements *OperatingConstraintsPowerRangeDataElementsType `json:"operatingConstraintsPowerRangeDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsPowerRangeListData"` + OperatingConstraintsResumeImplicationDataElements *OperatingConstraintsResumeImplicationDataElementsType `json:"operatingConstraintsResumeImplicationDataElements,omitempty" eebus:"typ:elements,fct:operatingConstraintsResumeImplicationListData"` + PowerSequenceAlternativesRelationDataElements *PowerSequenceAlternativesRelationDataElementsType `json:"powerSequenceAlternativesRelationDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceAlternativesRelationListData"` + PowerSequenceDescriptionDataElements *PowerSequenceDescriptionDataElementsType `json:"powerSequenceDescriptionDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceDescriptionListData"` + PowerSequenceNodeScheduleInformationDataElements *PowerSequenceNodeScheduleInformationDataElementsType `json:"powerSequenceNodeScheduleInformationDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceNodeScheduleInformationData"` + PowerSequencePriceCalculationRequestCallElements *PowerSequencePriceCalculationRequestCallElementsType `json:"powerSequencePriceCalculationRequestCallElements,omitempty" eebus:"typ:elements,fct:powerSequencePriceCalculationRequestCall"` + PowerSequencePriceDataElements *PowerSequencePriceDataElementsType `json:"powerSequencePriceDataElements,omitempty" eebus:"typ:elements,fct:powerSequencePriceListData"` + PowerSequenceScheduleConfigurationRequestCallElements *PowerSequenceScheduleConfigurationRequestCallElementsType `json:"powerSequenceScheduleConfigurationRequestCallElements,omitempty" eebus:"typ:elements,fct:powerSequenceScheduleConfigurationRequestCall"` + PowerSequenceScheduleConstraintsDataElements *PowerSequenceScheduleConstraintsDataElementsType `json:"powerSequenceScheduleConstraintsDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceScheduleConstraintsListData"` + PowerSequenceScheduleDataElements *PowerSequenceScheduleDataElementsType `json:"powerSequenceScheduleDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceScheduleListData"` + PowerSequenceSchedulePreferenceDataElements *PowerSequenceSchedulePreferenceDataElementsType `json:"powerSequenceSchedulePreferenceDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceSchedulePreferenceListData"` + PowerSequenceStateDataElements *PowerSequenceStateDataElementsType `json:"powerSequenceStateDataElements,omitempty" eebus:"typ:elements,fct:powerSequenceStateListData"` + PowerTimeSlotScheduleConstraintsDataElements *PowerTimeSlotScheduleConstraintsDataElementsType `json:"powerTimeSlotScheduleConstraintsDataElements,omitempty" eebus:"typ:elements,fct:powerTimeSlotScheduleConstraintsListData"` + PowerTimeSlotScheduleDataElements *PowerTimeSlotScheduleDataElementsType `json:"powerTimeSlotScheduleDataElements,omitempty" eebus:"typ:elements,fct:powerTimeSlotScheduleListData"` + PowerTimeSlotValueDataElements *PowerTimeSlotValueDataElementsType `json:"powerTimeSlotValueDataElements,omitempty" eebus:"typ:elements,fct:powerTimeSlotValueListData"` + SensingDataElements *SensingDataElementsType `json:"sensingDataElements,omitempty" eebus:"typ:elements,fct:sensingListData"` + SensingDescriptionDataElements *SensingDescriptionDataElementsType `json:"sensingDescriptionDataElements,omitempty" eebus:"typ:elements,fct:sensingDescriptionData"` + SessionIdentificationDataElements *SessionIdentificationDataElementsType `json:"sessionIdentificationDataElements,omitempty" eebus:"typ:elements,fct:sessionIdentificationData"` + SessionMeasurementRelationDataElements *SessionMeasurementRelationDataElementsType `json:"sessionMeasurementRelationDataElements,omitempty" eebus:"typ:elements,fct:sessionMeasurementRelationData"` + SetpointConstraintsDataElements *SetpointConstraintsDataElementsType `json:"setpointConstraintsDataElements,omitempty" eebus:"typ:elements,fct:setpointConstraintsListData"` + SetpointDataElements *SetpointDataElementsType `json:"setpointDataElements,omitempty" eebus:"typ:elements,fct:setpointListData"` + SetpointDescriptionDataElements *SetpointDescriptionDataElementsType `json:"setpointDescriptionDataElements,omitempty" eebus:"typ:elements,fct:"` + SmartEnergyManagementPsConfigurationRequestCallElements *SmartEnergyManagementPsConfigurationRequestCallElementsType `json:"smartEnergyManagementPsConfigurationRequestCallElements,omitempty" eebus:"typ:elements,fct:smartEnergyManagementPsConfigurationRequestCall"` + SmartEnergyManagementPsDataElements *SmartEnergyManagementPsDataElementsType `json:"smartEnergyManagementPsDataElements,omitempty" eebus:"typ:elements,fct:smartEnergyManagementPsData"` + SmartEnergyManagementPsPriceCalculationRequestCallElements *SmartEnergyManagementPsPriceCalculationRequestCallElementsType `json:"smartEnergyManagementPsPriceCalculationRequestCallElements,omitempty" eebus:"typ:elements,fct:smartEnergyManagementPsPriceCalculationRequestCall"` + SmartEnergyManagementPsPriceDataElements *SmartEnergyManagementPsPriceDataElementsType `json:"smartEnergyManagementPsPriceDataElements,omitempty" eebus:"typ:elements,fct:smartEnergyManagementPsPriceData"` + SpecificationVersionDataElements *SpecificationVersionDataElementsType `json:"specificationVersionDataElements,omitempty" eebus:"typ:elements,fct:specificationVersionListData"` + StateInformationDataElements *StateInformationDataElementsType `json:"stateInformationDataElements,omitempty" eebus:"typ:elements,fct:stateInformationListData"` + SubscriptionManagementDeleteCallElements *SubscriptionManagementDeleteCallElementsType `json:"subscriptionManagementDeleteCallElements,omitempty" eebus:"typ:elements,fct:subscriptionManagementDeleteCall"` + SubscriptionManagementEntryDataElements *SubscriptionManagementEntryDataElementsType `json:"subscriptionManagementEntryDataElements,omitempty" eebus:"typ:elements,fct:subscriptionManagementEntryListData"` + SubscriptionManagementRequestCallElements *SubscriptionManagementRequestCallElementsType `json:"subscriptionManagementRequestCallElements,omitempty" eebus:"typ:elements,fct:subscriptionManagementRequestCall"` + SupplyConditionDataElements *SupplyConditionDataElementsType `json:"supplyConditionDataElements,omitempty" eebus:"typ:elements,fct:supplyConditionListData"` + SupplyConditionDescriptionDataElements *SupplyConditionDescriptionDataElementsType `json:"supplyConditionDescriptionDataElements,omitempty" eebus:"typ:elements,fct:supplyConditionDescriptionListData"` + SupplyConditionThresholdRelationDataElements *SupplyConditionThresholdRelationDataElementsType `json:"supplyConditionThresholdRelationDataElements,omitempty" eebus:"typ:elements,fct:supplyConditionThresholdRelationListData"` + TariffBoundaryRelationDataElements *TariffBoundaryRelationDataElementsType `json:"tariffBoundaryRelationDataElements,omitempty" eebus:"typ:elements,fct:tariffBoundaryRelationListData"` + TariffDataElements *TariffDataElementsType `json:"tariffDataElements,omitempty" eebus:"typ:elements,fct:tariffListData"` + TariffDescriptionDataElements *TariffDescriptionDataElementsType `json:"tariffDescriptionDataElements,omitempty" eebus:"typ:elements,fct:tariffDescriptionListData"` + TariffOverallConstraintsDataElements *TariffOverallConstraintsDataElementsType `json:"tariffOverallConstraintsDataElements,omitempty" eebus:"typ:elements,fct:tariffOverallConstraintsData"` + TariffTierRelationDataElements *TariffTierRelationDataElementsType `json:"tariffTierRelationDataElements,omitempty" eebus:"typ:elements,fct:tariffTierRelationListData"` + TaskManagementJobDataElements *TaskManagementJobDataElementsType `json:"taskManagementJobDataElements,omitempty" eebus:"typ:elements,fct:taskManagementJobListData"` + TaskManagementJobDescriptionDataElements *TaskManagementJobDescriptionDataElementsType `json:"taskManagementJobDescriptionDataElements,omitempty" eebus:"typ:elements,fct:taskManagementJobDescriptionListData"` + TaskManagementJobRelationDataElements *TaskManagementJobRelationDataElementsType `json:"taskManagementJobRelationDataElements,omitempty" eebus:"typ:elements,fct:taskManagementJobRelationListData"` + TaskManagementOverviewDataElements *TaskManagementOverviewDataElementsType `json:"taskManagementOverviewDataElements,omitempty" eebus:"typ:elements,fct:taskManagementOverviewData"` + ThresholdConstraintsDataElements *ThresholdConstraintsDataElementsType `json:"thresholdConstraintsDataElements,omitempty" eebus:"typ:elements,fct:thresholdConstraintsListData"` + ThresholdDataElements *ThresholdDataElementsType `json:"thresholdDataElements,omitempty" eebus:"typ:elements,fct:thresholdListData"` + ThresholdDescriptionDataElements *ThresholdDescriptionDataElementsType `json:"thresholdDescriptionDataElements,omitempty" eebus:"typ:elements,fct:thresholdDescriptionListData"` + TierBoundaryDataElements *TierBoundaryDataElementsType `json:"tierBoundaryDataElements,omitempty" eebus:"typ:elements,fct:tierBoundaryListData"` + TierBoundaryDescriptionDataElements *TierBoundaryDescriptionDataElementsType `json:"tierBoundaryDescriptionDataElements,omitempty" eebus:"typ:elements,fct:tierBoundaryDescriptionListData"` + TierDataElements *TierDataElementsType `json:"tierDataElements,omitempty" eebus:"typ:elements,fct:tierListData"` + TierDescriptionDataElements *TierDescriptionDataElementsType `json:"tierDescriptionDataElements,omitempty" eebus:"typ:elements,fct:tierDescriptionListData"` + TierIncentiveRelationDataElements *TierIncentiveRelationDataElementsType `json:"tierIncentiveRelationDataElements,omitempty" eebus:"typ:elements,fct:tierIncentiveRelationListData"` + TimeDistributorDataElements *TimeDistributorDataElementsType `json:"timeDistributorDataElements,omitempty" eebus:"typ:elements,fct:timeDistributorData"` + TimeDistributorEnquiryCallElements *TimeDistributorEnquiryCallElementsType `json:"timeDistributorEnquiryCallElements,omitempty" eebus:"typ:elements,fct:timeDistributorEnquiryCall"` + TimeInformationDataElements *TimeInformationDataElementsType `json:"timeInformationDataElements,omitempty" eebus:"typ:elements,fct:timeInformationData"` + TimePrecisionDataElements *TimePrecisionDataElementsType `json:"timePrecisionDataElements,omitempty" eebus:"typ:elements,fct:timePrecisionData"` + TimeSeriesConstraintsDataElements *TimeSeriesConstraintsDataElementsType `json:"timeSeriesConstraintsDataElements,omitempty" eebus:"typ:elements,fct:timeSeriesConstraintsListData"` + TimeSeriesDataElements *TimeSeriesDataElementsType `json:"timeSeriesDataElements,omitempty" eebus:"typ:elements,fct:timeSeriesListData"` + TimeSeriesDescriptionDataElements *TimeSeriesDescriptionDataElementsType `json:"timeSeriesDescriptionDataElements,omitempty" eebus:"typ:elements,fct:timeSeriesDescriptionListData"` + TimeTableConstraintsDataElements *TimeTableConstraintsDataElementsType `json:"timeTableConstraintsDataElements,omitempty" eebus:"typ:elements,fct:timeTableConstraintsListData"` + TimeTableDataElements *TimeTableDataElementsType `json:"timeTableDataElements,omitempty" eebus:"typ:elements,fct:timeTableListData"` + TimeTableDescriptionDataElements *TimeTableDescriptionDataElementsType `json:"timeTableDescriptionDataElements,omitempty" eebus:"typ:elements,fct:timeTableDescriptionListData"` + UseCaseInformationDataElements *UseCaseInformationDataElementsType `json:"useCaseInformationDataElements,omitempty" eebus:"typ:elements,fct:useCaseInformationListData"` +} + +type CmdControlType struct { + Delete *ElementTagType `json:"delete,omitempty"` + Partial *ElementTagType `json:"partial,omitempty"` +} + +type CmdType struct { + // CmdOptionGroup + Function *FunctionType `json:"function,omitempty"` + Filter []FilterType `json:"filter,omitempty"` + + // DataChoiceGroup + ActuatorLevelData *ActuatorLevelDataType `json:"actuatorLevelData,omitempty" eebus:"fct:actuatorLevelData"` + ActuatorLevelDescriptionData *ActuatorLevelDescriptionDataType `json:"actuatorLevelDescriptionData,omitempty" eebus:"fct:actuatorLevelDescriptionData"` + ActuatorSwitchData *ActuatorSwitchDataType `json:"actuatorSwitchData,omitempty" eebus:"fct:actuatorSwitchData"` + ActuatorSwitchDescriptionData *ActuatorSwitchDescriptionDataType `json:"actuatorSwitchDescriptionData,omitempty" eebus:"fct:actuatorSwitchDescriptionData"` + AlarmListData *AlarmListDataType `json:"alarmListData,omitempty" eebus:"fct:alarmListData"` + BillConstraintsListData *BillConstraintsListDataType `json:"billConstraintsListData,omitempty" eebus:"fct:billConstraintsListData"` + BillDescriptionListData *BillDescriptionListDataType `json:"billDescriptionListData,omitempty" eebus:"fct:billDescriptionListData"` + BillListData *BillListDataType `json:"billListData,omitempty" eebus:"fct:billListData"` + BindingManagementDeleteCall *BindingManagementDeleteCallType `json:"bindingManagementDeleteCall,omitempty" eebus:"fct:bindingManagementDeleteCall"` + BindingManagementEntryListData *BindingManagementEntryListDataType `json:"bindingManagementEntryListData,omitempty" eebus:"fct:bindingManagementEntryListData"` + BindingManagementRequestCall *BindingManagementRequestCallType `json:"bindingManagementRequestCall,omitempty" eebus:"fct:bindingManagementRequestCall"` + CommodityListData *CommodityListDataType `json:"commodityListData,omitempty" eebus:"fct:commodityListData"` + DataTunnelingCall *DataTunnelingCallType `json:"dataTunnelingCall,omitempty" eebus:"fct:dataTunnelingCall"` + DeviceClassificationManufacturerData *DeviceClassificationManufacturerDataType `json:"deviceClassificationManufacturerData,omitempty" eebus:"fct:deviceClassificationManufacturerData"` + DeviceClassificationUserData *DeviceClassificationUserDataType `json:"deviceClassificationUserData,omitempty" eebus:"fct:deviceClassificationUserData"` + DeviceConfigurationKeyValueConstraintsListData *DeviceConfigurationKeyValueConstraintsListDataType `json:"deviceConfigurationKeyValueConstraintsListData,omitempty" eebus:"fct:deviceConfigurationKeyValueConstraintsListData"` + DeviceConfigurationKeyValueDescriptionListData *DeviceConfigurationKeyValueDescriptionListDataType `json:"deviceConfigurationKeyValueDescriptionListData,omitempty" eebus:"fct:deviceConfigurationKeyValueDescriptionListData"` + DeviceConfigurationKeyValueListData *DeviceConfigurationKeyValueListDataType `json:"deviceConfigurationKeyValueListData,omitempty" eebus:"fct:deviceConfigurationKeyValueListData"` + DeviceDiagnosisHeartbeatData *DeviceDiagnosisHeartbeatDataType `json:"deviceDiagnosisHeartbeatData,omitempty" eebus:"fct:deviceDiagnosisHeartbeatData"` + DeviceDiagnosisServiceData *DeviceDiagnosisServiceDataType `json:"deviceDiagnosisServiceData,omitempty" eebus:"fct:deviceDiagnosisServiceData"` + DeviceDiagnosisStateData *DeviceDiagnosisStateDataType `json:"deviceDiagnosisStateData,omitempty" eebus:"fct:deviceDiagnosisStateData"` + DirectControlActivityListData *DirectControlActivityListDataType `json:"directControlActivityListData,omitempty" eebus:"fct:directControlActivityListData"` + DirectControlDescriptionData *DirectControlDescriptionDataType `json:"directControlDescriptionData,omitempty" eebus:"fct:directControlDescriptionData"` + ElectricalConnectionDescriptionListData *ElectricalConnectionDescriptionListDataType `json:"electricalConnectionDescriptionListData,omitempty" eebus:"fct:electricalConnectionDescriptionListData"` + ElectricalConnectionParameterDescriptionListData *ElectricalConnectionParameterDescriptionListDataType `json:"electricalConnectionParameterDescriptionListData,omitempty" eebus:"fct:electricalConnectionParameterDescriptionListData"` + ElectricalConnectionPermittedValueSetListData *ElectricalConnectionPermittedValueSetListDataType `json:"electricalConnectionPermittedValueSetListData,omitempty" eebus:"fct:electricalConnectionPermittedValueSetListData"` + ElectricalConnectionStateListData *ElectricalConnectionStateListDataType `json:"electricalConnectionStateListData,omitempty" eebus:"fct:electricalConnectionStateListData"` + ElectricalConnectionCharacteristicData *ElectricalConnectionCharacteristicDataType `json:"electricalConnectionCharacteristicData,omitempty" eebus:"fct:electricalConnectionCharacteristicData"` + ElectricalConnectionCharacteristicListData *ElectricalConnectionCharacteristicListDataType `json:"electricalConnectionCharacteristicListData,omitempty" eebus:"fct:electricalConnectionCharacteristicListData"` + HvacOperationModeDescriptionListData *HvacOperationModeDescriptionListDataType `json:"hvacOperationModeDescriptionListData,omitempty" eebus:"fct:hvacOperationModeDescriptionListData"` + HvacOverrunDescriptionListData *HvacOverrunDescriptionListDataType `json:"hvacOverrunDescriptionListData,omitempty" eebus:"fct:hvacOverrunDescriptionListData"` + HvacOverrunListData *HvacOverrunListDataType `json:"hvacOverrunListData,omitempty" eebus:"fct:hvacOverrunListData"` + HvacSystemFunctionDescriptionListData *HvacSystemFunctionDescriptionListDataType `json:"hvacSystemFunctionDescriptionListData,omitempty" eebus:"fct:hvacSystemFunctionDescriptionListData"` + HvacSystemFunctionListData *HvacSystemFunctionListDataType `json:"hvacSystemFunctionListData,omitempty" eebus:"fct:hvacSystemFunctionListData"` + HvacSystemFunctionOperationModeRelationListData *HvacSystemFunctionOperationModeRelationListDataType `json:"hvacSystemFunctionOperationModeRelationListData,omitempty" eebus:"fct:hvacSystemFunctionOperationModeRelationListData"` + HvacSystemFunctionPowerSequenceRelationListData *HvacSystemFunctionPowerSequenceRelationListDataType `json:"hvacSystemFunctionPowerSequenceRelationListData,omitempty" eebus:"fct:hvacSystemFunctionPowerSequenceRelationListData"` + HvacSystemFunctionSetPointRelationListData *HvacSystemFunctionSetpointRelationListDataType `json:"hvacSystemFunctionSetpointRelationListData,omitempty" eebus:"fct:hvacSystemFunctionSetpointRelationListData"` + IdentificationListData *IdentificationListDataType `json:"identificationListData,omitempty" eebus:"fct:identificationListData"` + IncentiveDescriptionListData *IncentiveDescriptionListDataType `json:"incentiveDescriptionListData,omitempty" eebus:"fct:incentiveDescriptionListData"` + IncentiveListData *IncentiveListDataType `json:"incentiveListData,omitempty" eebus:"fct:incentiveListData"` + IncentiveTableConstraintsData *IncentiveTableConstraintsDataType `json:"incentiveTableConstraintsData,omitempty" eebus:"fct:incentiveTableConstraintsData"` + IncentiveTableData *IncentiveTableDataType `json:"incentiveTableData,omitempty" eebus:"fct:incentiveTableData"` + IncentiveTableDescriptionData *IncentiveTableDescriptionDataType `json:"incentiveTableDescriptionData,omitempty" eebus:"fct:incentiveTableDescriptionData"` + LoadControlEventListData *LoadControlEventListDataType `json:"loadControlEventListData,omitempty" eebus:"fct:loadControlEventListData"` + LoadControlLimitConstraintsListData *LoadControlLimitConstraintsListDataType `json:"loadControlLimitConstraintsListData,omitempty" eebus:"fct:loadControlLimitConstraintsListData"` + LoadControlLimitDescriptionListData *LoadControlLimitDescriptionListDataType `json:"loadControlLimitDescriptionListData,omitempty" eebus:"fct:loadControlLimitDescriptionListData"` + LoadControlLimitListData *LoadControlLimitListDataType `json:"loadControlLimitListData,omitempty" eebus:"fct:loadControlLimitListData"` + LoadControlNodeData *LoadControlNodeDataType `json:"loadControlNodeData,omitempty" eebus:"fct:loadControlNodeData"` + LoadControlStateListData *LoadControlStateListDataType `json:"loadControlStateListData,omitempty" eebus:"fct:loadControlStateListData"` + MeasurementConstraintsListData *MeasurementConstraintsListDataType `json:"measurementConstraintsListData,omitempty" eebus:"fct:measurementConstraintsListData"` + MeasurementDescriptionListData *MeasurementDescriptionListDataType `json:"measurementDescriptionListData,omitempty" eebus:"fct:measurementDescriptionListData"` + MeasurementListData *MeasurementListDataType `json:"measurementListData,omitempty" eebus:"fct:measurementListData"` + MeasurementSeriesListData *MeasurementSeriesListDataType `json:"measurementSeriesListData,omitempty" eebus:"fct:measurementSeriesListData"` + MeasurementThresholdRelationListData *MeasurementThresholdRelationListDataType `json:"measurementThresholdRelationListData,omitempty" eebus:"fct:measurementThresholdRelationListData"` + MessagingListData *MessagingListDataType `json:"messagingListData,omitempty" eebus:"fct:messagingListData"` + NetworkManagementAbortCall *NetworkManagementAbortCallType `json:"networkManagementAbortCall,omitempty" eebus:"fct:networkManagementAbortCall"` + NetworkManagementAddNodeCall *NetworkManagementAddNodeCallType `json:"networkManagementAddNodeCall,omitempty" eebus:"fct:networkManagementAddNodeCall"` + NetworkManagementDeviceDescriptionListData *NetworkManagementDeviceDescriptionListDataType `json:"networkManagementDeviceDescriptionListData,omitempty" eebus:"fct:networkManagementDeviceDescriptionListData"` + NetworkManagementDiscoverCall *NetworkManagementDiscoverCallType `json:"networkManagementDiscoverCall,omitempty" eebus:"fct:networkManagementDiscoverCall"` + NetworkManagementEntityDescriptionListData *NetworkManagementEntityDescriptionListDataType `json:"networkManagementEntityDescriptionListData,omitempty" eebus:"fct:networkManagementEntityDescriptionListData"` + NetworkManagementFeatureDescriptionListData *NetworkManagementFeatureDescriptionListDataType `json:"networkManagementFeatureDescriptionListData,omitempty" eebus:"fct:networkManagementFeatureDescriptionListData"` + NetworkManagementJoiningModeData *NetworkManagementJoiningModeDataType `json:"networkManagementJoiningModeData,omitempty" eebus:"fct:networkManagementJoiningModeData"` + NetworkManagementModifyNodeCall *NetworkManagementModifyNodeCallType `json:"networkManagementModifyNodeCall,omitempty" eebus:"fct:networkManagementModifyNodeCall"` + NetworkManagementProcessStateData *NetworkManagementProcessStateDataType `json:"networkManagementProcessStateData,omitempty" eebus:"fct:networkManagementProcessStateData"` + NetworkManagementRemoveNodeCall *NetworkManagementRemoveNodeCallType `json:"networkManagementRemoveNodeCall,omitempty" eebus:"fct:networkManagementRemoveNodeCall"` + NetworkManagementReportCandidateData *NetworkManagementReportCandidateDataType `json:"networkManagementReportCandidateData,omitempty" eebus:"fct:networkManagementReportCandidateData"` + NetworkManagementScanNetworkCall *NetworkManagementScanNetworkCallType `json:"networkManagementScanNetworkCall,omitempty" eebus:"fct:networkManagementScanNetworkCall"` + NodeManagementBindingData *NodeManagementBindingDataType `json:"nodeManagementBindingData,omitempty" eebus:"fct:nodeManagementBindingData"` + NodeManagementBindingDeleteCall *NodeManagementBindingDeleteCallType `json:"nodeManagementBindingDeleteCall,omitempty" eebus:"fct:nodeManagementBindingDeleteCall"` + NodeManagementBindingRequestCall *NodeManagementBindingRequestCallType `json:"nodeManagementBindingRequestCall,omitempty" eebus:"fct:nodeManagementBindingRequestCall"` + NodeManagementDestinationListData *NodeManagementDestinationListDataType `json:"nodeManagementDestinationListData,omitempty" eebus:"fct:nodeManagementDestinationListData"` + NodeManagementDetailedDiscoveryData *NodeManagementDetailedDiscoveryDataType `json:"nodeManagementDetailedDiscoveryData,omitempty" eebus:"fct:nodeManagementDetailedDiscoveryData"` + NodeManagementSubscriptionData *NodeManagementSubscriptionDataType `json:"nodeManagementSubscriptionData,omitempty" eebus:"fct:nodeManagementSubscriptionData"` + NodeManagementSubscriptionDeleteCall *NodeManagementSubscriptionDeleteCallType `json:"nodeManagementSubscriptionDeleteCall,omitempty" eebus:"fct:nodeManagementSubscriptionDeleteCall"` + NodeManagementSubscriptionRequestCall *NodeManagementSubscriptionRequestCallType `json:"nodeManagementSubscriptionRequestCall,omitempty" eebus:"fct:nodeManagementSubscriptionRequestCall"` + NodeManagementUseCaseData *NodeManagementUseCaseDataType `json:"nodeManagementUseCaseData,omitempty" eebus:"fct:nodeManagementUseCaseData"` + OperatingConstraintsDurationListData *OperatingConstraintsDurationListDataType `json:"operatingConstraintsDurationListData,omitempty" eebus:"fct:operatingConstraintsDurationListData"` + OperatingConstraintsInterruptListData *OperatingConstraintsInterruptListDataType `json:"operatingConstraintsInterruptListData,omitempty" eebus:"fct:operatingConstraintsInterruptListData"` + OperatingConstraintsPowerDescriptionListData *OperatingConstraintsPowerDescriptionListDataType `json:"operatingConstraintsPowerDescriptionListData,omitempty" eebus:"fct:operatingConstraintsPowerDescriptionListData"` + OperatingConstraintsPowerLevelListData *OperatingConstraintsPowerLevelListDataType `json:"operatingConstraintsPowerLevelListData,omitempty" eebus:"fct:operatingConstraintsPowerLevelListData"` + OperatingConstraintsPowerRangeListData *OperatingConstraintsPowerRangeListDataType `json:"operatingConstraintsPowerRangeListData,omitempty" eebus:"fct:operatingConstraintsPowerRangeListData"` + OperatingConstraintsResumeImplicationListData *OperatingConstraintsResumeImplicationListDataType `json:"operatingConstraintsResumeImplicationListData,omitempty" eebus:"fct:operatingConstraintsResumeImplicationListData"` + PowerSequenceAlternativesRelationListData *PowerSequenceAlternativesRelationListDataType `json:"powerSequenceAlternativesRelationListData,omitempty" eebus:"fct:powerSequenceAlternativesRelationListData"` + PowerSequenceDescriptionListData *PowerSequenceDescriptionListDataType `json:"powerSequenceDescriptionListData,omitempty" eebus:"fct:powerSequenceDescriptionListData"` + PowerSequenceNodeScheduleInformationData *PowerSequenceNodeScheduleInformationDataType `json:"powerSequenceNodeScheduleInformationData,omitempty" eebus:"fct:powerSequenceNodeScheduleInformationData"` + PowerSequencePriceCalculationRequestCall *PowerSequencePriceCalculationRequestCallType `json:"powerSequencePriceCalculationRequestCall,omitempty" eebus:"fct:powerSequencePriceCalculationRequestCall"` + PowerSequencePriceListData *PowerSequencePriceListDataType `json:"powerSequencePriceListData,omitempty" eebus:"fct:powerSequencePriceListData"` + PowerSequenceScheduleConfigurationRequestCall *PowerSequenceScheduleConfigurationRequestCallType `json:"powerSequenceScheduleConfigurationRequestCall,omitempty" eebus:"fct:powerSequenceScheduleConfigurationRequestCall"` + PowerSequenceScheduleConstraintsListData *PowerSequenceScheduleConstraintsListDataType `json:"powerSequenceScheduleConstraintsListData,omitempty" eebus:"fct:powerSequenceScheduleConstraintsListData"` + PowerSequenceScheduleListData *PowerSequenceScheduleListDataType `json:"powerSequenceScheduleListData,omitempty" eebus:"fct:powerSequenceScheduleListData"` + PowerSequenceSchedulePreferenceListData *PowerSequenceSchedulePreferenceListDataType `json:"powerSequenceSchedulePreferenceListData,omitempty" eebus:"fct:powerSequenceSchedulePreferenceListData"` + PowerSequenceStateListData *PowerSequenceStateListDataType `json:"powerSequenceStateListData,omitempty" eebus:"fct:powerSequenceStateListData"` + PowerTimeSlotScheduleConstraintsListData *PowerTimeSlotScheduleConstraintsListDataType `json:"powerTimeSlotScheduleConstraintsListData,omitempty" eebus:"fct:powerTimeSlotScheduleConstraintsListData"` + PowerTimeSlotScheduleListData *PowerTimeSlotScheduleListDataType `json:"powerTimeSlotScheduleListData,omitempty" eebus:"fct:powerTimeSlotScheduleListData"` + PowerTimeSlotValueListData *PowerTimeSlotValueListDataType `json:"powerTimeSlotValueListData,omitempty" eebus:"fct:powerTimeSlotValueListData"` + ResultData *ResultDataType `json:"resultData,omitempty" eebus:"fct:resultData"` + SensingDescriptionData *SensingDescriptionDataType `json:"sensingDescriptionData,omitempty" eebus:"fct:sensingDescriptionData"` + SensingListData *SensingListDataType `json:"sensingListData,omitempty" eebus:"fct:sensingListData"` + SessionIdentificationListData *SessionIdentificationListDataType `json:"sessionIdentificationListData,omitempty" eebus:"fct:sessionIdentificationListData"` + SessionMeasurementRelationListData *SessionMeasurementRelationListDataType `json:"sessionMeasurementRelationListData,omitempty" eebus:"fct:sessionMeasurementRelationListData"` + SetpointConstraintsListData *SetpointConstraintsListDataType `json:"setpointConstraintsListData,omitempty" eebus:"fct:setpointConstraintsListData"` + SetpointDescriptionListData *SetpointDescriptionListDataType `json:"setpointDescriptionListData,omitempty" eebus:"fct:setpointDescriptionListData"` + SetpointListData *SetpointListDataType `json:"setpointListData,omitempty" eebus:"fct:setpointListData"` + SmartEnergyManagementPsConfigurationRequestCall *SmartEnergyManagementPsConfigurationRequestCallType `json:"smartEnergyManagementPsConfigurationRequestCall,omitempty" eebus:"fct:smartEnergyManagementPsConfigurationRequestCall"` + SmartEnergyManagementPsData *SmartEnergyManagementPsDataType `json:"smartEnergyManagementPsData,omitempty" eebus:"fct:smartEnergyManagementPsData"` + SmartEnergyManagementPsPriceCalculationRequestCall *SmartEnergyManagementPsPriceCalculationRequestCallType `json:"smartEnergyManagementPsPriceCalculationRequestCall,omitempty" eebus:"fct:smartEnergyManagementPsPriceCalculationRequestCall"` + SmartEnergyManagementPsPriceData *SmartEnergyManagementPsPriceDataType `json:"smartEnergyManagementPsPriceData,omitempty" eebus:"fct:smartEnergyManagementPsPriceData"` + SpecificationVersionListData *SpecificationVersionListDataType `json:"specificationVersionListData,omitempty" eebus:"fct:specificationVersionListData"` + StateInformationListData *StateInformationListDataType `json:"stateInformationListData,omitempty" eebus:"fct:stateInformationListData"` + SubscriptionManagementDeleteCall *SubscriptionManagementDeleteCallType `json:"subscriptionManagementDeleteCall,omitempty" eebus:"fct:subscriptionManagementDeleteCall"` + SubscriptionManagementEntryListData *SubscriptionManagementEntryListDataType `json:"subscriptionManagementEntryListData,omitempty" eebus:"fct:subscriptionManagementEntryListData"` + SubscriptionManagementRequestCall *SubscriptionManagementRequestCallType `json:"subscriptionManagementRequestCall,omitempty" eebus:"fct:subscriptionManagementRequestCall"` + SupplyConditionDescriptionListData *SupplyConditionDescriptionListDataType `json:"supplyConditionDescriptionListData,omitempty" eebus:"fct:supplyConditionDescriptionListData"` + SupplyConditionListData *SupplyConditionListDataType `json:"supplyConditionListData,omitempty" eebus:"fct:supplyConditionListData"` + SupplyConditionThresholdRelationListData *SupplyConditionThresholdRelationListDataType `json:"supplyConditionThresholdRelationListData,omitempty" eebus:"fct:supplyConditionThresholdRelationListData"` + TariffBoundaryRelationListData *TariffBoundaryRelationListDataType `json:"tariffBoundaryRelationListData,omitempty" eebus:"fct:tariffBoundaryRelationListData"` + TariffDescriptionListData *TariffDescriptionListDataType `json:"tariffDescriptionListData,omitempty" eebus:"fct:tariffDescriptionListData"` + TariffListData *TariffListDataType `json:"tariffListData,omitempty" eebus:"fct:tariffListData"` + TariffOverallConstraintsData *TariffOverallConstraintsDataType `json:"tariffOverallConstraintsData,omitempty" eebus:"fct:tariffOverallConstraintsData"` + TariffTierRelationListData *TariffTierRelationListDataType `json:"tariffTierRelationListData,omitempty" eebus:"fct:tariffTierRelationListData"` + TaskManagementJobDescriptionListData *TaskManagementJobDescriptionListDataType `json:"taskManagementJobDescriptionListData,omitempty" eebus:"fct:taskManagementJobDescriptionListData"` + TaskManagementJobListData *TaskManagementJobListDataType `json:"taskManagementJobListData,omitempty" eebus:"fct:taskManagementJobListData"` + TaskManagementJobRelationListData *TaskManagementJobRelationListDataType `json:"taskManagementJobRelationListData,omitempty" eebus:"fct:taskManagementJobRelationListData"` + TaskManagementOverviewData *TaskManagementOverviewDataType `json:"taskManagementOverviewData,omitempty" eebus:"fct:taskManagementOverviewData"` + ThresholdConstraintsListData *ThresholdConstraintsListDataType `json:"thresholdConstraintsListData,omitempty" eebus:"fct:thresholdConstraintsListData"` + ThresholdDescriptionListData *ThresholdDescriptionListDataType `json:"thresholdDescriptionListData,omitempty" eebus:"fct:thresholdDescriptionListData"` + ThresholdListData *ThresholdListDataType `json:"thresholdListData,omitempty" eebus:"fct:thresholdListData"` + TierBoundaryDescriptionListData *TierBoundaryDescriptionListDataType `json:"tierBoundaryDescriptionListData,omitempty" eebus:"fct:tierBoundaryDescriptionListData"` + TierBoundaryListData *TierBoundaryListDataType `json:"tierBoundaryListData,omitempty" eebus:"fct:tierBoundaryListData"` + TierDescriptionListData *TierDescriptionListDataType `json:"tierDescriptionListData,omitempty" eebus:"fct:tierDescriptionListData"` + TierIncentiveRelationListData *TierIncentiveRelationListDataType `json:"tierIncentiveRelationListData,omitempty" eebus:"fct:tierIncentiveRelationListData"` + TierListData *TierListDataType `json:"tierListData,omitempty" eebus:"fct:tierListData"` + TimeDistributorData *TimeDistributorDataType `json:"timeDistributorData,omitempty" eebus:"fct:timeDistributorData"` + TimeDistributorEnquiryCall *TimeDistributorEnquiryCallType `json:"timeDistributorEnquiryCall,omitempty" eebus:"fct:timeDistributorEnquiryCall"` + TimeInformationData *TimeInformationDataType `json:"timeInformationData,omitempty" eebus:"fct:timeInformationData"` + TimePrecisionData *TimePrecisionDataType `json:"timePrecisionData,omitempty" eebus:"fct:timePrecisionData"` + TimeSeriesConstraintsListData *TimeSeriesConstraintsListDataType `json:"timeSeriesConstraintsListData,omitempty" eebus:"fct:timeSeriesConstraintsListData"` + TimeSeriesDescriptionListData *TimeSeriesDescriptionListDataType `json:"timeSeriesDescriptionListData,omitempty" eebus:"fct:timeSeriesDescriptionListData"` + TimeSeriesListData *TimeSeriesListDataType `json:"timeSeriesListData,omitempty" eebus:"fct:timeSeriesListData"` + TimeTableConstraintsListData *TimeTableConstraintsListDataType `json:"timeTableConstraintsListData,omitempty" eebus:"fct:timeTableConstraintsListData"` + TimeTableDescriptionListData *TimeTableDescriptionListDataType `json:"timeTableDescriptionListData,omitempty" eebus:"fct:timeTableDescriptionListData"` + TimeTableListData *TimeTableListDataType `json:"timeTableListData,omitempty" eebus:"fct:timeTableListData"` + UseCaseInformationListData *UseCaseInformationListDataType `json:"useCaseInformationListData,omitempty" eebus:"fct:useCaseInformationListData"` + + // DataExtendGroup + ManufacturerSpecificExtension *string `json:"manufacturerSpecificExtension,omitempty"` + LastUpdateAt *AbsoluteOrRelativeTimeType `json:"lastUpdateAt,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/commandframe_additions.go b/src/eebus-bridge/third_party/spine-go/model/commandframe_additions.go new file mode 100644 index 0000000..8d771db --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/commandframe_additions.go @@ -0,0 +1,297 @@ +package model + +import ( + "errors" + "fmt" + "reflect" + + "github.com/enbility/spine-go/util" +) + +func (r *MsgCounterType) String() string { + if r == nil { + return "" + } + return fmt.Sprintf("%d", *r) +} + +// FilterData stores the function field name and +// selector field name for a function +type FilterData struct { + Elements any + Selector any + Function *FunctionType +} + +func (f *FilterData) SelectorMatch(item any) bool { + if f.Selector == nil { + return false + } + + v := reflect.ValueOf(f.Selector).Elem() + t := reflect.TypeOf(f.Selector).Elem() + + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + if field.Kind() != reflect.Ptr { + continue + } + + if field.IsNil() { + continue + } + + fieldname := t.Field(i).Name + value := field.Elem().Interface() + + itemV := reflect.ValueOf(item).Elem() + itemF := itemV.FieldByName(fieldname) + if !itemF.IsValid() { + continue + } + + itemValue := itemF.Elem().Interface() + if itemValue != value { + return false + } + } + + return true +} + +// Get the field for a given functionType +func (f *FilterType) SetDataForFunction(tagType EEBusTagTypeType, fct FunctionType, data any) { + if data == nil || reflect.ValueOf(data).Kind() != reflect.Ptr { + return + } + + v := reflect.ValueOf(*f) + dv := reflect.ValueOf(f).Elem() + for i := 0; i < v.NumField(); i++ { + field := v.Field(i) + if field.Kind() != reflect.Ptr { + continue + } + + sf := v.Type().Field(i) + // Exclude the generic fields + if sf.Name == "CmdControl" || sf.Name == "FilterId" { + continue + } + + eebusTags := EEBusTags(sf) + function, exists := eebusTags[EEBusTagFunction] + if !exists { + continue + } + typ, exists := eebusTags[EEBusTagType] + if !exists || len(typ) == 0 { + continue + } + if typ != string(tagType) { + continue + } + + if fct != FunctionType(function) { + continue + } + + n := v.Type().Field(i).Name + ff := dv.FieldByName(n) + + if !ff.CanSet() { + break + } + + if reflect.ValueOf(data).IsNil() { + typ := reflect.TypeOf(data).Elem() + ff.Set(reflect.New(typ)) + return + } + + dataV := reflect.ValueOf(data) + dataC := dataV.Convert(ff.Type()) + ff.Set(dataC) + return + } +} + +// Get the data and some meta data for the current value +func (f *FilterType) Data() (*FilterData, error) { + var elements any = nil + var selector any = nil + var function string + + v := reflect.ValueOf(*f) + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + if f.Kind() != reflect.Ptr { + continue + } + + if f.IsNil() { + continue + } + + sf := v.Type().Field(i) + // Exclude the generic fields + if sf.Name == "CmdControl" || sf.Name == "FilterId" { + continue + } + + eebusTags := EEBusTags(sf) + fname, exists := eebusTags[EEBusTagFunction] + if !exists || len(fname) == 0 { + continue + } + typ, exists := eebusTags[EEBusTagType] + if !exists || len(typ) == 0 { + continue + } + + function = fname + + switch typ { + case string(EEBusTagTypeTypeSelector): + selector = f.Interface() + case string(EEbusTagTypeTypeElements): + elements = f.Interface() + } + } + + if len(function) == 0 { + return nil, errors.New("Data not found in Filter") + } + + ft := util.Ptr(FunctionType(function)) + + return &FilterData{ + Elements: elements, + Selector: selector, + Function: ft, + }, nil +} + +// CmdData stores the function field name for a cmd field +type CmdData struct { + FieldName string + Function *FunctionType + Value any +} + +// Get the field for a given functionType +func (cmd *CmdType) SetDataForFunction(fct FunctionType, data any) { + if data == nil || reflect.ValueOf(data).Kind() != reflect.Ptr { + return + } + + v := reflect.ValueOf(*cmd) + dv := reflect.ValueOf(cmd).Elem() + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + if f.Kind() != reflect.Ptr { + continue + } + + sf := v.Type().Field(i) + // Exclude the CmdOptionGroup fields + if sf.Name == "Function" || sf.Name == "Filter" { + continue + } + + eebusTags := EEBusTags(sf) + function, exists := eebusTags[EEBusTagFunction] + if !exists { + continue + } + + if fct != FunctionType(function) { + continue + } + + n := v.Type().Field(i).Name + ff := dv.FieldByName(n) + + if !ff.CanSet() { + break + } + + if reflect.ValueOf(data).IsNil() { + typ := reflect.TypeOf(data).Elem() + ff.Set(reflect.New(typ)) + return + } + + dataV := reflect.ValueOf(data) + dataC := dataV.Convert(ff.Type()) + ff.Set(dataC) + return + } +} + +// Get the data and some meta data of the current value +func (cmd *CmdType) Data() (*CmdData, error) { + v := reflect.ValueOf(*cmd) + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + if f.Kind() != reflect.Ptr { + continue + } + + if f.IsNil() { + continue + } + + sf := v.Type().Field(i) + // Exclude the CmdOptionGroup fields + if sf.Name == "Function" || sf.Name == "Filter" { + continue + } + + eebusTags := EEBusTags(sf) + function, exists := eebusTags[EEBusTagFunction] + if !exists { + continue + } + + var ft *FunctionType = nil + if len(function) > 0 { + ft = util.Ptr(FunctionType(function)) + } + + return &CmdData{ + FieldName: sf.Name, + Function: ft, + Value: f.Interface(), + }, nil + } + + return nil, errors.New("Data not found in Cmd") +} + +// Get the non empty field name of the data type +func (cmd *CmdType) DataName() string { + data, err := cmd.Data() + if err != nil { + return "unknown" + } + + return data.FieldName +} + +func (cmd *CmdType) ExtractFilter() (filterPartial *FilterType, filterDelete *FilterType) { + if cmd != nil && cmd.Filter != nil && len(cmd.Filter) > 0 { + for i := range cmd.Filter { + if cmd.Filter[i].CmdControl.Partial != nil { + filterPartial = &cmd.Filter[i] + } else if cmd.Filter[i].CmdControl.Delete != nil { + filterDelete = &cmd.Filter[i] + } + } + } + return +} + +func NewFilterTypePartial() *FilterType { + return &FilterType{CmdControl: &CmdControlType{Partial: &ElementTagType{}}} +} diff --git a/src/eebus-bridge/third_party/spine-go/model/commondatatypes.go b/src/eebus-bridge/third_party/spine-go/model/commondatatypes.go new file mode 100644 index 0000000..b202a32 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/commondatatypes.go @@ -0,0 +1,987 @@ +package model + +type ElementTagType struct{} + +type LabelType string + +type DescriptionType string + +type SpecificationVersionType string + +type TimePeriodType struct { + StartTime *AbsoluteOrRelativeTimeType `json:"startTime,omitempty"` + EndTime *AbsoluteOrRelativeTimeType `json:"endTime,omitempty"` +} + +type TimePeriodElementsType struct { + StartTime *ElementTagType `json:"startTime,omitempty"` + EndTime *ElementTagType `json:"endTime,omitempty"` +} + +type TimestampIntervalType struct { + StartTime *AbsoluteOrRelativeTimeType `json:"startTime,omitempty"` + EndTime *AbsoluteOrRelativeTimeType `json:"endTime,omitempty"` +} + +type TimeType string + +type DateType string + +type DateTimeType string + +type DurationType string + +type AbsoluteOrRelativeTimeType string + +type RecurringIntervalType string + +const ( + RecurringIntervalTypeYearly RecurringIntervalType = "yearly" + RecurringIntervalTypeMonthly RecurringIntervalType = "monthly" + RecurringIntervalTypeWeekly RecurringIntervalType = "weekly" + RecurringIntervalTypeDaily RecurringIntervalType = "daily" + RecurringIntervalTypeHourly RecurringIntervalType = "hourly" + RecurringIntervalTypeEveryminute RecurringIntervalType = "everyMinute" + RecurringIntervalTypeEverysecond RecurringIntervalType = "everySecond" +) + +type MonthType string + +const ( + MonthTypeJanuary MonthType = "january" + MonthTypeFebruary MonthType = "february" + MonthTypeMarch MonthType = "march" + MonthTypeApril MonthType = "april" + MonthTypeMay MonthType = "may" + MonthTypeJune MonthType = "june" + MonthTypeJuly MonthType = "july" + MonthTypeAugust MonthType = "august" + MonthTypeSeptember MonthType = "september" + MonthTypeOctober MonthType = "october" + MonthTypeNovember MonthType = "november" + MonthTypeDecember MonthType = "december" +) + +type DayOfMonthType uint8 + +type CalendarWeekType uint8 + +type DayOfWeekType string + +const ( + DayOfWeekTypeMonday DayOfWeekType = "monday" + DayOfWeekTypeTuesday DayOfWeekType = "tuesday" + DayOfWeekTypeWednesday DayOfWeekType = "wednesday" + DayOfWeekTypeThursday DayOfWeekType = "thursday" + DayOfWeekTypeFriday DayOfWeekType = "friday" + DayOfWeekTypeSaturday DayOfWeekType = "saturday" + DayOfWeekTypeSunday DayOfWeekType = "sunday" +) + +type DaysOfWeekType struct { + Monday *ElementTagType `json:"monday,omitempty"` + Tuesday *ElementTagType `json:"tuesday,omitempty"` + Wednesday *ElementTagType `json:"wednesday,omitempty"` + Thursday *ElementTagType `json:"thursday,omitempty"` + Friday *ElementTagType `json:"friday,omitempty"` + Saturday *ElementTagType `json:"saturday,omitempty"` + Sunday *ElementTagType `json:"sunday,omitempty"` +} + +type OccurrenceType string + +const ( + OccurrenceTypeFirst OccurrenceType = "first" + OccurrenceTypeSecond OccurrenceType = "second" + OccurrenceTypeThird OccurrenceType = "third" + OccurrenceTypeFourth OccurrenceType = "fourth" + OccurrenceTypeLast OccurrenceType = "last" +) + +type AbsoluteOrRecurringTimeType struct { + DateTime *DateTimeType `json:"dateTime,omitempty"` + Month *MonthType `json:"month,omitempty"` + DayOfMonth *DayOfMonthType `json:"dayOfMonth,omitempty"` + CalendarWeek *CalendarWeekType `json:"calendarWeek,omitempty"` + DayOfWeekOccurrence *OccurrenceType `json:"dayOfWeekOccurrence,omitempty"` + DaysOfWeek *DaysOfWeekType `json:"daysOfWeek,omitempty"` + Time *TimeType `json:"time,omitempty"` + Relative *DurationType `json:"relative,omitempty"` +} + +type AbsoluteOrRecurringTimeElementsType struct { + DateTime *ElementTagType `json:"dateTime,omitempty"` + Month *ElementTagType `json:"month,omitempty"` + DayOfMonth *ElementTagType `json:"dayOfMonth,omitempty"` + CalendarWeek *ElementTagType `json:"calendarWeek,omitempty"` + DayOfWeekOccurrence *ElementTagType `json:"dayOfWeekOccurrence,omitempty"` + DaysOfWeek *ElementTagType `json:"daysOfWeek,omitempty"` + Time *ElementTagType `json:"time,omitempty"` + Relative *ElementTagType `json:"relative,omitempty"` +} + +type RecurrenceInformationType struct { + RecurringInterval *RecurringIntervalType `json:"recurringInterval,omitempty"` + RecurringIntervalStep *uint `json:"recurringIntervalStep,omitempty"` + FirstExecution *DateTimeType `json:"firstExecution,omitempty"` + ExecutionCount *uint `json:"executionCount,omitempty"` + LastExecution *DateTimeType `json:"lastExecution,omitempty"` +} + +type RecurrenceInformationElementsType struct { + RecurringInterval *ElementTagType `json:"recurringInterval,omitempty"` + RecurringIntervalStep *ElementTagType `json:"recurringIntervalStep,omitempty"` + FirstExecution *ElementTagType `json:"firstExecution,omitempty"` + ExecutionCount *ElementTagType `json:"executionCount,omitempty"` + LastExecution *ElementTagType `json:"lastExecution,omitempty"` +} + +type ScaledNumberRangeType struct { + Min *ScaledNumberType `json:"min,omitempty"` + Max *ScaledNumberType `json:"max,omitempty"` +} + +type ScaledNumberRangeElementsType struct { + Min *ElementTagType `json:"min,omitempty"` + Max *ElementTagType `json:"max,omitempty"` +} + +type ScaledNumberSetType struct { + Value []ScaledNumberType `json:"value,omitempty"` + Range []ScaledNumberRangeType `json:"range,omitempty"` +} + +type ScaledNumberSetElementsType struct { + Value *ElementTagType `json:"value,omitempty"` + Range *ElementTagType `json:"range,omitempty"` +} + +type NumberType int64 + +type ScaleType int8 + +type ScaledNumberType struct { + Number *NumberType `json:"number,omitempty"` + Scale *ScaleType `json:"scale,omitempty"` +} + +type ScaledNumberElementsType struct { + Number *ElementTagType `json:"number,omitempty"` + Scale *ElementTagType `json:"scale,omitempty"` +} + +type MaxResponseDelayType DurationType + +type CommodityTypeType string + +const ( + CommodityTypeTypeElectricity CommodityTypeType = "electricity" + CommodityTypeTypeGas CommodityTypeType = "gas" + CommodityTypeTypeOil CommodityTypeType = "oil" + CommodityTypeTypeWater CommodityTypeType = "water" + CommodityTypeTypeWastewater CommodityTypeType = "wasteWater" + CommodityTypeTypeDomestichotwater CommodityTypeType = "domesticHotWater" + CommodityTypeTypeHeatingwater CommodityTypeType = "heatingWater" + CommodityTypeTypeSteam CommodityTypeType = "steam" + CommodityTypeTypeHeat CommodityTypeType = "heat" + CommodityTypeTypeCoolingload CommodityTypeType = "coolingLoad" + CommodityTypeTypeAir CommodityTypeType = "air" +) + +type EnergyDirectionType string + +const ( + EnergyDirectionTypeConsume EnergyDirectionType = "consume" + EnergyDirectionTypeProduce EnergyDirectionType = "produce" +) + +type EnergyModeType string + +const ( + EnergyModeTypeConsume EnergyModeType = "consume" + EnergyModeTypeProduce EnergyModeType = "produce" + EnergyModeTypeIdle EnergyModeType = "idle" + EnergyModeTypeAuto EnergyModeType = "auto" +) + +type UnitOfMeasurementType string + +const ( + UnitOfMeasurementTypeUnknown UnitOfMeasurementType = "unknown" + UnitOfMeasurementType1 UnitOfMeasurementType = "1" + UnitOfMeasurementTypem UnitOfMeasurementType = "m" + UnitOfMeasurementTypekg UnitOfMeasurementType = "kg" + UnitOfMeasurementTypes UnitOfMeasurementType = "s" + UnitOfMeasurementTypeA UnitOfMeasurementType = "A" + UnitOfMeasurementTypeK UnitOfMeasurementType = "K" + UnitOfMeasurementTypemol UnitOfMeasurementType = "mol" + UnitOfMeasurementTypecd UnitOfMeasurementType = "cd" + UnitOfMeasurementTypeV UnitOfMeasurementType = "V" + UnitOfMeasurementTypeW UnitOfMeasurementType = "W" + UnitOfMeasurementTypeWh UnitOfMeasurementType = "Wh" + UnitOfMeasurementTypeVA UnitOfMeasurementType = "VA" + UnitOfMeasurementTypeVAh UnitOfMeasurementType = "VAh" + UnitOfMeasurementTypevar UnitOfMeasurementType = "var" + UnitOfMeasurementTypevarh UnitOfMeasurementType = "varh" + UnitOfMeasurementTypedegC UnitOfMeasurementType = "degC" + UnitOfMeasurementTypedegF UnitOfMeasurementType = "degF" + UnitOfMeasurementTypeLm UnitOfMeasurementType = "Lm" + UnitOfMeasurementTypelx UnitOfMeasurementType = "lx" + UnitOfMeasurementTypeOhm UnitOfMeasurementType = "Ohm" + UnitOfMeasurementTypeHz UnitOfMeasurementType = "Hz" + UnitOfMeasurementTypedB UnitOfMeasurementType = "dB" + UnitOfMeasurementTypedBm UnitOfMeasurementType = "dBm" + UnitOfMeasurementTypepct UnitOfMeasurementType = "pct" + UnitOfMeasurementTypeppm UnitOfMeasurementType = "ppm" + UnitOfMeasurementTypel UnitOfMeasurementType = "l" + UnitOfMeasurementTypels UnitOfMeasurementType = "l/s" + UnitOfMeasurementTypelh UnitOfMeasurementType = "l/h" + UnitOfMeasurementTypedeg UnitOfMeasurementType = "deg" + UnitOfMeasurementTyperad UnitOfMeasurementType = "rad" + UnitOfMeasurementTyperads UnitOfMeasurementType = "rad/s" + UnitOfMeasurementTypesr UnitOfMeasurementType = "sr" + UnitOfMeasurementTypeGy UnitOfMeasurementType = "Gy" + UnitOfMeasurementTypeBq UnitOfMeasurementType = "Bq" + UnitOfMeasurementTypeBqm3 UnitOfMeasurementType = "Bq/m^3" + UnitOfMeasurementTypeSv UnitOfMeasurementType = "Sv" + UnitOfMeasurementTypeRd UnitOfMeasurementType = "Rd" + UnitOfMeasurementTypeC UnitOfMeasurementType = "C" + UnitOfMeasurementTypeF UnitOfMeasurementType = "F" + UnitOfMeasurementTypeH UnitOfMeasurementType = "H" + UnitOfMeasurementTypeJ UnitOfMeasurementType = "J" + UnitOfMeasurementTypeN UnitOfMeasurementType = "N" + UnitOfMeasurementTypeNm UnitOfMeasurementType = "N_m" + UnitOfMeasurementTypeNs UnitOfMeasurementType = "N_s" + UnitOfMeasurementTypeWb UnitOfMeasurementType = "Wb" + UnitOfMeasurementTypeT UnitOfMeasurementType = "T" + UnitOfMeasurementTypePa UnitOfMeasurementType = "Pa" + UnitOfMeasurementTypebar UnitOfMeasurementType = "bar" + UnitOfMeasurementTypeatm UnitOfMeasurementType = "atm" + UnitOfMeasurementTypepsi UnitOfMeasurementType = "psi" + UnitOfMeasurementTypemmHg UnitOfMeasurementType = "mmHg" + UnitOfMeasurementTypem2 UnitOfMeasurementType = "m^2" + UnitOfMeasurementTypem3 UnitOfMeasurementType = "m^3" + UnitOfMeasurementTypem3h UnitOfMeasurementType = "m^3/h" + UnitOfMeasurementTypems UnitOfMeasurementType = "m/s" + UnitOfMeasurementTypems2 UnitOfMeasurementType = "m/s^2" + UnitOfMeasurementTypem3s UnitOfMeasurementType = "m^3/s" + UnitOfMeasurementTypemm3 UnitOfMeasurementType = "m/m^3" + UnitOfMeasurementTypekgm3 UnitOfMeasurementType = "kg/m^3" + UnitOfMeasurementTypekgm UnitOfMeasurementType = "kg_m" + UnitOfMeasurementTypem2s UnitOfMeasurementType = "m^2/s" + UnitOfMeasurementTypewmk UnitOfMeasurementType = "W/m_K" + UnitOfMeasurementTypeJK UnitOfMeasurementType = "J/K" + UnitOfMeasurementType1s UnitOfMeasurementType = "1/s" + UnitOfMeasurementTypeWm2 UnitOfMeasurementType = "W/m^2" + UnitOfMeasurementTypeJm2 UnitOfMeasurementType = "J/m^2" + UnitOfMeasurementTypeS UnitOfMeasurementType = "S" + UnitOfMeasurementTypeSm UnitOfMeasurementType = "S/m" + UnitOfMeasurementTypeKs UnitOfMeasurementType = "K/s" + UnitOfMeasurementTypePas UnitOfMeasurementType = "Pa/s" + UnitOfMeasurementTypeJkgK UnitOfMeasurementType = "J/kg_K" + UnitOfMeasurementTypeVs UnitOfMeasurementType = "Vs" + UnitOfMeasurementTypeVm UnitOfMeasurementType = "V/m" + UnitOfMeasurementTypeVHz UnitOfMeasurementType = "V/Hz" + UnitOfMeasurementTypeAs UnitOfMeasurementType = "As" + UnitOfMeasurementTypeAm UnitOfMeasurementType = "A/m" + UnitOfMeasurementTypeHzs UnitOfMeasurementType = "Hz/s" + UnitOfMeasurementTypekgs UnitOfMeasurementType = "kg/s" + UnitOfMeasurementTypekgm2 UnitOfMeasurementType = "kg_m^2" + UnitOfMeasurementTypeJWh UnitOfMeasurementType = "J/Wh" + UnitOfMeasurementTypeWs UnitOfMeasurementType = "W/s" + UnitOfMeasurementTypeft3 UnitOfMeasurementType = "ft^3" + UnitOfMeasurementTypeft3h UnitOfMeasurementType = "ft^3/h" + UnitOfMeasurementTypeccf UnitOfMeasurementType = "ccf" + UnitOfMeasurementTypeccfh UnitOfMeasurementType = "ccf/h" + UnitOfMeasurementTypeUSliqgal UnitOfMeasurementType = "US.liq.gal" + UnitOfMeasurementTypeUSliqgalh UnitOfMeasurementType = "US.liq.gal/h" + UnitOfMeasurementTypeImpgal UnitOfMeasurementType = "Imp.gal" + UnitOfMeasurementTypeImpgalh UnitOfMeasurementType = "Imp.gal/h" + UnitOfMeasurementTypeBtu UnitOfMeasurementType = "Btu" + UnitOfMeasurementTypeBtuh UnitOfMeasurementType = "Btu/h" + UnitOfMeasurementTypeAh UnitOfMeasurementType = "Ah" + UnitOfMeasurementTypekgWh UnitOfMeasurementType = "kg/Wh" +) + +type CurrencyType string + +const ( + CurrencyTypeAed CurrencyType = "AED" + CurrencyTypeAfn CurrencyType = "AFN" + CurrencyTypeAll CurrencyType = "ALL" + CurrencyTypeAmd CurrencyType = "AMD" + CurrencyTypeAng CurrencyType = "ANG" + CurrencyTypeAoa CurrencyType = "AOA" + CurrencyTypeArs CurrencyType = "ARS" + CurrencyTypeAud CurrencyType = "AUD" + CurrencyTypeAwg CurrencyType = "AWG" + CurrencyTypeAzn CurrencyType = "AZN" + CurrencyTypeBam CurrencyType = "BAM" + CurrencyTypeBbd CurrencyType = "BBD" + CurrencyTypeBdt CurrencyType = "BDT" + CurrencyTypeBgn CurrencyType = "BGN" + CurrencyTypeBhd CurrencyType = "BHD" + CurrencyTypeBif CurrencyType = "BIF" + CurrencyTypeBmd CurrencyType = "BMD" + CurrencyTypeBnd CurrencyType = "BND" + CurrencyTypeBob CurrencyType = "BOB" + CurrencyTypeBov CurrencyType = "BOV" + CurrencyTypeBrl CurrencyType = "BRL" + CurrencyTypeBsd CurrencyType = "BSD" + CurrencyTypeBtn CurrencyType = "BTN" + CurrencyTypeBwp CurrencyType = "BWP" + CurrencyTypeByr CurrencyType = "BYR" + CurrencyTypeBzd CurrencyType = "BZD" + CurrencyTypeCad CurrencyType = "CAD" + CurrencyTypeCdf CurrencyType = "CDF" + CurrencyTypeChe CurrencyType = "CHE" + CurrencyTypeChf CurrencyType = "CHF" + CurrencyTypeChw CurrencyType = "CHW" + CurrencyTypeClf CurrencyType = "CLF" + CurrencyTypeClp CurrencyType = "CLP" + CurrencyTypeCny CurrencyType = "CNY" + CurrencyTypeCop CurrencyType = "COP" + CurrencyTypeCou CurrencyType = "COU" + CurrencyTypeCrc CurrencyType = "CRC" + CurrencyTypeCuc CurrencyType = "CUC" + CurrencyTypeCup CurrencyType = "CUP" + CurrencyTypeCve CurrencyType = "CVE" + CurrencyTypeCzk CurrencyType = "CZK" + CurrencyTypeDjf CurrencyType = "DJF" + CurrencyTypeDkk CurrencyType = "DKK" + CurrencyTypeDop CurrencyType = "DOP" + CurrencyTypeDzd CurrencyType = "DZD" + CurrencyTypeEgp CurrencyType = "EGP" + CurrencyTypeErn CurrencyType = "ERN" + CurrencyTypeEtb CurrencyType = "ETB" + CurrencyTypeEur CurrencyType = "EUR" + CurrencyTypeFjd CurrencyType = "FJD" + CurrencyTypeFkp CurrencyType = "FKP" + CurrencyTypeGbp CurrencyType = "GBP" + CurrencyTypeGel CurrencyType = "GEL" + CurrencyTypeGhs CurrencyType = "GHS" + CurrencyTypeGip CurrencyType = "GIP" + CurrencyTypeGmd CurrencyType = "GMD" + CurrencyTypeGnf CurrencyType = "GNF" + CurrencyTypeGtq CurrencyType = "GTQ" + CurrencyTypeGyd CurrencyType = "GYD" + CurrencyTypeHkd CurrencyType = "HKD" + CurrencyTypeHnl CurrencyType = "HNL" + CurrencyTypeHrk CurrencyType = "HRK" + CurrencyTypeHtg CurrencyType = "HTG" + CurrencyTypeHuf CurrencyType = "HUF" + CurrencyTypeIdr CurrencyType = "IDR" + CurrencyTypeIls CurrencyType = "ILS" + CurrencyTypeInr CurrencyType = "INR" + CurrencyTypeIqd CurrencyType = "IQD" + CurrencyTypeIrr CurrencyType = "IRR" + CurrencyTypeIsk CurrencyType = "ISK" + CurrencyTypeJmd CurrencyType = "JMD" + CurrencyTypeJod CurrencyType = "JOD" + CurrencyTypeJpy CurrencyType = "JPY" + CurrencyTypeKes CurrencyType = "KES" + CurrencyTypeKgs CurrencyType = "KGS" + CurrencyTypeKhr CurrencyType = "KHR" + CurrencyTypeKmf CurrencyType = "KMF" + CurrencyTypeKpw CurrencyType = "KPW" + CurrencyTypeKrw CurrencyType = "KRW" + CurrencyTypeKwd CurrencyType = "KWD" + CurrencyTypeKyd CurrencyType = "KYD" + CurrencyTypeKzt CurrencyType = "KZT" + CurrencyTypeLak CurrencyType = "LAK" + CurrencyTypeLbp CurrencyType = "LBP" + CurrencyTypeLkr CurrencyType = "LKR" + CurrencyTypeLrd CurrencyType = "LRD" + CurrencyTypeLsl CurrencyType = "LSL" + CurrencyTypeLyd CurrencyType = "LYD" + CurrencyTypeMad CurrencyType = "MAD" + CurrencyTypeMdl CurrencyType = "MDL" + CurrencyTypeMga CurrencyType = "MGA" + CurrencyTypeMkd CurrencyType = "MKD" + CurrencyTypeMmk CurrencyType = "MMK" + CurrencyTypeMnt CurrencyType = "MNT" + CurrencyTypeMop CurrencyType = "MOP" + CurrencyTypeMro CurrencyType = "MRO" + CurrencyTypeMur CurrencyType = "MUR" + CurrencyTypeMvr CurrencyType = "MVR" + CurrencyTypeMwk CurrencyType = "MWK" + CurrencyTypeMxn CurrencyType = "MXN" + CurrencyTypeMxv CurrencyType = "MXV" + CurrencyTypeMyr CurrencyType = "MYR" + CurrencyTypeMzn CurrencyType = "MZN" + CurrencyTypeNad CurrencyType = "NAD" + CurrencyTypeNgn CurrencyType = "NGN" + CurrencyTypeNio CurrencyType = "NIO" + CurrencyTypeNok CurrencyType = "NOK" + CurrencyTypeNpr CurrencyType = "NPR" + CurrencyTypeNzd CurrencyType = "NZD" + CurrencyTypeOmr CurrencyType = "OMR" + CurrencyTypePab CurrencyType = "PAB" + CurrencyTypePen CurrencyType = "PEN" + CurrencyTypePgk CurrencyType = "PGK" + CurrencyTypePhp CurrencyType = "PHP" + CurrencyTypePkr CurrencyType = "PKR" + CurrencyTypePln CurrencyType = "PLN" + CurrencyTypePyg CurrencyType = "PYG" + CurrencyTypeQar CurrencyType = "QAR" + CurrencyTypeRon CurrencyType = "RON" + CurrencyTypeRsd CurrencyType = "RSD" + CurrencyTypeRub CurrencyType = "RUB" + CurrencyTypeRwf CurrencyType = "RWF" + CurrencyTypeSar CurrencyType = "SAR" + CurrencyTypeSbd CurrencyType = "SBD" + CurrencyTypeScr CurrencyType = "SCR" + CurrencyTypeSdg CurrencyType = "SDG" + CurrencyTypeSek CurrencyType = "SEK" + CurrencyTypeSgd CurrencyType = "SGD" + CurrencyTypeShp CurrencyType = "SHP" + CurrencyTypeSll CurrencyType = "SLL" + CurrencyTypeSos CurrencyType = "SOS" + CurrencyTypeSrd CurrencyType = "SRD" + CurrencyTypeSsp CurrencyType = "SSP" + CurrencyTypeStd CurrencyType = "STD" + CurrencyTypeSvc CurrencyType = "SVC" + CurrencyTypeSyp CurrencyType = "SYP" + CurrencyTypeSzl CurrencyType = "SZL" + CurrencyTypeThb CurrencyType = "THB" + CurrencyTypeTjs CurrencyType = "TJS" + CurrencyTypeTmt CurrencyType = "TMT" + CurrencyTypeTnd CurrencyType = "TND" + CurrencyTypeTop CurrencyType = "TOP" + CurrencyTypeTry CurrencyType = "TRY" + CurrencyTypeTtd CurrencyType = "TTD" + CurrencyTypeTwd CurrencyType = "TWD" + CurrencyTypeTzs CurrencyType = "TZS" + CurrencyTypeUah CurrencyType = "UAH" + CurrencyTypeUgx CurrencyType = "UGX" + CurrencyTypeUsd CurrencyType = "USD" + CurrencyTypeUsn CurrencyType = "USN" + CurrencyTypeUyi CurrencyType = "UYI" + CurrencyTypeUyu CurrencyType = "UYU" + CurrencyTypeUzs CurrencyType = "UZS" + CurrencyTypeVef CurrencyType = "VEF" + CurrencyTypeVnd CurrencyType = "VND" + CurrencyTypeVuv CurrencyType = "VUV" + CurrencyTypeWst CurrencyType = "WST" + CurrencyTypeXaf CurrencyType = "XAF" + CurrencyTypeXag CurrencyType = "XAG" + CurrencyTypeXau CurrencyType = "XAU" + CurrencyTypeXba CurrencyType = "XBA" + CurrencyTypeXbb CurrencyType = "XBB" + CurrencyTypeXbc CurrencyType = "XBC" + CurrencyTypeXbd CurrencyType = "XBD" + CurrencyTypeXcd CurrencyType = "XCD" + CurrencyTypeXdr CurrencyType = "XDR" + CurrencyTypeXof CurrencyType = "XOF" + CurrencyTypeXpd CurrencyType = "XPD" + CurrencyTypeXpf CurrencyType = "XPF" + CurrencyTypeXpt CurrencyType = "XPT" + CurrencyTypeXsu CurrencyType = "XSU" + CurrencyTypeXts CurrencyType = "XTS" + CurrencyTypeXua CurrencyType = "XUA" + CurrencyTypeXxx CurrencyType = "XXX" + CurrencyTypeYer CurrencyType = "YER" + CurrencyTypeZar CurrencyType = "ZAR" + CurrencyTypeZmw CurrencyType = "ZMW" + CurrencyTypeZwl CurrencyType = "ZWL" +) + +type AddressDeviceType string + +type AddressEntityType uint + +type AddressFeatureType uint + +type DeviceAddressType struct { + Device *AddressDeviceType `json:"device,omitempty"` +} + +type DeviceAddressElementsType struct { + Device *ElementTagType `json:"device,omitempty"` +} + +type EntityAddressType struct { + Device *AddressDeviceType `json:"device,omitempty"` + Entity []AddressEntityType `json:"entity,omitempty"` +} + +type EntityAddressElementsType struct { + Device *ElementTagType `json:"device,omitempty"` + Entity *ElementTagType `json:"entity,omitempty"` +} + +type FeatureAddressType struct { + Device *AddressDeviceType `json:"device,omitempty"` + Entity []AddressEntityType `json:"entity,omitempty"` + Feature *AddressFeatureType `json:"feature,omitempty"` +} + +type FeatureAddressElementsType struct { + Device *ElementTagType `json:"device,omitempty"` + Entity *ElementTagType `json:"entity,omitempty"` + Feature *ElementTagType `json:"feature,omitempty"` +} + +type ScopeTypeType string + +const ( + ScopeTypeTypeAC ScopeTypeType = "ac" + ScopeTypeTypeACCosPhiGrid ScopeTypeType = "acCosPhiGrid" + ScopeTypeTypeACCurrentA ScopeTypeType = "acCurrentA" + ScopeTypeTypeACCurrentB ScopeTypeType = "acCurrentB" + ScopeTypeTypeACCurrentC ScopeTypeType = "acCurrentC" + ScopeTypeTypeACFrequency ScopeTypeType = "acFrequency" + ScopeTypeTypeACFrequencyGrid ScopeTypeType = "acFrequencyGrid" + ScopeTypeTypeACPowerA ScopeTypeType = "acPowerA" + ScopeTypeTypeACPowerB ScopeTypeType = "acPowerB" + ScopeTypeTypeACPowerC ScopeTypeType = "acPowerC" + ScopeTypeTypeACPowerLimitPct ScopeTypeType = "acPowerLimitPct" + ScopeTypeTypeACPowerTotal ScopeTypeType = "acPowerTotal" + ScopeTypeTypeACVoltageA ScopeTypeType = "acVoltageA" + ScopeTypeTypeACVoltageB ScopeTypeType = "acVoltageB" + ScopeTypeTypeACVoltageC ScopeTypeType = "acVoltageC" + ScopeTypeTypeACYieldDay ScopeTypeType = "acYieldDay" + ScopeTypeTypeACYieldTotal ScopeTypeType = "acYieldTotal" + ScopeTypeTypeDCCurrent ScopeTypeType = "dcCurrent" + ScopeTypeTypeDCPower ScopeTypeType = "dcPower" + ScopeTypeTypeDCString1 ScopeTypeType = "dcString1" + ScopeTypeTypeDCString2 ScopeTypeType = "dcString2" + ScopeTypeTypeDCString3 ScopeTypeType = "dcString3" + ScopeTypeTypeDCString4 ScopeTypeType = "dcString4" + ScopeTypeTypeDCString5 ScopeTypeType = "dcString5" + ScopeTypeTypeDCString6 ScopeTypeType = "dcString6" + ScopeTypeTypeDCTotal ScopeTypeType = "dcTotal" + ScopeTypeTypeDCVoltage ScopeTypeType = "dcVoltage" + ScopeTypeTypeDhwTemperature ScopeTypeType = "dhwTemperature" + ScopeTypeTypeFlowTemperature ScopeTypeType = "flowTemperature" + ScopeTypeTypeOutsideAirTemperature ScopeTypeType = "outsideAirTemperature" + ScopeTypeTypeReturnTemperature ScopeTypeType = "returnTemperature" + ScopeTypeTypeRoomAirTemperature ScopeTypeType = "roomAirTemperature" + ScopeTypeTypeCharge ScopeTypeType = "charge" + ScopeTypeTypeStateOfCharge ScopeTypeType = "stateOfCharge" + ScopeTypeTypeDischarge ScopeTypeType = "discharge" + ScopeTypeTypeGridConsumption ScopeTypeType = "gridConsumption" + ScopeTypeTypeGridFeedIn ScopeTypeType = "gridFeedIn" + ScopeTypeTypeSelfConsumption ScopeTypeType = "selfConsumption" + ScopeTypeTypeOverloadProtection ScopeTypeType = "overloadProtection" + ScopeTypeTypeACPower ScopeTypeType = "acPower" + ScopeTypeTypeACEnergy ScopeTypeType = "acEnergy" + ScopeTypeTypeACCurrent ScopeTypeType = "acCurrent" + ScopeTypeTypeACVoltage ScopeTypeType = "acVoltage" + ScopeTypeTypeBatteryControl ScopeTypeType = "batteryControl" + ScopeTypeTypeSimpleIncentiveTable ScopeTypeType = "simpleIncentiveTable" + ScopeTypeTypeStateOfHealth ScopeTypeType = "stateOfHealth" + ScopeTypeTypeTravelRange ScopeTypeType = "travelRange" + ScopeTypeTypeNominalEnergyCapacity ScopeTypeType = "nominalEnergyCapacity" + ScopeTypeTypeACPowerReal ScopeTypeType = "acPowerReal" + ScopeTypeTypeACPowerApparent ScopeTypeType = "acPowerApparent" + ScopeTypeTypeACPowerReactive ScopeTypeType = "acPowerReactive" + ScopeTypeTypeACYieldMonth ScopeTypeType = "acYieldMonth" + ScopeTypeTypeACYieldYear ScopeTypeType = "acYieldYear" + ScopeTypeTypeACCosPhi ScopeTypeType = "acCosPhi" + ScopeTypeTypeDCEnergy ScopeTypeType = "dcEnergy" + ScopeTypeTypeInsulationResistance ScopeTypeType = "insulationResistance" + ScopeTypeTypeStateOfEnergy ScopeTypeType = "stateOfEnergy" + ScopeTypeTypeUseableCapacity ScopeTypeType = "useableCapacity" + ScopeTypeTypeDCChargeEnergy ScopeTypeType = "dcChargeEnergy" + ScopeTypeTypeDCDischargeEnergy ScopeTypeType = "dcDischargeEnergy" + ScopeTypeTypeLoadCycleCount ScopeTypeType = "loadCycleCount" + ScopeTypeTypeComponentTemperature ScopeTypeType = "componentTemperature" + ScopeTypeTypeGridLimit ScopeTypeType = "gridLimit" + ScopeTypeTypeGridLimitFallback ScopeTypeType = "gridLimitFallback" + ScopeTypeTypeACPowerApparentTotal ScopeTypeType = "acPowerApparentTotal" + ScopeTypeTypeACPowerReactiveTotal ScopeTypeType = "acPowerReactiveTotal" + ScopeTypeTypeACCurrentTotal ScopeTypeType = "acCurrentTotal" + ScopeTypeTypeACEnergyConsumed ScopeTypeType = "acEnergyConsumed" + ScopeTypeTypeACEnergyProduced ScopeTypeType = "acEnergyProduced" + ScopeTypeTypeBatteryAcPower ScopeTypeType = "batteryAcPower" + ScopeTypeTypeBatteryAcPowerPhaseSpecific ScopeTypeType = "batteryAcPowerPhaseSpecific" + ScopeTypeTypeBatteryDcPower ScopeTypeType = "batteryDcPower" + ScopeTypeTypePccPower ScopeTypeType = "pccPower" + ScopeTypeTypeActivePowerLimit ScopeTypeType = "activePowerLimit" + ScopeTypeTypeActivePowerLimitPercentage ScopeTypeType = "activePowerLimitPercentage" + ScopeTypeTypeSimpleCommittedIncentiveTable ScopeTypeType = "simpleCommittedIncentiveTable" + ScopeTypeTypeSimplePreliminaryIncentiveTable ScopeTypeType = "simplePreliminaryIncentiveTable" + ScopeTypeTypeCommittedPowerPlan ScopeTypeType = "committedPowerPlan" + ScopeTypeTypePreliminaryPowerPlan ScopeTypeType = "preliminaryPowerPlan" + ScopeTypeTypeIncentiveTableEnConsWithPoETF ScopeTypeType = "incentiveTableEnConsWithPoETF" + ScopeTypeTypeIncentiveTableEnProdWithPoETF ScopeTypeType = "incentiveTableEnProdWithPoETF" + ScopeTypeTypeIncentiveTableEnConsWithPoE ScopeTypeType = "incentiveTableEnConsWithPoE" + ScopeTypeTypeIncentiveTableEnProdWithPoE ScopeTypeType = "incentiveTableEnProdWithPoE" + ScopeTypeTypeIncentiveTableEnConsWithTF ScopeTypeType = "incentiveTableEnConsWithTF" + ScopeTypeTypeIncentiveTableEnProdWithTF ScopeTypeType = "incentiveTableEnProdWithTF" + ScopeTypeTypeActivePowerForecast ScopeTypeType = "activePowerForecast" +) + +type RoleType string + +const ( + RoleTypeClient RoleType = "client" + RoleTypeServer RoleType = "server" + RoleTypeSpecial RoleType = "special" +) + +type FeatureGroupType string + +type DeviceTypeType string + +const ( + DeviceTypeTypeDishwasher DeviceTypeType = "Dishwasher" + DeviceTypeTypeDryer DeviceTypeType = "Dryer" + DeviceTypeTypeEnvironmentSensor DeviceTypeType = "EnvironmentSensor" + DeviceTypeTypeGeneric DeviceTypeType = "Generic" + DeviceTypeTypeHeatgenerationSystem DeviceTypeType = "HeatGenerationSystem" + DeviceTypeTypeHeatsinkSystem DeviceTypeType = "HeatSinkSystem" + DeviceTypeTypeHeatstorageSystem DeviceTypeType = "HeatStorageSystem" + DeviceTypeTypeHVACController DeviceTypeType = "HVACController" + DeviceTypeTypeSubmeter DeviceTypeType = "SubMeter" + DeviceTypeTypeWasher DeviceTypeType = "Washer" + DeviceTypeTypeElectricitySupplySystem DeviceTypeType = "ElectricitySupplySystem" + DeviceTypeTypeEnergyManagementSystem DeviceTypeType = "EnergyManagementSystem" + DeviceTypeTypeInverter DeviceTypeType = "Inverter" + DeviceTypeTypeChargingStation DeviceTypeType = "ChargingStation" +) + +type EntityTypeType string + +const ( + EntityTypeTypeBattery EntityTypeType = "Battery" + EntityTypeTypeCompressor EntityTypeType = "Compressor" + EntityTypeTypeDeviceInformation EntityTypeType = "DeviceInformation" + EntityTypeTypeDHWCircuit EntityTypeType = "DHWCircuit" + EntityTypeTypeDHWStorage EntityTypeType = "DHWStorage" + EntityTypeTypeDishwasher EntityTypeType = "Dishwasher" + EntityTypeTypeDryer EntityTypeType = "Dryer" + EntityTypeTypeElectricalImmersionHeater EntityTypeType = "ElectricalImmersionHeater" + EntityTypeTypeFan EntityTypeType = "Fan" + EntityTypeTypeGasHeatingAppliance EntityTypeType = "GasHeatingAppliance" + EntityTypeTypeGeneric EntityTypeType = "Generic" + EntityTypeTypeHeatingBufferStorage EntityTypeType = "HeatingBufferStorage" + EntityTypeTypeHeatingCircuit EntityTypeType = "HeatingCircuit" + EntityTypeTypeHeatingObject EntityTypeType = "HeatingObject" + EntityTypeTypeHeatingZone EntityTypeType = "HeatingZone" + EntityTypeTypeHeatPumpAppliance EntityTypeType = "HeatPumpAppliance" + EntityTypeTypeHeatSinkCircuit EntityTypeType = "HeatSinkCircuit" + EntityTypeTypeHeatSourceCircuit EntityTypeType = "HeatSourceCircuit" + EntityTypeTypeHeatSourceUnit EntityTypeType = "HeatSourceUnit" + EntityTypeTypeHvacController EntityTypeType = "HVACController" + EntityTypeTypeHvacRoom EntityTypeType = "HVACRoom" + EntityTypeTypeInstantDHWheater EntityTypeType = "InstantDHWHeater" + EntityTypeTypeInverter EntityTypeType = "Inverter" + EntityTypeTypeOilHeatingAppliance EntityTypeType = "OilHeatingAppliance" + EntityTypeTypePump EntityTypeType = "Pump" + EntityTypeTypeRefrigerantCircuit EntityTypeType = "RefrigerantCircuit" + EntityTypeTypeSmartEnergyAppliance EntityTypeType = "SmartEnergyAppliance" + EntityTypeTypeSolarDHWStorage EntityTypeType = "SolarDHWStorage" + EntityTypeTypeSolarThermalCircuit EntityTypeType = "SolarThermalCircuit" + EntityTypeTypeSubMeterElectricity EntityTypeType = "SubMeterElectricity" + EntityTypeTypeTemperatureSensor EntityTypeType = "TemperatureSensor" + EntityTypeTypeWasher EntityTypeType = "Washer" + EntityTypeTypeBatterySystem EntityTypeType = "BatterySystem" + EntityTypeTypeElectricityGenerationSystem EntityTypeType = "ElectricityGenerationSystem" + EntityTypeTypeElectricityStorageSystem EntityTypeType = "ElectricityStorageSystem" + EntityTypeTypeGridConnectionPointOfPremises EntityTypeType = "GridConnectionPointOfPremises" + EntityTypeTypeHousehold EntityTypeType = "Household" + EntityTypeTypePVSystem EntityTypeType = "PVSystem" + EntityTypeTypeEV EntityTypeType = "EV" + EntityTypeTypeEVSE EntityTypeType = "EVSE" + EntityTypeTypeChargingOutlet EntityTypeType = "ChargingOutlet" + EntityTypeTypeCEM EntityTypeType = "CEM" + EntityTypeTypePV EntityTypeType = "PV" + EntityTypeTypePVESHybrid EntityTypeType = "PVESHybrid" + EntityTypeTypeElectricalStorage EntityTypeType = "ElectricalStorage" + EntityTypeTypePVString EntityTypeType = "PVString" + EntityTypeTypeGridGuard EntityTypeType = "GridGuard" + EntityTypeTypeControllableSystem EntityTypeType = "ControllableSystem" +) + +type FeatureTypeType string + +const ( + FeatureTypeTypeActuatorLevel FeatureTypeType = "ActuatorLevel" + FeatureTypeTypeActuatorSwitch FeatureTypeType = "ActuatorSwitch" + FeatureTypeTypeAlarm FeatureTypeType = "Alarm" + FeatureTypeTypeDataTunneling FeatureTypeType = "DataTunneling" + FeatureTypeTypeDeviceClassification FeatureTypeType = "DeviceClassification" + FeatureTypeTypeDeviceDiagnosis FeatureTypeType = "DeviceDiagnosis" + FeatureTypeTypeDirectControl FeatureTypeType = "DirectControl" + FeatureTypeTypeElectricalConnection FeatureTypeType = "ElectricalConnection" + FeatureTypeTypeGeneric FeatureTypeType = "Generic" + FeatureTypeTypeHvac FeatureTypeType = "HVAC" + FeatureTypeTypeLoadControl FeatureTypeType = "LoadControl" + FeatureTypeTypeMeasurement FeatureTypeType = "Measurement" + FeatureTypeTypeMessaging FeatureTypeType = "Messaging" + FeatureTypeTypeNetworkManagement FeatureTypeType = "NetworkManagement" + FeatureTypeTypeNodeManagement FeatureTypeType = "NodeManagement" + FeatureTypeTypeOperatingConstraints FeatureTypeType = "OperatingConstraints" + FeatureTypeTypePowerSequences FeatureTypeType = "PowerSequences" + FeatureTypeTypeSensing FeatureTypeType = "Sensing" + FeatureTypeTypeSetpoint FeatureTypeType = "Setpoint" + FeatureTypeTypeSmartEnergyManagementPs FeatureTypeType = "SmartEnergyManagementPs" + FeatureTypeTypeTaskManagement FeatureTypeType = "TaskManagement" + FeatureTypeTypeThreshold FeatureTypeType = "Threshold" + FeatureTypeTypeTimeInformation FeatureTypeType = "TimeInformation" + FeatureTypeTypeTimeTable FeatureTypeType = "TimeTable" + FeatureTypeTypeDeviceConfiguration FeatureTypeType = "DeviceConfiguration" + FeatureTypeTypeSupplyCondition FeatureTypeType = "SupplyCondition" + FeatureTypeTypeTimeSeries FeatureTypeType = "TimeSeries" + FeatureTypeTypeTariffInformation FeatureTypeType = "TariffInformation" + FeatureTypeTypeIncentiveTable FeatureTypeType = "IncentiveTable" + FeatureTypeTypeBill FeatureTypeType = "Bill" + FeatureTypeTypeIdentification FeatureTypeType = "Identification" + FeatureTypeTypeStateInformation FeatureTypeType = "StateInformation" +) + +type FeatureSpecificUsageType string + +const ( + // FeatureDirectControlSpecificUsageEnumType + FeatureSpecificUsageTypeHistory FeatureSpecificUsageType = "History" + FeatureSpecificUsageTypeRealtime FeatureSpecificUsageType = "RealTime" + + // FeatureHvacSpecificUsageEnumType + FeatureSpecificUsageTypeOperationmode FeatureSpecificUsageType = "OperationMode" + FeatureSpecificUsageTypeOverrun FeatureSpecificUsageType = "Overrun" + + // FeatureMeasurementSpecificUsageEnumType + FeatureSpecificUsageTypeContact FeatureSpecificUsageType = "Contact" + FeatureSpecificUsageTypeElectrical FeatureSpecificUsageType = "Electrical" + FeatureSpecificUsageTypeHeat FeatureSpecificUsageType = "Heat" + FeatureSpecificUsageTypeLevel FeatureSpecificUsageType = "Level" + FeatureSpecificUsageTypePressure FeatureSpecificUsageType = "Pressure" + FeatureSpecificUsageTypeTemperature FeatureSpecificUsageType = "Temperature" + + // FeatureSetpointSpecificUsageEnumType + + // FeatureSmartEnergyManagementPsSpecificUsageEnumType + FeatureSpecificUsageTypeFixedForecast FeatureSpecificUsageType = "FixedForecast" + FeatureSpecificUsageTypeFlexibleChosenForecast FeatureSpecificUsageType = "FlexibleChosenForecast" + FeatureSpecificUsageTypeFlexibleOptionalForecast FeatureSpecificUsageType = "FlexibleOptionalForecast" + FeatureSpecificUsageTypeOptionalSequenceBasedImmediateControl FeatureSpecificUsageType = "OptionalSequenceBasedImmediateControl" +) + +type FeatureDirectControlSpecificUsageEnumType string + +const ( + FeatureDirectControlSpecificUsageEnumTypeHistory FeatureDirectControlSpecificUsageEnumType = "History" + FeatureDirectControlSpecificUsageEnumTypeRealtime FeatureDirectControlSpecificUsageEnumType = "RealTime" +) + +type FeatureHvacSpecificUsageEnumType string + +const ( + FeatureHvacSpecificUsageEnumTypeOperationmode FeatureHvacSpecificUsageEnumType = "OperationMode" + FeatureHvacSpecificUsageEnumTypeOverrun FeatureHvacSpecificUsageEnumType = "Overrun" +) + +type FeatureMeasurementSpecificUsageEnumType string + +const ( + FeatureMeasurementSpecificUsageEnumTypeContact FeatureMeasurementSpecificUsageEnumType = "Contact" + FeatureMeasurementSpecificUsageEnumTypeElectrical FeatureMeasurementSpecificUsageEnumType = "Electrical" + FeatureMeasurementSpecificUsageEnumTypeHeat FeatureMeasurementSpecificUsageEnumType = "Heat" + FeatureMeasurementSpecificUsageEnumTypeLevel FeatureMeasurementSpecificUsageEnumType = "Level" + FeatureMeasurementSpecificUsageEnumTypePressure FeatureMeasurementSpecificUsageEnumType = "Pressure" + FeatureMeasurementSpecificUsageEnumTypeTemperature FeatureMeasurementSpecificUsageEnumType = "Temperature" +) + +type FeatureSetpointSpecificUsageEnumType string + +const ( + // FeatureMeasurementSpecificUsageEnumType + FeatureSetpointSpecificUsageEnumTypeContact FeatureSetpointSpecificUsageEnumType = "Contact" + FeatureSetpointSpecificUsageEnumTypeElectrical FeatureSetpointSpecificUsageEnumType = "Electrical" + FeatureSetpointSpecificUsageEnumTypeHeat FeatureSetpointSpecificUsageEnumType = "Heat" + FeatureSetpointSpecificUsageEnumTypeLevel FeatureSetpointSpecificUsageEnumType = "Level" + FeatureSetpointSpecificUsageEnumTypePressure FeatureSetpointSpecificUsageEnumType = "Pressure" + FeatureSetpointSpecificUsageEnumTypeTemperature FeatureSetpointSpecificUsageEnumType = "Temperature" +) + +type FeatureSmartEnergyManagementPsSpecificUsageEnumType string + +const ( + FeatureSmartEnergyManagementPsSpecificUsageEnumTypeFixedForecast FeatureSmartEnergyManagementPsSpecificUsageEnumType = "FixedForecast" + FeatureSmartEnergyManagementPsSpecificUsageEnumTypeFlexibleChosenForecast FeatureSmartEnergyManagementPsSpecificUsageEnumType = "FlexibleChosenForecast" + FeatureSmartEnergyManagementPsSpecificUsageEnumTypeFlexibleOptionalForecast FeatureSmartEnergyManagementPsSpecificUsageEnumType = "FlexibleOptionalForecast" + FeatureSmartEnergyManagementPsSpecificUsageEnumTypeOptionalSequenceBasedImmediateControl FeatureSmartEnergyManagementPsSpecificUsageEnumType = "OptionalSequenceBasedImmediateControl" +) + +type FunctionType string + +const ( + FunctionTypeActuatorLevelData FunctionType = "actuatorLevelData" + FunctionTypeActuatorLevelDescriptionData FunctionType = "actuatorLevelDescriptionData" + FunctionTypeActuatorSwitchData FunctionType = "actuatorSwitchData" + FunctionTypeActuatorSwitchDescriptionData FunctionType = "actuatorSwitchDescriptionData" + FunctionTypeAlarmListData FunctionType = "alarmListData" + FunctionTypeBindingManagementDeleteCall FunctionType = "bindingManagementDeleteCall" + FunctionTypeBindingManagementEntryListData FunctionType = "bindingManagementEntryListData" + FunctionTypeBindingManagementRequestCall FunctionType = "bindingManagementRequestCall" + FunctionTypeDataTunnelingCall FunctionType = "dataTunnelingCall" + FunctionTypeDeviceClassificationManufacturerData FunctionType = "deviceClassificationManufacturerData" + FunctionTypeDeviceClassificationUserData FunctionType = "deviceClassificationUserData" + FunctionTypeDeviceDiagnosisHeartbeatData FunctionType = "deviceDiagnosisHeartbeatData" + FunctionTypeDeviceDiagnosisServiceData FunctionType = "deviceDiagnosisServiceData" + FunctionTypeDeviceDiagnosisStateData FunctionType = "deviceDiagnosisStateData" + FunctionTypeDirectControlActivityListData FunctionType = "directControlActivityListData" + FunctionTypeDirectControlDescriptionData FunctionType = "directControlDescriptionData" + FunctionTypeElectricalConnectionDescriptionListData FunctionType = "electricalConnectionDescriptionListData" + FunctionTypeElectricalConnectionParameterDescriptionListData FunctionType = "electricalConnectionParameterDescriptionListData" + FunctionTypeElectricalConnectionStateListData FunctionType = "electricalConnectionStateListData" + FunctionTypeHvacOperationModeDescriptionListData FunctionType = "hvacOperationModeDescriptionListData" + FunctionTypeHvacOverrunDescriptionListData FunctionType = "hvacOverrunDescriptionListData" + FunctionTypeHvacOverrunListData FunctionType = "hvacOverrunListData" + FunctionTypeHvacSystemFunctionDescriptionListData FunctionType = "hvacSystemFunctionDescriptionListData" + FunctionTypeHvacSystemFunctionListData FunctionType = "hvacSystemFunctionListData" + FunctionTypeHvacSystemFunctionOperationModeRelationListData FunctionType = "hvacSystemFunctionOperationModeRelationListData" + FunctionTypeHvacSystemFunctionPowerSequenceRelationListData FunctionType = "hvacSystemFunctionPowerSequenceRelationListData" + FunctionTypeHvacSystemFunctionSetPointRelationListData FunctionType = "hvacSystemFunctionSetpointRelationListData" + FunctionTypeLoadControlEventListData FunctionType = "loadControlEventListData" + FunctionTypeLoadControlStateListData FunctionType = "loadControlStateListData" + FunctionTypeMeasurementConstraintsListData FunctionType = "measurementConstraintsListData" + FunctionTypeMeasurementDescriptionListData FunctionType = "measurementDescriptionListData" + FunctionTypeMeasurementListData FunctionType = "measurementListData" + FunctionTypeMeasurementThresholdRelationListData FunctionType = "measurementThresholdRelationListData" + FunctionTypeMessagingListData FunctionType = "messagingListData" + FunctionTypeNetworkManagementAbortCall FunctionType = "networkManagementAbortCall" + FunctionTypeNetworkManagementAddNodeCall FunctionType = "networkManagementAddNodeCall" + FunctionTypeNetworkManagementDeviceDescriptionListData FunctionType = "networkManagementDeviceDescriptionListData" + FunctionTypeNetworkManagementDiscoverCall FunctionType = "networkManagementDiscoverCall" + FunctionTypeNetworkManagementEntityDescriptionListData FunctionType = "networkManagementEntityDescriptionListData" + FunctionTypeNetworkManagementFeatureDescriptionListData FunctionType = "networkManagementFeatureDescriptionListData" + FunctionTypeNetworkManagementJoiningModeData FunctionType = "networkManagementJoiningModeData" + FunctionTypeNetworkManagementModifyNodeCall FunctionType = "networkManagementModifyNodeCall" + FunctionTypeNetworkManagementProcessStateData FunctionType = "networkManagementProcessStateData" + FunctionTypeNetworkManagementRemoveNodeCall FunctionType = "networkManagementRemoveNodeCall" + FunctionTypeNetworkManagementReportCandidateData FunctionType = "networkManagementReportCandidateData" + FunctionTypeNetworkManagementScanNetworkCall FunctionType = "networkManagementScanNetworkCall" + FunctionTypeNodeManagementBindingData FunctionType = "nodeManagementBindingData" + FunctionTypeNodeManagementBindingDeleteCall FunctionType = "nodeManagementBindingDeleteCall" + FunctionTypeNodeManagementBindingRequestCall FunctionType = "nodeManagementBindingRequestCall" + FunctionTypeNodeManagementDestinationListData FunctionType = "nodeManagementDestinationListData" + FunctionTypeNodeManagementDetailedDiscoveryData FunctionType = "nodeManagementDetailedDiscoveryData" + FunctionTypeNodeManagementSubscriptionData FunctionType = "nodeManagementSubscriptionData" + FunctionTypeNodeManagementSubscriptionDeleteCall FunctionType = "nodeManagementSubscriptionDeleteCall" + FunctionTypeNodeManagementSubscriptionRequestCall FunctionType = "nodeManagementSubscriptionRequestCall" + FunctionTypeOperatingConstraintsDurationListData FunctionType = "operatingConstraintsDurationListData" + FunctionTypeOperatingConstraintsInterruptListData FunctionType = "operatingConstraintsInterruptListData" + FunctionTypeOperatingConstraintsPowerDescriptionListData FunctionType = "operatingConstraintsPowerDescriptionListData" + FunctionTypeOperatingConstraintsPowerLevelListData FunctionType = "operatingConstraintsPowerLevelListData" + FunctionTypeOperatingConstraintsPowerRangeListData FunctionType = "operatingConstraintsPowerRangeListData" + FunctionTypeOperatingConstraintsResumeImplicationListData FunctionType = "operatingConstraintsResumeImplicationListData" + FunctionTypePowerSequenceAlternativesRelationListData FunctionType = "powerSequenceAlternativesRelationListData" + FunctionTypePowerSequenceDescriptionListData FunctionType = "powerSequenceDescriptionListData" + FunctionTypePowerSequenceNodeScheduleInformationData FunctionType = "powerSequenceNodeScheduleInformationData" + FunctionTypePowerSequencePriceCalculationRequestCall FunctionType = "powerSequencePriceCalculationRequestCall" + FunctionTypePowerSequencePriceListData FunctionType = "powerSequencePriceListData" + FunctionTypePowerSequenceScheduleConfigurationRequestCall FunctionType = "powerSequenceScheduleConfigurationRequestCall" + FunctionTypePowerSequenceScheduleConstraintsListData FunctionType = "powerSequenceScheduleConstraintsListData" + FunctionTypePowerSequenceScheduleListData FunctionType = "powerSequenceScheduleListData" + FunctionTypePowerSequenceSchedulePreferenceListData FunctionType = "powerSequenceSchedulePreferenceListData" + FunctionTypePowerSequenceStateListData FunctionType = "powerSequenceStateListData" + FunctionTypePowerTimeSlotScheduleConstraintsListData FunctionType = "powerTimeSlotScheduleConstraintsListData" + FunctionTypePowerTimeSlotScheduleListData FunctionType = "powerTimeSlotScheduleListData" + FunctionTypePowerTimeSlotValueListData FunctionType = "powerTimeSlotValueListData" + FunctionTypeResultData FunctionType = "resultData" + FunctionTypeSensingDescriptionData FunctionType = "sensingDescriptionData" + FunctionTypeSensingListData FunctionType = "sensingListData" + FunctionTypeSessionIdentificationListData FunctionType = "sessionIdentificationListData" + FunctionTypeSessionMeasurementRelationListData FunctionType = "sessionMeasurementRelationListData" + FunctionTypeSetpointConstraintsListData FunctionType = "setpointConstraintsListData" + FunctionTypeSetpointDescriptionListData FunctionType = "setpointDescriptionListData" + FunctionTypeSetpointListData FunctionType = "setpointListData" + FunctionTypeSmartEnergyManagementPsConfigurationRequestCall FunctionType = "smartEnergyManagementPsConfigurationRequestCall" + FunctionTypeSmartEnergyManagementPsData FunctionType = "smartEnergyManagementPsData" + FunctionTypeSmartEnergyManagementPsPriceCalculationRequestCall FunctionType = "smartEnergyManagementPsPriceCalculationRequestCall" + FunctionTypeSmartEnergyManagementPsPriceData FunctionType = "smartEnergyManagementPsPriceData" + FunctionTypeSpecificationVersionListData FunctionType = "specificationVersionListData" + FunctionTypeSubscriptionManagementDeleteCall FunctionType = "subscriptionManagementDeleteCall" + FunctionTypeSubscriptionManagementEntryListData FunctionType = "subscriptionManagementEntryListData" + FunctionTypeSubscriptionManagementRequestCall FunctionType = "subscriptionManagementRequestCall" + FunctionTypeSupplyConditionDescriptionListData FunctionType = "supplyConditionDescriptionListData" + FunctionTypeSupplyConditionListData FunctionType = "supplyConditionListData" + FunctionTypeSupplyConditionThresholdRelationListData FunctionType = "supplyConditionThresholdRelationListData" + FunctionTypeTaskManagementJobDescriptionListData FunctionType = "taskManagementJobDescriptionListData" + FunctionTypeTaskManagementJobListData FunctionType = "taskManagementJobListData" + FunctionTypeTaskManagementJobRelationListData FunctionType = "taskManagementJobRelationListData" + FunctionTypeTaskManagementOverviewData FunctionType = "taskManagementOverviewData" + FunctionTypeThresholdConstraintsListData FunctionType = "thresholdConstraintsListData" + FunctionTypeThresholdDescriptionListData FunctionType = "thresholdDescriptionListData" + FunctionTypeThresholdListData FunctionType = "thresholdListData" + FunctionTypeTimeDistributorData FunctionType = "timeDistributorData" + FunctionTypeTimeDistributorEnquiryCall FunctionType = "timeDistributorEnquiryCall" + FunctionTypeTimeInformationData FunctionType = "timeInformationData" + FunctionTypeTimePrecisionData FunctionType = "timePrecisionData" + FunctionTypeTimeTableConstraintsListData FunctionType = "timeTableConstraintsListData" + FunctionTypeTimeTableDescriptionListData FunctionType = "timeTableDescriptionListData" + FunctionTypeTimeTableListData FunctionType = "timeTableListData" + FunctionTypeDeviceConfigurationKeyValueConstraintsListData FunctionType = "deviceConfigurationKeyValueConstraintsListData" + FunctionTypeDeviceConfigurationKeyValueListData FunctionType = "deviceConfigurationKeyValueListData" + FunctionTypeDeviceConfigurationKeyValueDescriptionListData FunctionType = "deviceConfigurationKeyValueDescriptionListData" + FunctionTypeLoadControlLimitConstraintsListData FunctionType = "loadControlLimitConstraintsListData" + FunctionTypeLoadControlLimitDescriptionListData FunctionType = "loadControlLimitDescriptionListData" + FunctionTypeLoadControlLimitListData FunctionType = "loadControlLimitListData" + FunctionTypeLoadControlNodeData FunctionType = "loadControlNodeData" + FunctionTypeTimeSeriesConstraintsListData FunctionType = "timeSeriesConstraintsListData" + FunctionTypeTimeSeriesDescriptionListData FunctionType = "timeSeriesDescriptionListData" + FunctionTypeTimeSeriesListData FunctionType = "timeSeriesListData" + FunctionTypeTariffOverallConstraintsData FunctionType = "tariffOverallConstraintsData" + FunctionTypeTariffListData FunctionType = "tariffListData" + FunctionTypeTariffBoundaryRelationListData FunctionType = "tariffBoundaryRelationListData" + FunctionTypeTariffTierRelationListData FunctionType = "tariffTierRelationListData" + FunctionTypeTariffDescriptionListData FunctionType = "tariffDescriptionListData" + FunctionTypeTierBoundaryListData FunctionType = "tierBoundaryListData" + FunctionTypeTierBoundaryDescriptionListData FunctionType = "tierBoundaryDescriptionListData" + FunctionTypeCommodityListData FunctionType = "commodityListData" + FunctionTypeTierListData FunctionType = "tierListData" + FunctionTypeTierIncentiveRelationListData FunctionType = "tierIncentiveRelationListData" + FunctionTypeTierDescriptionListData FunctionType = "tierDescriptionListData" + FunctionTypeIncentiveListData FunctionType = "incentiveListData" + FunctionTypeIncentiveDescriptionListData FunctionType = "incentiveDescriptionListData" + FunctionTypeIncentiveTableData FunctionType = "incentiveTableData" + FunctionTypeIncentiveTableDescriptionData FunctionType = "incentiveTableDescriptionData" + FunctionTypeIncentiveTableConstraintsData FunctionType = "incentiveTableConstraintsData" + FunctionTypeElectricalConnectionPermittedValueSetListData FunctionType = "electricalConnectionPermittedValueSetListData" + FunctionTypeUseCaseInformationListData FunctionType = "useCaseInformationListData" + FunctionTypeNodeManagementUseCaseData FunctionType = "nodeManagementUseCaseData" + FunctionTypeBillConstraintsListData FunctionType = "billConstraintsListData" + FunctionTypeBillDescriptionListData FunctionType = "billDescriptionListData" + FunctionTypeBillListData FunctionType = "billListData" + FunctionTypeIdentificationListData FunctionType = "identificationListData" + FunctionTypeMeasurementSeriesListData FunctionType = "measurementSeriesListData" + FunctionTypeElectricalConnectionCharacteristicData FunctionType = "electricalConnectionCharacteristicData" + FunctionTypeElectricalConnectionCharacteristicListData FunctionType = "electricalConnectionCharacteristicListData" + FunctionTypeStateInformationListData FunctionType = "stateInformationListData" +) + +type PossibleOperationsClassifierType struct { + Partial *ElementTagType `json:"partial,omitempty"` +} + +type PossibleOperationsReadType struct { + Partial *ElementTagType `json:"partial,omitempty"` +} + +type PossibleOperationsWriteType struct { + Partial *ElementTagType `json:"partial,omitempty"` +} + +type PossibleOperationsType struct { + Read *PossibleOperationsReadType `json:"read,omitempty"` + Write *PossibleOperationsWriteType `json:"write,omitempty"` +} + +type PossibleOperationsElementsType struct { + Read *ElementTagType `json:"read,omitempty"` + Write *ElementTagType `json:"write,omitempty"` +} + +type FunctionPropertyType struct { + Function *FunctionType `json:"function,omitempty"` + PossibleOperations *PossibleOperationsType `json:"possibleOperations,omitempty"` +} + +type FunctionPropertyElementsType struct { + Function *ElementTagType `json:"function,omitempty"` + PossibleOperations *ElementTagType `json:"possibleOperations,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/commondatatypes_additions.go b/src/eebus-bridge/third_party/spine-go/model/commondatatypes_additions.go new file mode 100644 index 0000000..8272e55 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/commondatatypes_additions.go @@ -0,0 +1,372 @@ +package model + +import ( + "encoding/json" + "errors" + "fmt" + "math" + "strconv" + "strings" + "time" + + "github.com/rickb777/date/period" +) + +// TimePeriodType + +func NewTimePeriodTypeWithRelativeEndTime(duration time.Duration) *TimePeriodType { + now := time.Now().UTC() + endTime := now.Add(duration) + value := &TimePeriodType{ + EndTime: NewAbsoluteOrRelativeTimeTypeFromTime(endTime), + } + return value +} + +// helper type to modify EndTime field value in json.Marshal and +// json.Unmarshal to allow provide accurate relative durations +// +// If only EndTime is provided and it is a duration, it has to +// decrease over time. To do this without actually changing +// the data, it will always be transformed into an absolute time +// in Marshal and returned as an up to date relative duration +// in Unmarshal +type tempTimePeriodType TimePeriodType + +func setTimePeriodTypeEndTime(t *tempTimePeriodType) { + if t.StartTime != nil || t.EndTime == nil { + return + } + + duration, err := t.EndTime.GetTimeDuration() + if err != nil { + return + } + + time := time.Now().UTC().Add(duration) + t.EndTime = NewAbsoluteOrRelativeTimeTypeFromTime(time) +} + +func getTimePeriodTypeDuration(t *TimePeriodType) (time.Duration, error) { + if t.StartTime != nil || t.EndTime == nil { + return 0, errors.New("invalid data format") + } + + if t.EndTime.IsRelativeTime() { + return getTimeDurationFromString(string(*t.EndTime)) + } + + endTime, err := t.EndTime.GetTime() + if err != nil { + return 0, err + } + + now := time.Now().UTC() + duration := endTime.Sub(now) + duration = duration.Round(time.Second) + + return duration, nil +} + +// when startTime is empty and endTime is an absolute time, +// then endTime should be returned as an relative timestamp +func (t TimePeriodType) MarshalJSON() ([]byte, error) { + temp := tempTimePeriodType(t) + + if duration, err := getTimePeriodTypeDuration(&t); err == nil { + temp.EndTime = NewAbsoluteOrRelativeTimeTypeFromDuration(duration) + } + + return json.Marshal(temp) +} + +// when startTime is empty and endTime is a relative time, +// then endTime should be written as an absolute timestamp +func (t *TimePeriodType) UnmarshalJSON(data []byte) error { + var temp tempTimePeriodType + if err := json.Unmarshal(data, &temp); err != nil { + return err + } + + setTimePeriodTypeEndTime(&temp) + + *t = TimePeriodType(temp) + + return nil +} + +// Return the current duration if StartTime is nil and EndTime is not +// otherwise returns an error +func (t *TimePeriodType) GetDuration() (time.Duration, error) { + return getTimePeriodTypeDuration(t) +} + +// TimeType xs:time + +func NewTimeType(t string) *TimeType { + value := TimeType(t) + return &value +} + +func (s *TimeType) GetTime() (time.Time, error) { + allowedFormats := []string{ + "15:04:05.999999999", + "15:04:05.999999999Z", + "15:04:05", + "15:04:05Z", + "15:04:05+07:00", + "15:04:05-07:00", + } + + for _, format := range allowedFormats { + if value, err := time.ParseInLocation(format, string(*s), time.UTC); err == nil { + return value, nil + } + } + + return time.Time{}, errors.New("unsupported time format") +} + +// DateType xs:date + +func NewDateType(t string) *DateType { + value := DateType(t) + return &value +} + +// 2001-10-26, 2001-10-26+02:00, 2001-10-26Z, 2001-10-26+00:00, -2001-10-26, or -20000-04-01 +func (d *DateType) GetTime() (time.Time, error) { + allowedFormats := []string{ + "2006-01-02", + "2006-01-02Z", + "2006-01-02+07:00", + } + + for _, format := range allowedFormats { + if value, err := time.ParseInLocation(format, string(*d), time.UTC); err == nil { + return value, nil + } + } + + return time.Time{}, errors.New("unsupported date format") +} + +// DateTimeType xs:datetime + +func NewDateTimeType(t string) *DateTimeType { + value := DateTimeType(t) + return &value +} + +func NewDateTimeTypeFromTime(t time.Time) *DateTimeType { + s := t.Round(time.Second).UTC().Format("2006-01-02T15:04:05Z") + return NewDateTimeType(s) +} + +func (d *DateTimeType) GetTime() (time.Time, error) { + allowedFormats := []string{ + "2006-01-02T15:04:05.999999999", + "2006-01-02T15:04:05.999999999Z", + "2006-01-02T15:04:05", + "2006-01-02T15:04:05Z", + } + + for _, format := range allowedFormats { + if value, err := time.ParseInLocation(format, string(*d), time.UTC); err == nil { + return value, nil + } + } + + return time.Time{}, errors.New("unsupported datetime format") +} + +// DurationType + +func NewDurationType(duration time.Duration) *DurationType { + d, _ := period.NewOf(duration) + value := DurationType(d.String()) + return &value +} + +func (d *DurationType) GetTimeDuration() (time.Duration, error) { + return getTimeDurationFromString(string(*d)) +} + +// helper for DurationType and AbsoluteOrRelativeTimeType +func getTimeDurationFromString(s string) (time.Duration, error) { + p, err := period.Parse(string(s)) + if err != nil { + return 0, err + } + + return p.DurationApprox(), nil +} + +// AbsoluteOrRelativeTimeType +// can be of type TimeType or DurationType + +func NewAbsoluteOrRelativeTimeType(s string) *AbsoluteOrRelativeTimeType { + value := AbsoluteOrRelativeTimeType(s) + return &value +} + +func NewAbsoluteOrRelativeTimeTypeFromDuration(t time.Duration) *AbsoluteOrRelativeTimeType { + s := NewDurationType(t) + value := AbsoluteOrRelativeTimeType(*s) + return &value +} + +func NewAbsoluteOrRelativeTimeTypeFromTime(t time.Time) *AbsoluteOrRelativeTimeType { + s := NewDateTimeTypeFromTime(t) + value := AbsoluteOrRelativeTimeType(*s) + return &value +} + +func (a *AbsoluteOrRelativeTimeType) GetDateTimeType() *DateTimeType { + value := NewDateTimeType(string(*a)) + return value +} + +func (a *AbsoluteOrRelativeTimeType) GetTime() (time.Time, error) { + value := NewDateTimeType(string(*a)) + t, err := value.GetTime() + if err == nil { + return t, nil + } + + // Check if this is a relative time + d, err := getTimeDurationFromString(string(*a)) + if err != nil { + return time.Time{}, err + } + r := time.Now().Add(d) + return r, nil +} + +func (a *AbsoluteOrRelativeTimeType) IsRelativeTime() bool { + _, err := getTimeDurationFromString(string(*a)) + return err == nil +} + +func (a *AbsoluteOrRelativeTimeType) GetDurationType() (*DurationType, error) { + value, err := a.GetTimeDuration() + if err != nil { + return nil, err + } + + return NewDurationType(value), nil +} + +func (a *AbsoluteOrRelativeTimeType) GetTimeDuration() (time.Duration, error) { + return getTimeDurationFromString(string(*a)) +} + +// ScaledNumberType + +func (m *ScaledNumberType) GetValue() float64 { + if m.Number == nil { + return 0 + } + var scale float64 = 0 + if m.Scale != nil { + scale = float64(*m.Scale) + } + return float64(*m.Number) * math.Pow(10, scale) +} + +func NewScaledNumberType(value float64) *ScaledNumberType { + m := &ScaledNumberType{} + + numberOfDecimals := 0 + temp := strconv.FormatFloat(value, 'f', -1, 64) + index := strings.IndexByte(temp, '.') + if index > -1 { + numberOfDecimals = len(temp) - index - 1 + } + + // We limit this to 4 digits for now + if numberOfDecimals > 4 { + numberOfDecimals = 4 + } + + numberValue := NumberType(math.Trunc(value * math.Pow(10, float64(numberOfDecimals)))) + m.Number = &numberValue + + var scaleValue ScaleType + if numberValue != 0 { + scaleValue = ScaleType(-numberOfDecimals) + } else { + scaleValue = ScaleType(0) + } + m.Scale = &scaleValue + + return m +} + +// DeviceAddressType + +var _ UpdateHelper = (*DeviceAddressType)(nil) + +func (r *DeviceAddressType) String() string { + if r == nil { + return "" + } + + var result = "" + if r.Device != nil { + result += string(*r.Device) + } + + return result +} + +// EntityAddressType + +var _ UpdateHelper = (*EntityAddressType)(nil) + +func (r *EntityAddressType) String() string { + if r == nil { + return "" + } + + var result = "" + if r.Device != nil { + result += string(*r.Device) + } + result += ":[" + for index, id := range r.Entity { + if index > 0 { + result += "," + } + result += fmt.Sprintf("%d", id) + } + result += "]:" + return result +} + +// FeatureAddressType + +var _ UpdateHelper = (*FeatureAddressType)(nil) + +func (r *FeatureAddressType) String() string { + if r == nil { + return "" + } + + var result = "" + if r.Device != nil { + result += string(*r.Device) + } + result += ":[" + for index, id := range r.Entity { + if index > 0 { + result += "," + } + result += fmt.Sprintf("%d", id) + } + result += "]:" + if r.Feature != nil { + result += fmt.Sprintf("%d", *r.Feature) + } + return result +} diff --git a/src/eebus-bridge/third_party/spine-go/model/custom.go b/src/eebus-bridge/third_party/spine-go/model/custom.go new file mode 100644 index 0000000..f97423d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/custom.go @@ -0,0 +1,52 @@ +package model + +import ( + "fmt" + + "github.com/enbility/spine-go/util" +) + +// provides a helper method to create hash values of custom structs for usage with collection updates +type UpdateHelper interface { + String() string +} + +type ErrorType struct { + ErrorNumber ErrorNumberType + Description *DescriptionType +} + +func NewErrorType(errorNumber ErrorNumberType, description string) *ErrorType { + return &ErrorType{ + ErrorNumber: errorNumber, + Description: util.Ptr(DescriptionType(description)), + } +} + +func NewErrorTypeFromNumber(errorNumber ErrorNumberType) *ErrorType { + return &ErrorType{ + ErrorNumber: errorNumber, + } +} + +func NewErrorTypeFromString(description string) *ErrorType { + return NewErrorType(ErrorNumberTypeGeneralError, description) +} + +func NewErrorTypeFromResult(result *ResultDataType) *ErrorType { + if result.ErrorNumber == nil || *result.ErrorNumber == ErrorNumberTypeNoError { + return nil + } + + return &ErrorType{ + ErrorNumber: *result.ErrorNumber, + Description: result.Description, + } +} + +func (e *ErrorType) String() string { + if e.Description != nil && len(*e.Description) > 0 { + return fmt.Sprintf("Error %d: %s", e.ErrorNumber, *e.Description) + } + return fmt.Sprintf("Error %d", e.ErrorNumber) +} diff --git a/src/eebus-bridge/third_party/spine-go/model/datagram.go b/src/eebus-bridge/third_party/spine-go/model/datagram.go new file mode 100644 index 0000000..d51a9c7 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/datagram.go @@ -0,0 +1,26 @@ +package model + +type Datagram struct { + Datagram DatagramType `json:"datagram"` +} + +type DatagramType struct { + Header HeaderType `json:"header"` + Payload PayloadType `json:"payload"` +} + +type HeaderType struct { + SpecificationVersion *SpecificationVersionType `json:"specificationVersion,omitempty"` + AddressSource *FeatureAddressType `json:"addressSource,omitempty"` + AddressDestination *FeatureAddressType `json:"addressDestination,omitempty"` + AddressOriginator *FeatureAddressType `json:"addressOriginator,omitempty"` + MsgCounter *MsgCounterType `json:"msgCounter,omitempty"` + MsgCounterReference *MsgCounterType `json:"msgCounterReference,omitempty"` + CmdClassifier *CmdClassifierType `json:"cmdClassifier,omitempty"` + AckRequest *bool `json:"ackRequest,omitempty"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` +} + +type PayloadType struct { + Cmd []CmdType `json:"cmd"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/datagram_additions.go b/src/eebus-bridge/third_party/spine-go/model/datagram_additions.go new file mode 100644 index 0000000..9650236 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/datagram_additions.go @@ -0,0 +1,51 @@ +package model + +import ( + "fmt" +) + +func (d *DatagramType) PrintMessageOverview(send bool, localFeature, remoteFeature string) string { + var result string + + transmission := "Send" + device := "" + if d.Header.AddressDestination != nil && d.Header.AddressDestination.Device != nil { + device = string(*d.Header.AddressDestination.Device) + } + if !send { + transmission = "Recv" + if d.Header.AddressSource.Device != nil { + device = string(*d.Header.AddressSource.Device) + } + device = fmt.Sprintf("%s:%s to %s", device, remoteFeature, localFeature) + } + + cmdClassifier := CmdClassifierType("Unknown") + if d.Header.CmdClassifier != nil { + cmdClassifier = *d.Header.CmdClassifier + } + msgCounter := MsgCounterType(0) + if d.Header.MsgCounter != nil { + msgCounter = *d.Header.MsgCounter + } + cmd := CmdType{} + if len(d.Payload.Cmd) > 0 { + cmd = d.Payload.Cmd[0] + } + + switch cmdClassifier { + case CmdClassifierTypeRead: + result = fmt.Sprintf("%s: %s %s %d %s", transmission, device, cmdClassifier, msgCounter, cmd.DataName()) + case CmdClassifierTypeReply: + msgCounterRef := *d.Header.MsgCounterReference + result = fmt.Sprintf("%s: %s %s %d %d %s", transmission, device, cmdClassifier, msgCounter, msgCounterRef, cmd.DataName()) + case CmdClassifierTypeResult: + msgCounterRef := *d.Header.MsgCounterReference + errorNumber := *d.Payload.Cmd[0].ResultData.ErrorNumber + result = fmt.Sprintf("%s: %s %s %d %d %s %d", transmission, device, cmdClassifier, msgCounter, msgCounterRef, cmd.DataName(), errorNumber) + default: + result = fmt.Sprintf("%s: %s %s %d %s", transmission, device, cmdClassifier, msgCounter, cmd.DataName()) + } + + return result +} diff --git a/src/eebus-bridge/third_party/spine-go/model/datatunneling.go b/src/eebus-bridge/third_party/spine-go/model/datatunneling.go new file mode 100644 index 0000000..7246c98 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/datatunneling.go @@ -0,0 +1,27 @@ +package model + +type PurposeIdType string + +type ChannelIdType uint + +type DataTunnelingHeaderType struct { + PurposeId *PurposeIdType `json:"purposeId,omitempty"` + ChannelId *ChannelIdType `json:"channelId,omitempty"` + SequenceId *uint `json:"sequenceId,omitempty"` +} + +type DataTunnelingHeaderElementsType struct { + PurposeId *ElementTagType `json:"purposeId,omitempty"` + ChannelId *ElementTagType `json:"channelId,omitempty"` + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type DataTunnelingCallType struct { + Header *DataTunnelingHeaderType `json:"header,omitempty"` + Payload *string `json:"payload,omitempty"` +} + +type DataTunnelingCallElementsType struct { + Header *DataTunnelingHeaderElementsType `json:"header,omitempty"` + Payload *ElementTagType `json:"payload,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/deviceclassification.go b/src/eebus-bridge/third_party/spine-go/model/deviceclassification.go new file mode 100644 index 0000000..51e8427 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/deviceclassification.go @@ -0,0 +1,55 @@ +package model + +type DeviceClassificationStringType string + +type PowerSourceType string + +const ( + PowerSourceTypeUnknown PowerSourceType = "unknown" + PowerSourceTypeMainssinglephase PowerSourceType = "mainsSinglePhase" + PowerSourceTypeMains3Phase PowerSourceType = "mains3Phase" + PowerSourceTypeBattery PowerSourceType = "battery" + PowerSourceTypeDc PowerSourceType = "dc" +) + +type DeviceClassificationManufacturerDataType struct { + DeviceName *DeviceClassificationStringType `json:"deviceName,omitempty"` + DeviceCode *DeviceClassificationStringType `json:"deviceCode,omitempty"` + SerialNumber *DeviceClassificationStringType `json:"serialNumber,omitempty"` + SoftwareRevision *DeviceClassificationStringType `json:"softwareRevision,omitempty"` + HardwareRevision *DeviceClassificationStringType `json:"hardwareRevision,omitempty"` + VendorName *DeviceClassificationStringType `json:"vendorName,omitempty"` + VendorCode *DeviceClassificationStringType `json:"vendorCode,omitempty"` + BrandName *DeviceClassificationStringType `json:"brandName,omitempty"` + PowerSource *PowerSourceType `json:"powerSource,omitempty"` + ManufacturerNodeIdentification *DeviceClassificationStringType `json:"manufacturerNodeIdentification,omitempty"` + ManufacturerLabel *LabelType `json:"manufacturerLabel,omitempty"` + ManufacturerDescription *DescriptionType `json:"manufacturerDescription,omitempty"` +} + +type DeviceClassificationManufacturerDataElementsType struct { + DeviceName *ElementTagType `json:"deviceName,omitempty"` + DeviceCode *ElementTagType `json:"deviceCode,omitempty"` + SerialNumber *ElementTagType `json:"serialNumber,omitempty"` + SoftwareRevision *ElementTagType `json:"softwareRevision,omitempty"` + HardwareRevision *ElementTagType `json:"hardwareRevision,omitempty"` + VendorName *ElementTagType `json:"vendorName,omitempty"` + VendorCode *ElementTagType `json:"vendorCode,omitempty"` + BrandName *ElementTagType `json:"brandName,omitempty"` + PowerSource *ElementTagType `json:"powerSource,omitempty"` + ManufacturerNodeIdentification *ElementTagType `json:"manufacturerNodeIdentification,omitempty"` + ManufacturerLabel *ElementTagType `json:"manufacturerLabel,omitempty"` + ManufacturerDescription *ElementTagType `json:"manufacturerDescription,omitempty"` +} + +type DeviceClassificationUserDataType struct { + UserNodeIdentification *DeviceClassificationStringType `json:"userNodeIdentification,omitempty"` + UserLabel *LabelType `json:"userLabel,omitempty"` + UserDescription *DescriptionType `json:"userDescription,omitempty"` +} + +type DeviceClassificationUserDataElementsType struct { + UserNodeIdentification *ElementTagType `json:"userNodeIdentification,omitempty"` + UserLabel *ElementTagType `json:"userLabel,omitempty"` + UserDescription *ElementTagType `json:"userDescription,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration.go b/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration.go new file mode 100644 index 0000000..2da9d70 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration.go @@ -0,0 +1,156 @@ +package model + +type DeviceConfigurationKeyIdType uint + +type DeviceConfigurationKeyValueStringType string + +const ( + DeviceConfigurationKeyValueStringTypeISO151182ED1 DeviceConfigurationKeyValueStringType = "iso15118-2ed1" + DeviceConfigurationKeyValueStringTypeISO151182ED2 DeviceConfigurationKeyValueStringType = "iso15118-2ed2" + DeviceConfigurationKeyValueStringTypeIEC61851 DeviceConfigurationKeyValueStringType = "iec61851" +) + +type DeviceConfigurationKeyNameType string + +const ( + DeviceConfigurationKeyNameTypePeakPowerOfPVSystem DeviceConfigurationKeyNameType = "peakPowerOfPvSystem" + DeviceConfigurationKeyNameTypePvCurtailmentLimitFactor DeviceConfigurationKeyNameType = "pvCurtailmentLimitFactor" + DeviceConfigurationKeyNameTypeAsymmetricChargingSupported DeviceConfigurationKeyNameType = "asymmetricChargingSupported" + DeviceConfigurationKeyNameTypeCommunicationsStandard DeviceConfigurationKeyNameType = "communicationsStandard" + DeviceConfigurationKeyNameTypeInverterGridCode DeviceConfigurationKeyNameType = "inverterGridCode" + DeviceConfigurationKeyNameTypePvStringAvailabilityStatus DeviceConfigurationKeyNameType = "pvStringAvailabilityStatus" + DeviceConfigurationKeyNameTypeBatteryAvailabilityStatus DeviceConfigurationKeyNameType = "batteryAvailabilityStatus" + DeviceConfigurationKeyNameTypeGridConnectionStatus DeviceConfigurationKeyNameType = "gridConnectionStatus" + DeviceConfigurationKeyNameTypeTimeToAcChargePowerMax DeviceConfigurationKeyNameType = "timeToAcChargePowerMax" + DeviceConfigurationKeyNameTypeTimeToAcDischargePowerMax DeviceConfigurationKeyNameType = "timeToAcDischargePowerMax" + DeviceConfigurationKeyNameTypeTilt DeviceConfigurationKeyNameType = "tilt" + DeviceConfigurationKeyNameTypeAzimuth DeviceConfigurationKeyNameType = "azimuth" + DeviceConfigurationKeyNameTypeBatteryType DeviceConfigurationKeyNameType = "batteryType" + DeviceConfigurationKeyNameTypeMaxCycleCountPerDay DeviceConfigurationKeyNameType = "maxCycleCountPerDay" + DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit DeviceConfigurationKeyNameType = "failsafeConsumptionActivePowerLimit" + DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit DeviceConfigurationKeyNameType = "failsafeProductionActivePowerLimit" + DeviceConfigurationKeyNameTypeFailsafePositiveReactivePowerLimit DeviceConfigurationKeyNameType = "failsafePositiveReactivePowerLimit" + DeviceConfigurationKeyNameTypeFailsafeNegativeReactivePowerLimit DeviceConfigurationKeyNameType = "failsafeNegativeReactivePowerLimit" + DeviceConfigurationKeyNameTypeFailsafePositiveCosPhiLimit DeviceConfigurationKeyNameType = "failsafePositiveCosPhiLimit" + DeviceConfigurationKeyNameTypeFailsafeNegativeCosPhiLimit DeviceConfigurationKeyNameType = "failsafeNegativeCosPhiLimit" + DeviceConfigurationKeyNameTypeMaxAcChargePower DeviceConfigurationKeyNameType = "maxAcChargePower" + DeviceConfigurationKeyNameTypeMaxAcDischargePower DeviceConfigurationKeyNameType = "maxAcDischargePower" + DeviceConfigurationKeyNameTypeMaxDcChargePower DeviceConfigurationKeyNameType = "maxDcChargePower" + DeviceConfigurationKeyNameTypeMaxDcDischargePower DeviceConfigurationKeyNameType = "maxDcDischargePower" + DeviceConfigurationKeyNameTypeBatteryActiveControlMode DeviceConfigurationKeyNameType = "batteryActiveControlMode" + DeviceConfigurationKeyNameTypeDefaultAcPower DeviceConfigurationKeyNameType = "defaultAcPower" + DeviceConfigurationKeyNameTypeDefaultDcPower DeviceConfigurationKeyNameType = "defaultDcPower" + DeviceConfigurationKeyNameTypeDefaultPccPower DeviceConfigurationKeyNameType = "defaultPccPower" + DeviceConfigurationKeyNameTypeFailsafeAcPowerSetpoint DeviceConfigurationKeyNameType = "failsafeAcPowerSetpoint" + DeviceConfigurationKeyNameTypeFailsafeDcPowerSetpoint DeviceConfigurationKeyNameType = "failsafeDcPowerSetpoint" + DeviceConfigurationKeyNameTypeFailsafePccPowerSetpoint DeviceConfigurationKeyNameType = "failsafePccPowerSetpoint" + DeviceConfigurationKeyNameTypeFailsafeDurationMinimum DeviceConfigurationKeyNameType = "failsafeDurationMinimum" + DeviceConfigurationKeyNameTypeDischargingBelowTargetEnergyRequestPermitted DeviceConfigurationKeyNameType = "dischargingBelowTargetEnergyRequestPermitted" + DeviceConfigurationKeyNameTypeIncentivesSimulationCyclesMax DeviceConfigurationKeyNameType = "incentivesSimulationCyclesMax" + DeviceConfigurationKeyNameTypeIncentivesSimulationConcurrent DeviceConfigurationKeyNameType = "incentivesSimulationConcurrent" + DeviceConfigurationKeyNameTypeIncentivesTimeoutIncentiveRequest DeviceConfigurationKeyNameType = "incentivesTimeoutIncentiveRequest" + DeviceConfigurationKeyNameTypeIncentivesWaitIncentiveWriteable DeviceConfigurationKeyNameType = "incentivesWaitIncentiveWriteable" +) + +type DeviceConfigurationKeyValueTypeType string + +const ( + DeviceConfigurationKeyValueTypeTypeBoolean DeviceConfigurationKeyValueTypeType = "boolean" + DeviceConfigurationKeyValueTypeTypeDate DeviceConfigurationKeyValueTypeType = "date" + DeviceConfigurationKeyValueTypeTypeDateTime DeviceConfigurationKeyValueTypeType = "dateTime" + DeviceConfigurationKeyValueTypeTypeDuration DeviceConfigurationKeyValueTypeType = "duration" + DeviceConfigurationKeyValueTypeTypeString DeviceConfigurationKeyValueTypeType = "string" + DeviceConfigurationKeyValueTypeTypeTime DeviceConfigurationKeyValueTypeType = "time" + DeviceConfigurationKeyValueTypeTypeScaledNumber DeviceConfigurationKeyValueTypeType = "scaledNumber" + DeviceConfigurationKeyValueTypeTypeInteger DeviceConfigurationKeyValueTypeType = "integer" +) + +type DeviceConfigurationKeyValueValueType struct { + Boolean *bool `json:"boolean,omitempty"` + Date *DateType `json:"date,omitempty"` + DateTime *DateTimeType `json:"dateTime,omitempty"` + Duration *DurationType `json:"duration,omitempty"` + String *DeviceConfigurationKeyValueStringType `json:"string,omitempty"` + Time *TimeType `json:"time,omitempty"` + ScaledNumber *ScaledNumberType `json:"scaledNumber,omitempty"` + Integer *int64 `json:"integer,omitempty"` +} + +type DeviceConfigurationKeyValueValueElementsType struct { + Boolean *ElementTagType `json:"boolean,omitempty"` + Date *ElementTagType `json:"date,omitempty"` + DateTime *ElementTagType `json:"dateTime,omitempty"` + Duration *ElementTagType `json:"duration,omitempty"` + String *ElementTagType `json:"string,omitempty"` + Time *ElementTagType `json:"time,omitempty"` + ScaledNumber *ScaledNumberElementsType `json:"scaledNumber,omitempty"` +} + +type DeviceConfigurationKeyValueDataType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty" eebus:"key"` + Value *DeviceConfigurationKeyValueValueType `json:"value,omitempty"` + IsValueChangeable *bool `json:"isValueChangeable,omitempty" eebus:"writecheck"` +} + +type DeviceConfigurationKeyValueDataElementsType struct { + KeyId *ElementTagType `json:"keyId,omitempty"` + Value *DeviceConfigurationKeyValueValueElementsType `json:"value,omitempty"` + IsValueChangeable *ElementTagType `json:"isValueChangeable,omitempty"` +} + +type DeviceConfigurationKeyValueListDataType struct { + DeviceConfigurationKeyValueData []DeviceConfigurationKeyValueDataType `json:"deviceConfigurationKeyValueData,omitempty"` +} + +type DeviceConfigurationKeyValueListDataSelectorsType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty"` +} + +type DeviceConfigurationKeyValueDescriptionDataType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty" eebus:"key"` + KeyName *DeviceConfigurationKeyNameType `json:"keyName,omitempty"` + ValueType *DeviceConfigurationKeyValueTypeType `json:"valueType,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type DeviceConfigurationKeyValueDescriptionDataElementsType struct { + KeyId *ElementTagType `json:"keyId,omitempty"` + KeyName *ElementTagType `json:"keyName,omitempty"` + ValueType *ElementTagType `json:"valueType,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type DeviceConfigurationKeyValueDescriptionListDataType struct { + DeviceConfigurationKeyValueDescriptionData []DeviceConfigurationKeyValueDescriptionDataType `json:"deviceConfigurationKeyValueDescriptionData,omitempty"` +} + +type DeviceConfigurationKeyValueDescriptionListDataSelectorsType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty"` + KeyName *DeviceConfigurationKeyNameType `json:"keyName,omitempty"` +} + +type DeviceConfigurationKeyValueConstraintsDataType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty" eebus:"key"` + ValueRangeMin *DeviceConfigurationKeyValueValueType `json:"valueRangeMin,omitempty"` + ValueRangeMax *DeviceConfigurationKeyValueValueType `json:"valueRangeMax,omitempty"` + ValueStepSize *DeviceConfigurationKeyValueValueType `json:"valueStepSize,omitempty"` +} + +type DeviceConfigurationKeyValueConstraintsDataElementsType struct { + KeyId *ElementTagType `json:"keyId,omitempty"` + ValueRangeMin *DeviceConfigurationKeyValueValueElementsType `json:"valueRangeMin,omitempty"` + ValueRangeMax *DeviceConfigurationKeyValueValueElementsType `json:"valueRangeMax,omitempty"` + ValueStepSize *DeviceConfigurationKeyValueValueElementsType `json:"valueStepSize,omitempty"` +} + +type DeviceConfigurationKeyValueConstraintsListDataType struct { + DeviceConfigurationKeyValueConstraintsData []DeviceConfigurationKeyValueConstraintsDataType `json:"deviceConfigurationKeyValueConstraintsData,omitempty"` +} + +type DeviceConfigurationKeyValueConstraintsListDataSelectorsType struct { + KeyId *DeviceConfigurationKeyIdType `json:"keyId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration_additions.go b/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration_additions.go new file mode 100644 index 0000000..bbb5132 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/deviceconfiguration_additions.go @@ -0,0 +1,58 @@ +package model + +// DeviceConfigurationKeyValueListDataType + +var _ Updater = (*DeviceConfigurationKeyValueListDataType)(nil) + +func (r *DeviceConfigurationKeyValueListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []DeviceConfigurationKeyValueDataType + if newList != nil { + newData = newList.(*DeviceConfigurationKeyValueListDataType).DeviceConfigurationKeyValueData + } + + data, success := UpdateList(remoteWrite, r.DeviceConfigurationKeyValueData, newData, filterPartial, filterDelete) + + if success && persist { + r.DeviceConfigurationKeyValueData = data + } + + return data, success +} + +// DeviceConfigurationKeyValueDescriptionListDataType + +var _ Updater = (*DeviceConfigurationKeyValueDescriptionListDataType)(nil) + +func (r *DeviceConfigurationKeyValueDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []DeviceConfigurationKeyValueDescriptionDataType + if newList != nil { + newData = newList.(*DeviceConfigurationKeyValueDescriptionListDataType).DeviceConfigurationKeyValueDescriptionData + } + + data, success := UpdateList(remoteWrite, r.DeviceConfigurationKeyValueDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.DeviceConfigurationKeyValueDescriptionData = data + } + + return data, success +} + +// DeviceConfigurationKeyValueConstraintsListDataType + +var _ Updater = (*DeviceConfigurationKeyValueConstraintsListDataType)(nil) + +func (r *DeviceConfigurationKeyValueConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []DeviceConfigurationKeyValueConstraintsDataType + if newList != nil { + newData = newList.(*DeviceConfigurationKeyValueConstraintsListDataType).DeviceConfigurationKeyValueConstraintsData + } + + data, success := UpdateList(remoteWrite, r.DeviceConfigurationKeyValueConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.DeviceConfigurationKeyValueConstraintsData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/devicediagnosis.go b/src/eebus-bridge/third_party/spine-go/model/devicediagnosis.go new file mode 100644 index 0000000..e772fd5 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/devicediagnosis.go @@ -0,0 +1,76 @@ +package model + +type VendorStateCodeType string + +type LastErrorCodeType string + +type DeviceDiagnosisOperatingStateType string + +const ( + DeviceDiagnosisOperatingStateTypeNormalOperation DeviceDiagnosisOperatingStateType = "normalOperation" + DeviceDiagnosisOperatingStateTypeStandby DeviceDiagnosisOperatingStateType = "standby" + DeviceDiagnosisOperatingStateTypeFailure DeviceDiagnosisOperatingStateType = "failure" + DeviceDiagnosisOperatingStateTypeServiceNeeded DeviceDiagnosisOperatingStateType = "serviceNeeded" + DeviceDiagnosisOperatingStateTypeOverrideDetected DeviceDiagnosisOperatingStateType = "overrideDetected" + DeviceDiagnosisOperatingStateTypeInAlarm DeviceDiagnosisOperatingStateType = "inAlarm" + DeviceDiagnosisOperatingStateTypeNotReachable DeviceDiagnosisOperatingStateType = "notReachable" + DeviceDiagnosisOperatingStateTypeFinished DeviceDiagnosisOperatingStateType = "finished" + DeviceDiagnosisOperatingStateTypeTemporarilyNotReady DeviceDiagnosisOperatingStateType = "temporarilyNotReady" + DeviceDiagnosisOperatingStateTypeOff DeviceDiagnosisOperatingStateType = "off" +) + +type PowerSupplyConditionType string + +const ( + PowerSupplyConditionTypeGood PowerSupplyConditionType = "good" + PowerSupplyConditionTypeLow PowerSupplyConditionType = "low" + PowerSupplyConditionTypeCritical PowerSupplyConditionType = "critical" + PowerSupplyConditionTypeUnknown PowerSupplyConditionType = "unknown" + PowerSupplyConditionTypeError PowerSupplyConditionType = "error" +) + +type DeviceDiagnosisStateDataType struct { + Timestamp *string `json:"timestamp,omitempty"` + OperatingState *DeviceDiagnosisOperatingStateType `json:"operatingState,omitempty"` + VendorStateCode *VendorStateCodeType `json:"vendorStateCode,omitempty"` + LastErrorCode *LastErrorCodeType `json:"lastErrorCode,omitempty"` + UpTime *DurationType `json:"upTime,omitempty"` + TotalUpTime *DurationType `json:"totalUpTime,omitempty"` + PowerSupplyCondition *PowerSupplyConditionType `json:"powerSupplyCondition,omitempty"` +} + +type DeviceDiagnosisStateDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + OperatingState *ElementTagType `json:"operatingState,omitempty"` + VendorStateCode *ElementTagType `json:"vendorStateCode,omitempty"` + LastErrorCode *ElementTagType `json:"lastErrorCode,omitempty"` + UpTime *ElementTagType `json:"upTime,omitempty"` + TotalUpTime *ElementTagType `json:"totalUpTime,omitempty"` + PowerSupplyCondition *ElementTagType `json:"powerSupplyCondition,omitempty"` +} + +type DeviceDiagnosisHeartbeatDataType struct { + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + HeartbeatCounter *uint64 `json:"heartbeatCounter,omitempty"` + HeartbeatTimeout *DurationType `json:"heartbeatTimeout,omitempty"` +} + +type DeviceDiagnosisHeartbeatDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + HeartbeatCounter *ElementTagType `json:"heartbeatCounter,omitempty"` + HeartbeatTimeout *ElementTagType `json:"heartbeatTimeout,omitempty"` +} + +type DeviceDiagnosisServiceDataType struct { + Timestamp *string `json:"timestamp,omitempty"` + InstallationTime *string `json:"installationTime,omitempty"` + BootCounter *uint64 `json:"bootCounter,omitempty"` + NextService *string `json:"nextService,omitempty"` +} + +type DeviceDiagnosisServiceDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + InstallationTime *ElementTagType `json:"installationTime,omitempty"` + BootCounter *ElementTagType `json:"bootCounter,omitempty"` + NextService *ElementTagType `json:"nextService,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/directcontrol.go b/src/eebus-bridge/third_party/spine-go/model/directcontrol.go new file mode 100644 index 0000000..b63c8f8 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/directcontrol.go @@ -0,0 +1,55 @@ +package model + +type DirectControlActivityStateType string + +const ( + DirectControlActivityStateTypeRunning AlarmTypeType = "running" + DirectControlActivityStateTypePaused AlarmTypeType = "paused" + DirectControlActivityStateTypeInactive AlarmTypeType = "inactive" +) + +type DirectControlActivityDataType struct { + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + ActivityState *DirectControlActivityStateType `json:"activityState,omitempty"` + IsActivityStateChangeable *bool `json:"isActivityStateChangeable,omitempty"` + EnergyMode *EnergyModeType `json:"energyMode,omitempty"` + IsEnergyModeChangeable *bool `json:"isEnergyModeChangeable,omitempty"` + Power *ScaledNumberType `json:"power,omitempty"` + IsPowerChangeable *bool `json:"isPowerChangeable,omitempty"` + Energy *ScaledNumberType `json:"energy,omitempty"` + IsEnergyChangeable *bool `json:"isEnergyChangeable,omitempty"` + SequenceId *PowerSequenceIdType `json:"sequence_id,omitempty"` +} + +type DirectControlActivityDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + ActivityState *ElementTagType `json:"activityState,omitempty"` + IsActivityStateChangeable *ElementTagType `json:"isActivityStateChangeable,omitempty"` + EnergyMode *ElementTagType `json:"energyMode,omitempty"` + IsEnergyModeChangeable *ElementTagType `json:"isEnergyModeChangeable,omitempty"` + Power *ScaledNumberElementsType `json:"power,omitempty"` + IsPowerChangeable *ElementTagType `json:"isPowerChangeable,omitempty"` + Energy *ScaledNumberElementsType `json:"energy,omitempty"` + IsEnergyChangeable *ElementTagType `json:"isEnergyChangeable,omitempty"` + SequenceId *ElementTagType `json:"sequence_id,omitempty"` +} + +type DirectControlActivityListDataType struct { + DirectControlActivityDataElements []DirectControlActivityDataType `json:"directControlActivityDataElements,omitempty"` +} + +type DirectControlActivityListDataSelectorsType struct { + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` +} + +type DirectControlDescriptionDataType struct { + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *UnitOfMeasurementType `json:"powerUnit,omitempty"` + EnergyUnit *UnitOfMeasurementType `json:"energyUnit,omitempty"` +} + +type DirectControlDescriptionDataElementsType struct { + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *ElementTagType `json:"powerUnit,omitempty"` + EnergyUnit *ElementTagType `json:"energyUnit,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/eebus_tags.go b/src/eebus-bridge/third_party/spine-go/model/eebus_tags.go new file mode 100644 index 0000000..e5a6c2d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/eebus_tags.go @@ -0,0 +1,47 @@ +package model + +import ( + "reflect" + "strings" + + "github.com/enbility/ship-go/logging" +) + +type EEBusTag string + +const ( + EEBusTagFunction EEBusTag = "fct" + EEBusTagType EEBusTag = "typ" + EEBusTagKey EEBusTag = "key" + EEBusTagWriteCheck EEBusTag = "writecheck" +) + +type EEBusTagTypeType string + +const ( + EEBusTagTypeTypeSelector EEBusTagTypeType = "selector" + EEbusTagTypeTypeElements EEBusTagTypeType = "elements" +) + +const EEBusTagName string = "eebus" + +func EEBusTags(field reflect.StructField) map[EEBusTag]string { + result := make(map[EEBusTag]string) + tags := field.Tag.Get(EEBusTagName) + if len(tags) == 0 { + return result + } + for _, tag := range strings.Split(tags, ",") { + pair := strings.Split(tag, ":") + if len(pair) == 1 { + // boolean tags like "key" + result[EEBusTag(pair[0])] = "true" + } else if len(pair) == 2 { + result[EEBusTag(pair[0])] = pair[1] + } else { + logging.Log().Errorf("error: malformatted eebus tag: '%s'", tags) + } + } + + return result +} diff --git a/src/eebus-bridge/third_party/spine-go/model/electricalconnection.go b/src/eebus-bridge/third_party/spine-go/model/electricalconnection.go new file mode 100644 index 0000000..ae1b7c6 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/electricalconnection.go @@ -0,0 +1,239 @@ +package model + +type ElectricalConnectionIdType uint + +type ElectricalConnectionParameterIdType uint + +type ElectricalConnectionCharacteristicIdType uint + +type ElectricalConnectionMeasurandVariantType string + +const ( + ElectricalConnectionMeasurandVariantTypeAmplitude ElectricalConnectionMeasurandVariantType = "amplitude" + ElectricalConnectionMeasurandVariantTypeRms ElectricalConnectionMeasurandVariantType = "rms" + ElectricalConnectionMeasurandVariantTypeInstantaneous ElectricalConnectionMeasurandVariantType = "instantaneous" + ElectricalConnectionMeasurandVariantTypeAngle ElectricalConnectionMeasurandVariantType = "angle" + ElectricalConnectionMeasurandVariantTypeCosphi ElectricalConnectionMeasurandVariantType = "cosPhi" +) + +type ElectricalConnectionVoltageTypeType string + +const ( + ElectricalConnectionVoltageTypeTypeAc ElectricalConnectionVoltageTypeType = "ac" + ElectricalConnectionVoltageTypeTypeDc ElectricalConnectionVoltageTypeType = "dc" +) + +type ElectricalConnectionAcMeasurementTypeType string + +const ( + ElectricalConnectionAcMeasurementTypeTypeReal ElectricalConnectionAcMeasurementTypeType = "real" + ElectricalConnectionAcMeasurementTypeTypeReactive ElectricalConnectionAcMeasurementTypeType = "reactive" + ElectricalConnectionAcMeasurementTypeTypeApparent ElectricalConnectionAcMeasurementTypeType = "apparent" + ElectricalConnectionAcMeasurementTypeTypePhase ElectricalConnectionAcMeasurementTypeType = "phase" +) + +type ElectricalConnectionPhaseNameType string + +const ( + ElectricalConnectionPhaseNameTypeA ElectricalConnectionPhaseNameType = "a" + ElectricalConnectionPhaseNameTypeB ElectricalConnectionPhaseNameType = "b" + ElectricalConnectionPhaseNameTypeC ElectricalConnectionPhaseNameType = "c" + ElectricalConnectionPhaseNameTypeAb ElectricalConnectionPhaseNameType = "ab" + ElectricalConnectionPhaseNameTypeBc ElectricalConnectionPhaseNameType = "bc" + ElectricalConnectionPhaseNameTypeAc ElectricalConnectionPhaseNameType = "ac" + ElectricalConnectionPhaseNameTypeAbc ElectricalConnectionPhaseNameType = "abc" + ElectricalConnectionPhaseNameTypeNeutral ElectricalConnectionPhaseNameType = "neutral" + ElectricalConnectionPhaseNameTypeGround ElectricalConnectionPhaseNameType = "ground" + ElectricalConnectionPhaseNameTypeNone ElectricalConnectionPhaseNameType = "none" +) + +type ElectricalConnectionConnectionPointType string + +const ( + ElectricalConnectionConnectionPointTypeGrid ElectricalConnectionConnectionPointType = "grid" + ElectricalConnectionConnectionPointTypeHome ElectricalConnectionConnectionPointType = "home" + ElectricalConnectionConnectionPointTypePv ElectricalConnectionConnectionPointType = "pv" + ElectricalConnectionConnectionPointTypeSd ElectricalConnectionConnectionPointType = "sd" + ElectricalConnectionConnectionPointTypeOther ElectricalConnectionConnectionPointType = "other" +) + +type ElectricalConnectionCharacteristicContextType string + +const ( + ElectricalConnectionCharacteristicContextTypeDevice ElectricalConnectionCharacteristicContextType = "device" + ElectricalConnectionCharacteristicContextTypeEntity ElectricalConnectionCharacteristicContextType = "entity" + ElectricalConnectionCharacteristicContextTypeInverter ElectricalConnectionCharacteristicContextType = "inverter" + ElectricalConnectionCharacteristicContextTypePvString ElectricalConnectionCharacteristicContextType = "pvString" + ElectricalConnectionCharacteristicContextTypeBattery ElectricalConnectionCharacteristicContextType = "battery" +) + +type ElectricalConnectionCharacteristicTypeType string + +const ( + ElectricalConnectionCharacteristicTypeTypePowerConsumptionMin ElectricalConnectionCharacteristicTypeType = "powerConsumptionMin" + ElectricalConnectionCharacteristicTypeTypePowerConsumptionMax ElectricalConnectionCharacteristicTypeType = "powerConsumptionMax" + ElectricalConnectionCharacteristicTypeTypePowerConsumptionNominalMin ElectricalConnectionCharacteristicTypeType = "powerConsumptionNominalMin" + ElectricalConnectionCharacteristicTypeTypePowerConsumptionNominalMax ElectricalConnectionCharacteristicTypeType = "powerConsumptionNominalMax" + ElectricalConnectionCharacteristicTypeTypePowerProductionMin ElectricalConnectionCharacteristicTypeType = "powerProductionMin" + ElectricalConnectionCharacteristicTypeTypePowerProductionMax ElectricalConnectionCharacteristicTypeType = "powerProductionMax" + ElectricalConnectionCharacteristicTypeTypePowerProductionNominalMin ElectricalConnectionCharacteristicTypeType = "powerProductionNominalMin" + ElectricalConnectionCharacteristicTypeTypePowerProductionNominalMax ElectricalConnectionCharacteristicTypeType = "powerProductionNominalMax" + ElectricalConnectionCharacteristicTypeTypeEnergyCapacityNominalMax ElectricalConnectionCharacteristicTypeType = "energyCapacityNominalMax" + ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax ElectricalConnectionCharacteristicTypeType = "contractualConsumptionNominalMax" + ElectricalConnectionCharacteristicTypeTypeContractualProductionNominalMax ElectricalConnectionCharacteristicTypeType = "contractualProductionNominalMax" + ElectricalConnectionCharacteristicTypeTypeApparentPowerProductionNominalMax ElectricalConnectionCharacteristicTypeType = "apparentPowerProductionNominalMax" + ElectricalConnectionCharacteristicTypeTypeApparentPowerConsumptionNominalMax ElectricalConnectionCharacteristicTypeType = "apparentPowerConsumptionNominalMax" +) + +type ElectricalConnectionParameterDescriptionDataType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty" eebus:"key"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + VoltageType *ElectricalConnectionVoltageTypeType `json:"voltageType,omitempty"` + AcMeasuredPhases *ElectricalConnectionPhaseNameType `json:"acMeasuredPhases,omitempty"` + AcMeasuredInReferenceTo *ElectricalConnectionPhaseNameType `json:"acMeasuredInReferenceTo,omitempty"` + AcMeasurementType *ElectricalConnectionAcMeasurementTypeType `json:"acMeasurementType,omitempty"` + AcMeasurementVariant *ElectricalConnectionMeasurandVariantType `json:"acMeasurementVariant,omitempty"` + AcMeasuredHarmonic *uint8 `json:"acMeasuredHarmonic,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type ElectricalConnectionParameterDescriptionDataElementsType struct { + ElectricalConnectionId *ElementTagType `json:"electricalConnectionId,omitempty"` + ParameterId *ElementTagType `json:"parameterId,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + VoltageType *ElementTagType `json:"voltageType,omitempty"` + AcMeasuredPhases *ElementTagType `json:"acMeasuredPhases,omitempty"` + AcMeasuredInReferenceTo *ElementTagType `json:"acMeasuredInReferenceTo,omitempty"` + AcMeasurementType *ElementTagType `json:"acMeasurementType,omitempty"` + AcMeasurementVariant *ElementTagType `json:"acMeasurementVariant,omitempty"` + AcMeasuredHarmonic *ElementTagType `json:"acMeasuredHarmonic,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type ElectricalConnectionParameterDescriptionListDataType struct { + ElectricalConnectionParameterDescriptionData []ElectricalConnectionParameterDescriptionDataType `json:"electricalConnectionParameterDescriptionData,omitempty"` +} + +type ElectricalConnectionParameterDescriptionListDataSelectorsType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type ElectricalConnectionPermittedValueSetDataType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty" eebus:"key"` + PermittedValueSet []ScaledNumberSetType `json:"permittedValueSet,omitempty"` +} + +type ElectricalConnectionPermittedValueSetDataElementsType struct { + ElectricalConnectionId *ElementTagType `json:"electricalConnectionId,omitempty"` + ParameterId *ElementTagType `json:"parameterId,omitempty"` + PermittedValueSet *ElementTagType `json:"permittedValueSet,omitempty"` +} + +type ElectricalConnectionPermittedValueSetListDataType struct { + ElectricalConnectionPermittedValueSetData []ElectricalConnectionPermittedValueSetDataType `json:"electricalConnectionPermittedValueSetData,omitempty"` +} + +type ElectricalConnectionPermittedValueSetListDataSelectorsType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty"` +} + +type ElectricalConnectionStateDataType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + CurrentEnergyMode *EnergyModeType `json:"currentEnergyMode,omitempty"` + ConsumptionTime *DurationType `json:"consumptionTime,omitempty"` + ProductionTime *DurationType `json:"productionTime,omitempty"` + TotalConsumptionTime *DurationType `json:"totalConsumptionTime,omitempty"` + TotalProductionTime *DurationType `json:"totalProductionTime,omitempty"` +} + +type ElectricalConnectionStateDataElementsType struct { + ElectricalConnectionId *ElementTagType `json:"electricalConnectionId,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + CurrentEnergyMode *ElementTagType `json:"currentEnergyMode,omitempty"` + ConsumptionTime *ElementTagType `json:"consumptionTime,omitempty"` + ProductionTime *ElementTagType `json:"productionTime,omitempty"` + TotalConsumptionTime *ElementTagType `json:"totalConsumptionTime,omitempty"` + TotalProductionTime *ElementTagType `json:"totalProductionTime,omitempty"` +} + +type ElectricalConnectionStateListDataType struct { + ElectricalConnectionStateData []ElectricalConnectionStateDataType `json:"electricalConnectionStateData,omitempty"` +} + +type ElectricalConnectionStateListDataSelectorsType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` +} + +type ElectricalConnectionDescriptionDataType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` + PowerSupplyType *ElectricalConnectionVoltageTypeType `json:"powerSupplyType,omitempty"` + AcConnectedPhases *uint `json:"acConnectedPhases,omitempty"` + AcRmsPeriodDuration *DurationType `json:"acRmsPeriodDuration,omitempty"` + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type ElectricalConnectionDescriptionDataElementsType struct { + ElectricalConnectionId *ElementTagType `json:"electricalConnectionId,omitempty"` + PowerSupplyType *ElementTagType `json:"powerSupplyType,omitempty"` + AcConnectedPhases *ElementTagType `json:"acConnectedPhases,omitempty"` + AcRmsPeriodDuration *ElementTagType `json:"acRmsPeriodDuration,omitempty"` + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type ElectricalConnectionDescriptionListDataType struct { + ElectricalConnectionDescriptionData []ElectricalConnectionDescriptionDataType `json:"electricalConnectionDescriptionData,omitempty"` +} + +type ElectricalConnectionDescriptionListDataSelectorsType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type ElectricalConnectionCharacteristicDataType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty" eebus:"key"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty" eebus:"key"` + CharacteristicId *ElectricalConnectionCharacteristicIdType `json:"characteristicId,omitempty" eebus:"key"` + CharacteristicContext *ElectricalConnectionCharacteristicContextType `json:"characteristicContext,omitempty"` + CharacteristicType *ElectricalConnectionCharacteristicTypeType `json:"characteristicType,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` +} + +type ElectricalConnectionCharacteristicDataElementsType struct { + ElectricalConnectionId *ElementTagType `json:"electricalConnectionId,omitempty"` + ParameterId *ElementTagType `json:"parameterId,omitempty"` + CharacteristicId *ElementTagType `json:"characteristicId,omitempty"` + CharacteristicContext *ElementTagType `json:"characteristicContext,omitempty"` + CharacteristicType *ElementTagType `json:"characteristicType,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` +} + +type ElectricalConnectionCharacteristicListDataType struct { + ElectricalConnectionCharacteristicData []ElectricalConnectionCharacteristicDataType `json:"electricalConnectionCharacteristicData,omitempty"` +} + +type ElectricalConnectionCharacteristicListDataSelectorsType struct { + ElectricalConnectionId *ElectricalConnectionIdType `json:"electricalConnectionId,omitempty"` + ParameterId *ElectricalConnectionParameterIdType `json:"parameterId,omitempty"` + CharacteristicId *ElectricalConnectionCharacteristicIdType `json:"characteristicId,omitempty"` + CharacteristicContext *ElectricalConnectionCharacteristicContextType `json:"characteristicContext,omitempty"` + CharacteristicType *ElectricalConnectionCharacteristicTypeType `json:"characteristicType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/electricalconnection_additions.go b/src/eebus-bridge/third_party/spine-go/model/electricalconnection_additions.go new file mode 100644 index 0000000..f015145 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/electricalconnection_additions.go @@ -0,0 +1,96 @@ +package model + +// ElectricalConnectionStateListDataType + +var _ Updater = (*ElectricalConnectionStateListDataType)(nil) + +func (r *ElectricalConnectionStateListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ElectricalConnectionStateDataType + if newList != nil { + newData = newList.(*ElectricalConnectionStateListDataType).ElectricalConnectionStateData + } + + data, success := UpdateList(remoteWrite, r.ElectricalConnectionStateData, newData, filterPartial, filterDelete) + + if success && persist { + r.ElectricalConnectionStateData = data + } + + return data, success +} + +// ElectricalConnectionPermittedValueSetListDataType + +var _ Updater = (*ElectricalConnectionPermittedValueSetListDataType)(nil) + +func (r *ElectricalConnectionPermittedValueSetListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ElectricalConnectionPermittedValueSetDataType + if newList != nil { + newData = newList.(*ElectricalConnectionPermittedValueSetListDataType).ElectricalConnectionPermittedValueSetData + } + + data, success := UpdateList(remoteWrite, r.ElectricalConnectionPermittedValueSetData, newData, filterPartial, filterDelete) + + if success && persist { + r.ElectricalConnectionPermittedValueSetData = data + } + + return data, success +} + +// ElectricalConnectionDescriptionListDataType + +var _ Updater = (*ElectricalConnectionDescriptionListDataType)(nil) + +func (r *ElectricalConnectionDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ElectricalConnectionDescriptionDataType + if newList != nil { + newData = newList.(*ElectricalConnectionDescriptionListDataType).ElectricalConnectionDescriptionData + } + + data, success := UpdateList(remoteWrite, r.ElectricalConnectionDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.ElectricalConnectionDescriptionData = data + } + + return data, success +} + +// ElectricalConnectionCharacteristicListDataType + +var _ Updater = (*ElectricalConnectionCharacteristicListDataType)(nil) + +func (r *ElectricalConnectionCharacteristicListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ElectricalConnectionCharacteristicDataType + if newList != nil { + newData = newList.(*ElectricalConnectionCharacteristicListDataType).ElectricalConnectionCharacteristicData + } + + data, success := UpdateList(remoteWrite, r.ElectricalConnectionCharacteristicData, newData, filterPartial, filterDelete) + + if success && persist { + r.ElectricalConnectionCharacteristicData = data + } + + return data, success +} + +// ElectricalConnectionParameterDescriptionListDataType + +var _ Updater = (*ElectricalConnectionParameterDescriptionListDataType)(nil) + +func (r *ElectricalConnectionParameterDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ElectricalConnectionParameterDescriptionDataType + if newList != nil { + newData = newList.(*ElectricalConnectionParameterDescriptionListDataType).ElectricalConnectionParameterDescriptionData + } + + data, success := UpdateList(remoteWrite, r.ElectricalConnectionParameterDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.ElectricalConnectionParameterDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/hvac.go b/src/eebus-bridge/third_party/spine-go/model/hvac.go new file mode 100644 index 0000000..060d3d5 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/hvac.go @@ -0,0 +1,222 @@ +package model + +type HvacSystemFunctionIdType uint + +type HvacSystemFunctionTypeType string + +const ( + HvacSystemFunctionTypeTypeHeating HvacSystemFunctionTypeType = "heating" + HvacSystemFunctionTypeTypeCooling HvacSystemFunctionTypeType = "cooling" + HvacSystemFunctionTypeTypeVentilation HvacSystemFunctionTypeType = "ventilation" + HvacSystemFunctionTypeTypeDhw HvacSystemFunctionTypeType = "dhw" +) + +type HvacOperationModeIdType uint + +type HvacOperationModeTypeType string + +const ( + HvacOperationModeTypeTypeAuto HvacOperationModeTypeType = "auto" + HvacOperationModeTypeTypeOn HvacOperationModeTypeType = "on" + HvacOperationModeTypeTypeOff HvacOperationModeTypeType = "off" + HvacOperationModeTypeTypeEco HvacOperationModeTypeType = "eco" +) + +type HvacOverrunIdType uint + +type HvacOverrunTypeType string + +const ( + HvacOverrunTypeTypeOneTimeDhw HvacOverrunTypeType = "oneTimeDhw" + HvacOverrunTypeTypeParty HvacOverrunTypeType = "party" + HvacOverrunTypeTypeSgReadyCondition1 HvacOverrunTypeType = "sgReadyCondition1" + HvacOverrunTypeTypeSgReadyCondition3 HvacOverrunTypeType = "sgReadyCondition3" + HvacOverrunTypeTypeSgReadyCondition4 HvacOverrunTypeType = "sgReadyCondition4" + HvacOverrunTypeTypeOneDayAway HvacOverrunTypeType = "oneDayAway" + HvacOverrunTypeTypeOneDayAtHome HvacOverrunTypeType = "oneDayAtHome" + HvacOverrunTypeTypeOneTimeVentilation HvacOverrunTypeType = "oneTimeVentilation" + HvacOverrunTypeTypeHvacSystemOff HvacOverrunTypeType = "hvacSystemOff" + HvacOverrunTypeTypeValveKick HvacOverrunTypeType = "valveKick" +) + +type HvacOverrunStatusType string + +const ( + HvacOverrunStatusTypeActive HvacOverrunStatusType = "active" + HvacOverrunStatusTypeRunning HvacOverrunStatusType = "running" + HvacOverrunStatusTypeFinished HvacOverrunStatusType = "finished" + HvacOverrunStatusTypeInactive HvacOverrunStatusType = "inactive" +) + +type HvacSystemFunctionDataType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"` + CurrentOperationModeId *HvacOperationModeIdType `json:"currentOperationModeId,omitempty"` + IsOperationModeIdChangeable *bool `json:"isOperationModeIdChangeable,omitempty"` + CurrentSetpointId *SetpointIdType `json:"currentSetpointId,omitempty"` + IsSetpointIdChangeable *bool `json:"isSetpointIdChangeable,omitempty"` + IsOverrunActive *bool `json:"isOverrunActive,omitempty"` +} + +type HvacSystemFunctionDataElementsType struct { + SystemFunctionId *ElementTagType `json:"systemFunctionId,omitempty"` + CurrentOperationModeId *ElementTagType `json:"currentOperationModeId,omitempty"` + IsOperationModeIdChangeable *ElementTagType `json:"isOperationModeIdChangeable,omitempty"` + CurrentSetpointId *ElementTagType `json:"currentSetpointId,omitempty"` + IsSetpointIdChangeable *ElementTagType `json:"isSetpointIdChangeable,omitempty"` + IsOverrunActive *ElementTagType `json:"isOverrunActive,omitempty"` +} + +type HvacSystemFunctionListDataType struct { + HvacSystemFunctionData []HvacSystemFunctionDataType `json:"hvacSystemFunctionData,omitempty"` +} + +type HvacSystemFunctionListDataSelectorsType struct { + SystemFunctionId []HvacSystemFunctionIdType `json:"systemFunctionId,omitempty"` +} + +type HvacSystemFunctionOperationModeRelationDataType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"` + OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty"` +} + +type HvacSystemFunctionOperationModeRelationDataElementsType struct { + SystemFunctionId *ElementTagType `json:"systemFunctionId,omitempty"` + OperationModeId *ElementTagType `json:"operationModeId,omitempty"` +} + +type HvacSystemFunctionOperationModeRelationListDataType struct { + HvacSystemFunctionOperationModeRelationData []HvacSystemFunctionOperationModeRelationDataType `json:"hvacSystemFunctionOperationModeRelationData,omitempty"` +} + +type HvacSystemFunctionOperationModeRelationListDataSelectorsType struct { + SystemFunctionId []HvacSystemFunctionIdType `json:"systemFunctionId,omitempty"` +} + +type HvacSystemFunctionSetpointRelationDataType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"` + OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty"` + SetpointId *SetpointIdType `json:"setpointId,omitempty"` +} + +type HvacSystemFunctionSetpointRelationDataElementsType struct { + SystemFunctionId *ElementTagType `json:"systemFunctionId,omitempty"` + OperationModeId *ElementTagType `json:"operationModeId,omitempty"` + SetpointId *ElementTagType `json:"setpointId,omitempty"` +} + +type HvacSystemFunctionSetpointRelationListDataType struct { + HvacSystemFunctionSetpointRelationData []HvacSystemFunctionSetpointRelationDataType `json:"hvacSystemFunctionSetpointRelationData,omitempty"` +} + +type HvacSystemFunctionSetpointRelationListDataSelectorsType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty"` + OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty"` +} + +type HvacSystemFunctionPowerSequenceRelationDataType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"` + SequenceId []PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type HvacSystemFunctionPowerSequenceRelationDataElementsType struct { + SystemFunctionId *ElementTagType `json:"systemFunctionId,omitempty"` + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type HvacSystemFunctionPowerSequenceRelationListDataType struct { + HvacSystemFunctionPowerSequenceRelationData []HvacSystemFunctionPowerSequenceRelationDataType `json:"hvacSystemFunctionPowerSequenceRelationData,omitempty"` +} + +type HvacSystemFunctionPowerSequenceRelationListDataSelectorsType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty"` +} + +type HvacSystemFunctionDescriptionDataType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty" eebus:"key"` + SystemFunctionType *HvacSystemFunctionTypeType `json:"systemFunctionType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type HvacSystemFunctionDescriptionDataElementsType struct { + SystemFunctionId *ElementTagType `json:"systemFunctionId,omitempty"` + SystemFunctionType *ElementTagType `json:"systemFunctionType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type HvacSystemFunctionDescriptionListDataType struct { + HvacSystemFunctionDescriptionData []HvacSystemFunctionDescriptionDataType `json:"hvacSystemFunctionDescriptionData,omitempty"` +} + +type HvacSystemFunctionDescriptionListDataSelectorsType struct { + SystemFunctionId *HvacSystemFunctionIdType `json:"systemFunctionId,omitempty"` +} + +type HvacOperationModeDescriptionDataType struct { + OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty" eebus:"key"` + OperationModeType *HvacOperationModeTypeType `json:"operationModeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type HvacOperationModeDescriptionDataElementsType struct { + OperationModeId *ElementTagType `json:"operationModeId,omitempty"` + OperationModeType *ElementTagType `json:"operationModeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type HvacOperationModeDescriptionListDataType struct { + HvacOperationModeDescriptionData []HvacOperationModeDescriptionDataType `json:"hvacOperationModeDescriptionData,omitempty"` +} + +type HvacOperationModeDescriptionListDataSelectorsType struct { + OperationModeId *HvacOperationModeIdType `json:"operationModeId,omitempty"` +} + +type HvacOverrunDataType struct { + OverrunId *HvacOverrunIdType `json:"overrunId,omitempty" eebus:"key"` + OverrunStatus *HvacOverrunStatusType `json:"overrunStatus,omitempty"` + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` + IsOverrunStatusChangeable *bool `json:"isOverrunStatusChangeable,omitempty"` +} + +type HvacOverrunDataElementsType struct { + OverrunId *ElementTagType `json:"overrunId,omitempty"` + OverrunStatus *ElementTagType `json:"overrunStatus,omitempty"` + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + IsOverrunStatusChangeable *ElementTagType `json:"isOverrunStatusChangeable,omitempty"` +} + +type HvacOverrunListDataType struct { + HvacOverrunData []HvacOverrunDataType `json:"hvacOverrunData,omitempty"` +} + +type HvacOverrunListDataSelectorsType struct { + OverrunId *HvacOverrunIdType `json:"overrunId,omitempty"` +} + +type HvacOverrunDescriptionDataType struct { + OverrunId *HvacOverrunIdType `json:"overrunId,omitempty" eebus:"key"` + OverrunType *HvacOverrunTypeType `json:"overrunType,omitempty"` + AffectedSystemFunctionId []HvacSystemFunctionIdType `json:"affectedSystemFunctionId,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type HvacOverrunDescriptionDataElementsType struct { + OverrunId *ElementTagType `json:"overrunId,omitempty"` + OverrunType *ElementTagType `json:"overrunType,omitempty"` + AffectedSystemFunctionId *ElementTagType `json:"affectedSystemFunctionId,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type HvacOverrunDescriptionListDataType struct { + HvacOverrunDescriptionData []HvacOverrunDescriptionDataType `json:"hvacOverrunDescriptionData,omitempty"` +} + +type HvacOverrunDescriptionListDataSelectorsType struct { + OverrunId *HvacOverrunIdType `json:"overrunId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/hvac_additions.go b/src/eebus-bridge/third_party/spine-go/model/hvac_additions.go new file mode 100644 index 0000000..d279a65 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/hvac_additions.go @@ -0,0 +1,153 @@ +package model + +// HvacSystemFunctionListDataType + +var _ Updater = (*HvacSystemFunctionListDataType)(nil) + +func (r *HvacSystemFunctionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacSystemFunctionDataType + if newList != nil { + newData = newList.(*HvacSystemFunctionListDataType).HvacSystemFunctionData + } + + data, success := UpdateList(remoteWrite, r.HvacSystemFunctionData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacSystemFunctionData = data + } + + return data, success +} + +// HvacSystemFunctionOperationModeRelationListDataType + +var _ Updater = (*HvacSystemFunctionOperationModeRelationListDataType)(nil) + +func (r *HvacSystemFunctionOperationModeRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacSystemFunctionOperationModeRelationDataType + if newList != nil { + newData = newList.(*HvacSystemFunctionOperationModeRelationListDataType).HvacSystemFunctionOperationModeRelationData + } + + data, success := UpdateList(remoteWrite, r.HvacSystemFunctionOperationModeRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacSystemFunctionOperationModeRelationData = data + } + + return data, success +} + +// HvacSystemFunctionSetpointRelationListDataType + +var _ Updater = (*HvacSystemFunctionSetpointRelationListDataType)(nil) + +func (r *HvacSystemFunctionSetpointRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacSystemFunctionSetpointRelationDataType + if newList != nil { + newData = newList.(*HvacSystemFunctionSetpointRelationListDataType).HvacSystemFunctionSetpointRelationData + } + + data, success := UpdateList(remoteWrite, r.HvacSystemFunctionSetpointRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacSystemFunctionSetpointRelationData = data + } + + return data, success +} + +// HvacSystemFunctionPowerSequenceRelationListDataType + +var _ Updater = (*HvacSystemFunctionPowerSequenceRelationListDataType)(nil) + +func (r *HvacSystemFunctionPowerSequenceRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacSystemFunctionPowerSequenceRelationDataType + if newList != nil { + newData = newList.(*HvacSystemFunctionPowerSequenceRelationListDataType).HvacSystemFunctionPowerSequenceRelationData + } + + data, success := UpdateList(remoteWrite, r.HvacSystemFunctionPowerSequenceRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacSystemFunctionPowerSequenceRelationData = data + } + + return data, success +} + +// HvacSystemFunctionDescriptionListDataType + +var _ Updater = (*HvacSystemFunctionDescriptionListDataType)(nil) + +func (r *HvacSystemFunctionDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacSystemFunctionDescriptionDataType + if newList != nil { + newData = newList.(*HvacSystemFunctionDescriptionListDataType).HvacSystemFunctionDescriptionData + } + + data, success := UpdateList(remoteWrite, r.HvacSystemFunctionDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacSystemFunctionDescriptionData = data + } + + return data, success +} + +// HvacOperationModeDescriptionListDataType + +var _ Updater = (*HvacOperationModeDescriptionListDataType)(nil) + +func (r *HvacOperationModeDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacOperationModeDescriptionDataType + if newList != nil { + newData = newList.(*HvacOperationModeDescriptionListDataType).HvacOperationModeDescriptionData + } + + data, success := UpdateList(remoteWrite, r.HvacOperationModeDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacOperationModeDescriptionData = data + } + + return data, success +} + +// HvacOverrunListDataType + +var _ Updater = (*HvacOverrunListDataType)(nil) + +func (r *HvacOverrunListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacOverrunDataType + if newList != nil { + newData = newList.(*HvacOverrunListDataType).HvacOverrunData + } + + data, success := UpdateList(remoteWrite, r.HvacOverrunData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacOverrunData = data + } + + return data, success +} + +// HvacOverrunDescriptionListDataType + +var _ Updater = (*HvacOverrunDescriptionListDataType)(nil) + +func (r *HvacOverrunDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []HvacOverrunDescriptionDataType + if newList != nil { + newData = newList.(*HvacOverrunDescriptionListDataType).HvacOverrunDescriptionData + } + + data, success := UpdateList(remoteWrite, r.HvacOverrunDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.HvacOverrunDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/identification.go b/src/eebus-bridge/third_party/spine-go/model/identification.go new file mode 100644 index 0000000..6e84329 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/identification.go @@ -0,0 +1,82 @@ +package model + +type IdentificationIdType uint + +type IdentificationTypeType string + +const ( + IdentificationTypeTypeEui48 IdentificationTypeType = "eui48" + IdentificationTypeTypeEui64 IdentificationTypeType = "eui64" + IdentificationTypeTypeUserrfidtag IdentificationTypeType = "userRfidTag" +) + +type IdentificationValueType string + +type SessionIdType uint + +type IdentificationDataType struct { + IdentificationId *IdentificationIdType `json:"identificationId,omitempty" eebus:"key"` + IdentificationType *IdentificationTypeType `json:"identificationType,omitempty"` + IdentificationValue *IdentificationValueType `json:"identificationValue,omitempty"` + Authorized *bool `json:"authorized,omitempty"` +} + +type IdentificationDataElementsType struct { + IdentificationId *ElementTagType `json:"identificationId,omitempty"` + IdentificationType *ElementTagType `json:"identificationType,omitempty"` + IdentificationValue *ElementTagType `json:"identificationValue,omitempty"` + Authorized *ElementTagType `json:"authorized,omitempty"` +} + +type IdentificationListDataType struct { + IdentificationData []IdentificationDataType `json:"identificationData,omitempty"` +} + +type IdentificationListDataSelectorsType struct { + IdentificationId *IdentificationIdType `json:"identificationId,omitempty"` + IdentificationType *IdentificationTypeType `json:"identificationType,omitempty"` +} + +type SessionIdentificationDataType struct { + SessionId *SessionIdType `json:"sessionId,omitempty" eebus:"key"` + IdentificationId *IdentificationIdType `json:"identificationId,omitempty"` + IsLatestSession *bool `json:"isLatestSession,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` +} + +type SessionIdentificationDataElementsType struct { + SessionId *ElementTagType `json:"sessionId,omitempty"` + IdentificationId *ElementTagType `json:"identificationId,omitempty"` + IsLatestSession *ElementTagType `json:"isLatestSession,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` +} + +type SessionIdentificationListDataType struct { + SessionIdentificationData []SessionIdentificationDataType `json:"sessionIdentificationData,omitempty"` +} + +type SessionIdentificationListDataSelectorsType struct { + SessionId *SessionIdType `json:"sessionId,omitempty"` + IdentificationId *IdentificationIdType `json:"identificationId,omitempty"` + IsLatestSession *bool `json:"isLatestSession,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` +} + +type SessionMeasurementRelationDataType struct { + SessionId *SessionIdType `json:"sessionId,omitempty" eebus:"key"` + MeasurementId []MeasurementIdType `json:"measurementId,omitempty"` +} + +type SessionMeasurementRelationDataElementsType struct { + SessionId *ElementTagType `json:"sessionId,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` +} + +type SessionMeasurementRelationListDataType struct { + SessionMeasurementRelationData []SessionMeasurementRelationDataType `json:"sessionMeasurementRelationData,omitempty"` +} + +type SessionMeasurementRelationListDataSelectorsType struct { + SessionId *SessionIdType `json:"sessionId,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/identification_additions.go b/src/eebus-bridge/third_party/spine-go/model/identification_additions.go new file mode 100644 index 0000000..949f335 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/identification_additions.go @@ -0,0 +1,58 @@ +package model + +// IdentificationListDataType + +var _ Updater = (*IdentificationListDataType)(nil) + +func (r *IdentificationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []IdentificationDataType + if newList != nil { + newData = newList.(*IdentificationListDataType).IdentificationData + } + + data, success := UpdateList(remoteWrite, r.IdentificationData, newData, filterPartial, filterDelete) + + if success && persist { + r.IdentificationData = data + } + + return persist, success +} + +// SessionIdentificationListDataType + +var _ Updater = (*SessionIdentificationListDataType)(nil) + +func (r *SessionIdentificationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SessionIdentificationDataType + if newList != nil { + newData = newList.(*SessionIdentificationListDataType).SessionIdentificationData + } + + data, success := UpdateList(remoteWrite, r.SessionIdentificationData, newData, filterPartial, filterDelete) + + if success && persist { + r.SessionIdentificationData = data + } + + return persist, success +} + +// SessionMeasurementRelationListDataType + +var _ Updater = (*SessionMeasurementRelationListDataType)(nil) + +func (r *SessionMeasurementRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SessionMeasurementRelationDataType + if newList != nil { + newData = newList.(*SessionMeasurementRelationListDataType).SessionMeasurementRelationData + } + + data, success := UpdateList(remoteWrite, r.SessionMeasurementRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.SessionMeasurementRelationData = data + } + + return persist, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/incentivetable.go b/src/eebus-bridge/third_party/spine-go/model/incentivetable.go new file mode 100644 index 0000000..c5cacb0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/incentivetable.go @@ -0,0 +1,103 @@ +package model + +type IncentiveTableType struct { + Tariff *TariffDataType `json:"tariff,omitempty"` // ignoring changes + IncentiveSlot []IncentiveTableIncentiveSlotType `json:"incentiveSlot,omitempty"` +} + +type IncentiveTableElementsType struct { + Tariff *TariffDataElementsType `json:"tariff,omitempty"` // ignoring changes + IncentiveSlot *IncentiveTableIncentiveSlotElementsType `json:"incentiveSlot,omitempty"` +} + +type IncentiveTableIncentiveSlotType struct { + TimeInterval *TimeTableDataType `json:"timeInterval,omitempty"` // ignoring changes + Tier []IncentiveTableTierType `json:"tier,omitempty"` +} + +type IncentiveTableIncentiveSlotElementsType struct { + TimeInterval *TimeTableDataElementsType `json:"timeInterval,omitempty"` // ignoring changes + Tier *IncentiveTableTierElementsType `json:"tier,omitempty"` +} + +type IncentiveTableTierType struct { + Tier *TierDataType `json:"tier,omitempty"` // ignoring changes + Boundary []TierBoundaryDataType `json:"boundary,omitempty"` // ignoring changes + Incentive []IncentiveDataType `json:"incentive,omitempty"` // ignoring changes +} + +type IncentiveTableTierElementsType struct { + Tier *TierDataElementsType `json:"tier,omitempty"` // ignoring changes + Boundary *TierBoundaryDataElementsType `json:"boundary,omitempty"` // ignoring changes + Incentive *IncentiveDataElementsType `json:"incentive,omitempty"` // ignoring changes +} + +type IncentiveTableDataType struct { + IncentiveTable []IncentiveTableType `json:"incentiveTable,omitempty"` +} + +type IncentiveTableDataElementsType struct { + IncentiveTable *IncentiveTableElementsType `json:"incentiveTable,omitempty"` +} + +type IncentiveTableDataSelectorsType struct { + Tariff *TariffListDataSelectorsType `json:"tariff,omitempty"` +} + +type IncentiveTableDescriptionType struct { + TariffDescription *TariffDescriptionDataType `json:"tariffDescription,omitempty"` + Tier []IncentiveTableDescriptionTierType `json:"tier,omitempty"` +} + +type IncentiveTableDescriptionElementsType struct { + TariffDescription *TariffDescriptionDataElementsType `json:"tariffDescription,omitempty"` + Tier *IncentiveTableDescriptionTierType `json:"tier,omitempty"` +} + +type IncentiveTableDescriptionTierType struct { + TierDescription *TierDescriptionDataType `json:"tierDescription,omitempty"` + BoundaryDescription []TierBoundaryDescriptionDataType `json:"boundaryDescription,omitempty"` + IncentiveDescription []IncentiveDescriptionDataType `json:"incentiveDescription,omitempty"` +} + +type IncentiveTableDescriptionTierElementsType struct { + TierDescription *TierDescriptionDataElementsType `json:"tierDescription,omitempty"` + BoundaryDescription *TierBoundaryDescriptionDataElementsType `json:"boundaryDescription,omitempty"` + IncentiveDescription *IncentiveDescriptionDataElementsType `json:"incentiveDescription,omitempty"` +} + +type IncentiveTableDescriptionDataType struct { + IncentiveTableDescription []IncentiveTableDescriptionType `json:"incentiveTableDescription,omitempty"` +} + +type IncentiveTableDescriptionDataElementsType struct { + IncentiveTableDescription *IncentiveTableDescriptionElementsType `json:"incentiveTableDescription,omitempty"` +} + +type IncentiveTableDescriptionDataSelectorsType struct { + TariffDescription *TariffDescriptionListDataSelectorsType `json:"tariffDescription,omitempty"` +} + +type IncentiveTableConstraintsType struct { + Tariff *TariffDataType `json:"tariff,omitempty"` + TariffConstraints *TariffOverallConstraintsDataType `json:"tariffConstraints,omitempty"` + IncentiveSlotConstraints *TimeTableConstraintsDataType `json:"incentiveSlotConstraints,omitempty"` +} + +type IncentiveTableConstraintsElementsType struct { + Tariff *TariffDataElementsType `json:"tariff,omitempty"` + TariffConstraints *TariffOverallConstraintsDataElementsType `json:"tariffConstraints,omitempty"` + IncentiveSlotConstraints *TimeTableConstraintsDataElementsType `json:"incentiveSlotConstraints,omitempty"` +} + +type IncentiveTableConstraintsDataType struct { + IncentiveTableConstraints []IncentiveTableConstraintsType `json:"incentiveTableConstraints,omitempty"` +} + +type IncentiveTableConstraintsDataElementsType struct { + IncentiveTableConstraints *IncentiveTableConstraintsElementsType `json:"incentiveTableConstraints,omitempty"` +} + +type IncentiveTableConstraintsDataSelectorsType struct { + Tariff *TariffListDataSelectorsType `json:"tariff,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/loadcontrol.go b/src/eebus-bridge/third_party/spine-go/model/loadcontrol.go new file mode 100644 index 0000000..54ac38c --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/loadcontrol.go @@ -0,0 +1,185 @@ +package model + +type LoadControlEventIdType uint + +type LoadControlEventActionType string + +const ( + LoadControlEventActionTypePause LoadControlEventActionType = "pause" + LoadControlEventActionTypeResume LoadControlEventActionType = "resume" + LoadControlEventActionTypeReduce LoadControlEventActionType = "reduce" + LoadControlEventActionTypeIncrease LoadControlEventActionType = "increase" + LoadControlEventActionTypeEmergency LoadControlEventActionType = "emergency" + LoadControlEventActionTypeNormal LoadControlEventActionType = "normal" +) + +type LoadControlEventStateType string + +const ( + LoadControlEventStateTypeEventAccepted LoadControlEventStateType = "eventAccepted" + LoadControlEventStateTypeEventStarted LoadControlEventStateType = "eventStarted" + LoadControlEventStateTypeEventStopped LoadControlEventStateType = "eventStopped" + LoadControlEventStateTypeEventRejected LoadControlEventStateType = "eventRejected" + LoadControlEventStateTypeEventCancelled LoadControlEventStateType = "eventCancelled" + LoadControlEventStateTypeEventError LoadControlEventStateType = "eventError" +) + +type LoadControlLimitIdType uint + +type LoadControlLimitTypeType string + +const ( + LoadControlLimitTypeTypeMinValueLimit LoadControlLimitTypeType = "minValueLimit" + LoadControlLimitTypeTypeMaxValueLimit LoadControlLimitTypeType = "maxValueLimit" + LoadControlLimitTypeTypeSignDependentAbsValueLimit LoadControlLimitTypeType = "signDependentAbsValueLimit" +) + +type LoadControlCategoryType string + +const ( + LoadControlCategoryTypeObligation LoadControlCategoryType = "obligation" + LoadControlCategoryTypeRecommendation LoadControlCategoryType = "recommendation" + LoadControlCategoryTypeOptimization LoadControlCategoryType = "optimization" +) + +type LoadControlNodeDataType struct { + IsNodeRemoteControllable *bool `json:"isNodeRemoteControllable,omitempty"` +} + +type LoadControlNodeDataElementsType struct { + IsNodeRemoteControllable *ElementTagType `json:"isNodeRemoteControllable,omitempty"` +} + +type LoadControlEventDataType struct { + Timestamp *string `json:"timestamp,omitempty"` + EventId *LoadControlEventIdType `json:"eventId,omitempty" eebus:"key"` + EventActionConsume *LoadControlEventActionType `json:"eventActionConsume,omitempty"` + EventActionProduce *LoadControlEventActionType `json:"eventActionProduce,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` +} + +type LoadControlEventDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + EventId *ElementTagType `json:"eventId,omitempty"` + EventActionConsume *ElementTagType `json:"eventActionConsume,omitempty"` + EventActionProduce *ElementTagType `json:"eventActionProduce,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` +} + +type LoadControlEventListDataType struct { + LoadControlEventData []LoadControlEventDataType `json:"loadControlEventData,omitempty"` +} + +type LoadControlEventListDataSelectorsType struct { + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` + EventId *LoadControlEventIdType `json:"eventId,omitempty"` +} + +type LoadControlStateDataType struct { + Timestamp *string `json:"timestamp"` + EventId *LoadControlEventIdType `json:"eventId,omitempty" eebus:"key"` + EventStateConsume *LoadControlEventStateType `json:"eventStateConsume"` + AppliedEventActionConsume *LoadControlEventActionType `json:"appliedEventActionConsume"` + EventStateProduce *LoadControlEventStateType `json:"eventStateProduce"` + AppliedEventActionProduce *LoadControlEventActionType `json:"appliedEventActionProduce"` +} + +type LoadControlStateDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp"` + EventId *ElementTagType `json:"eventId,omitempty"` + EventStateConsume *ElementTagType `json:"eventStateConsume"` + AppliedEventActionConsume *ElementTagType `json:"appliedEventActionConsume"` + EventStateProduce *ElementTagType `json:"eventStateProduce"` + AppliedEventActionProduce *ElementTagType `json:"appliedEventActionProduce"` +} + +type LoadControlStateListDataType struct { + LoadControlStateData []LoadControlStateDataType `json:"loadControlStateData,omitempty"` +} + +type LoadControlStateListDataSelectorsType struct { + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` + EventId *LoadControlEventIdType `json:"eventId,omitempty"` +} + +type LoadControlLimitDataType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty" eebus:"key"` + IsLimitChangeable *bool `json:"isLimitChangeable,omitempty" eebus:"writecheck"` + IsLimitActive *bool `json:"isLimitActive,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` +} + +type LoadControlLimitDataElementsType struct { + LimitId *ElementTagType `json:"limitId,omitempty"` + IsLimitChangeable *ElementTagType `json:"isLimitChangeable,omitempty"` + IsLimitActive *ElementTagType `json:"isLimitActive,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` +} + +type LoadControlLimitListDataType struct { + LoadControlLimitData []LoadControlLimitDataType `json:"loadControlLimitData,omitempty"` +} + +type LoadControlLimitListDataSelectorsType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty"` +} + +type LoadControlLimitConstraintsDataType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty" eebus:"key"` + ValueRangeMin *ScaledNumberType `json:"valueRangeMin,omitempty"` + ValueRangeMax *ScaledNumberType `json:"valueRangeMax,omitempty"` + ValueStepSize *ScaledNumberType `json:"valueStepSize,omitempty"` +} + +type LoadControlLimitConstraintsDataElementsType struct { + LimitId *ElementTagType `json:"limitId,omitempty"` + ValueRangeMin *ScaledNumberElementsType `json:"valueRangeMin,omitempty"` + ValueRangeMax *ScaledNumberElementsType `json:"valueRangeMax,omitempty"` + ValueStepSize *ScaledNumberElementsType `json:"valueStepSize,omitempty"` +} + +type LoadControlLimitConstraintsListDataType struct { + LoadControlLimitConstraintsData []LoadControlLimitConstraintsDataType `json:"loadControlLimitConstraintsData,omitempty"` +} + +type LoadControlLimitConstraintsListDataSelectorsType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty"` +} + +type LoadControlLimitDescriptionDataType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty" eebus:"key"` + LimitType *LoadControlLimitTypeType `json:"limitType,omitempty"` + LimitCategory *LoadControlCategoryType `json:"limitCategory,omitempty"` + LimitDirection *EnergyDirectionType `json:"limitDirection,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type LoadControlLimitDescriptionDataElementsType struct { + LimitId *ElementTagType `json:"limitId,omitempty"` + LimitType *ElementTagType `json:"limitType,omitempty"` + LimitCategory *ElementTagType `json:"limitCategory,omitempty"` + LimitDirection *ElementTagType `json:"limitDirection,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type LoadControlLimitDescriptionListDataType struct { + LoadControlLimitDescriptionData []LoadControlLimitDescriptionDataType `json:"loadControlLimitDescriptionData,omitempty"` +} + +type LoadControlLimitDescriptionListDataSelectorsType struct { + LimitId *LoadControlLimitIdType `json:"limitId,omitempty"` + LimitType *LoadControlLimitTypeType `json:"limitType,omitempty"` + LimitDirection *EnergyDirectionType `json:"limitDirection,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/loadcontrol_additions.go b/src/eebus-bridge/third_party/spine-go/model/loadcontrol_additions.go new file mode 100644 index 0000000..4c3c385 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/loadcontrol_additions.go @@ -0,0 +1,96 @@ +package model + +// LoadControlEventListDataType + +var _ Updater = (*LoadControlEventListDataType)(nil) + +func (r *LoadControlEventListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []LoadControlEventDataType + if newList != nil { + newData = newList.(*LoadControlEventListDataType).LoadControlEventData + } + + data, success := UpdateList(remoteWrite, r.LoadControlEventData, newData, filterPartial, filterDelete) + + if success && persist { + r.LoadControlEventData = data + } + + return data, success +} + +// LoadControlStateListDataType + +var _ Updater = (*LoadControlStateListDataType)(nil) + +func (r *LoadControlStateListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []LoadControlStateDataType + if newList != nil { + newData = newList.(*LoadControlStateListDataType).LoadControlStateData + } + + data, success := UpdateList(remoteWrite, r.LoadControlStateData, newData, filterPartial, filterDelete) + + if success && persist { + r.LoadControlStateData = data + } + + return data, success +} + +// LoadControlLimitListDataType + +var _ Updater = (*LoadControlLimitListDataType)(nil) + +func (r *LoadControlLimitListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []LoadControlLimitDataType + if newList != nil { + newData = newList.(*LoadControlLimitListDataType).LoadControlLimitData + } + + data, success := UpdateList(remoteWrite, r.LoadControlLimitData, newData, filterPartial, filterDelete) + + if success && persist { + r.LoadControlLimitData = data + } + + return data, success +} + +// LoadControlLimitConstraintsListDataType + +var _ Updater = (*LoadControlLimitConstraintsListDataType)(nil) + +func (r *LoadControlLimitConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []LoadControlLimitConstraintsDataType + if newList != nil { + newData = newList.(*LoadControlLimitConstraintsListDataType).LoadControlLimitConstraintsData + } + + data, success := UpdateList(remoteWrite, r.LoadControlLimitConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.LoadControlLimitConstraintsData = data + } + + return data, success +} + +// LoadControlLimitDescriptionListDataType + +var _ Updater = (*LoadControlLimitDescriptionListDataType)(nil) + +func (r *LoadControlLimitDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []LoadControlLimitDescriptionDataType + if newList != nil { + newData = newList.(*LoadControlLimitDescriptionListDataType).LoadControlLimitDescriptionData + } + + data, success := UpdateList(remoteWrite, r.LoadControlLimitDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.LoadControlLimitDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/measurement.go b/src/eebus-bridge/third_party/spine-go/model/measurement.go new file mode 100644 index 0000000..f018a7e --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/measurement.go @@ -0,0 +1,222 @@ +package model + +type MeasurementIdType uint + +type MeasurementTypeType string + +const ( + MeasurementTypeTypeAcceleration MeasurementTypeType = "acceleration" + MeasurementTypeTypeAngle MeasurementTypeType = "angle" + MeasurementTypeTypeAngularVelocity MeasurementTypeType = "angularVelocity" + MeasurementTypeTypeArea MeasurementTypeType = "area" + MeasurementTypeTypeAtmosphericPressure MeasurementTypeType = "atmosphericPressure" + MeasurementTypeTypeCapacity MeasurementTypeType = "capacity" + MeasurementTypeTypeConcentration MeasurementTypeType = "concentration" + MeasurementTypeTypeCount MeasurementTypeType = "count" + MeasurementTypeTypeCurrent MeasurementTypeType = "current" + MeasurementTypeTypeDensity MeasurementTypeType = "density" + MeasurementTypeTypeDistance MeasurementTypeType = "distance" + MeasurementTypeTypeElectricField MeasurementTypeType = "electricField" + MeasurementTypeTypeEnergy MeasurementTypeType = "energy" + MeasurementTypeTypeForce MeasurementTypeType = "force" + MeasurementTypeTypeFrequency MeasurementTypeType = "frequency" + MeasurementTypeTypeHarmonicDistortion MeasurementTypeType = "harmonicDistortion" + MeasurementTypeTypeHeat MeasurementTypeType = "heat" + MeasurementTypeTypeHeatFlux MeasurementTypeType = "heatFlux" + MeasurementTypeTypeIlluminance MeasurementTypeType = "illuminance" + MeasurementTypeTypeImpulse MeasurementTypeType = "impulse" + MeasurementTypeTypeLevel MeasurementTypeType = "level" + MeasurementTypeTypeMagneticField MeasurementTypeType = "magneticField" + MeasurementTypeTypeMass MeasurementTypeType = "mass" + MeasurementTypeTypeMassFlow MeasurementTypeType = "massFlow" + MeasurementTypeTypeParticles MeasurementTypeType = "particles" + MeasurementTypeTypePercentage MeasurementTypeType = "percentage" + MeasurementTypeTypePower MeasurementTypeType = "power" + MeasurementTypeTypePowerFactor MeasurementTypeType = "powerFactor" + MeasurementTypeTypePressure MeasurementTypeType = "pressure" + MeasurementTypeTypeRadonActivity MeasurementTypeType = "radonActivity" + MeasurementTypeTypeRelativeHumidity MeasurementTypeType = "relativeHumidity" + MeasurementTypeTypeResistance MeasurementTypeType = "resistance" + MeasurementTypeTypeSolarRadiation MeasurementTypeType = "solarRadiation" + MeasurementTypeTypeSpeed MeasurementTypeType = "speed" + MeasurementTypeTypeTemperature MeasurementTypeType = "temperature" + MeasurementTypeTypeTime MeasurementTypeType = "time" + MeasurementTypeTypeTorque MeasurementTypeType = "torque" + MeasurementTypeTypeUnknown MeasurementTypeType = "unknown" + MeasurementTypeTypeVelocity MeasurementTypeType = "velocity" + MeasurementTypeTypeVoltage MeasurementTypeType = "voltage" + MeasurementTypeTypeVolume MeasurementTypeType = "volume" + MeasurementTypeTypeVolumetricFlow MeasurementTypeType = "volumetricFlow" +) + +type MeasurementValueTypeType string + +const ( + MeasurementValueTypeTypeValue MeasurementValueTypeType = "value" + MeasurementValueTypeTypeAverageValue MeasurementValueTypeType = "averageValue" + MeasurementValueTypeTypeMinValue MeasurementValueTypeType = "minValue" + MeasurementValueTypeTypeMaxValue MeasurementValueTypeType = "maxValue" + MeasurementValueTypeTypeStandardDeviation MeasurementValueTypeType = "standardDeviation" +) + +type MeasurementValueSourceType string + +const ( + MeasurementValueSourceTypeMeasuredValue MeasurementValueSourceType = "measuredValue" + MeasurementValueSourceTypeCalculatedValue MeasurementValueSourceType = "calculatedValue" + MeasurementValueSourceTypeEmpiricalValue MeasurementValueSourceType = "empiricalValue" +) + +type MeasurementValueTendencyType string + +const ( + MeasurementValueTendencyTypeRising MeasurementValueTendencyType = "rising" + MeasurementValueTendencyTypeStable MeasurementValueTendencyType = "stable" + MeasurementValueTendencyTypeFalling MeasurementValueTendencyType = "falling" +) + +type MeasurementValueStateType string + +const ( + MeasurementValueStateTypeNormal MeasurementValueStateType = "normal" + MeasurementValueStateTypeOutofrange MeasurementValueStateType = "outOfRange" + MeasurementValueStateTypeError MeasurementValueStateType = "error" +) + +type MeasurementDataType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty" eebus:"key"` + ValueType *MeasurementValueTypeType `json:"valueType,omitempty" eebus:"key"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` + EvaluationPeriod *TimePeriodType `json:"evaluationPeriod,omitempty"` + ValueSource *MeasurementValueSourceType `json:"valueSource,omitempty"` + ValueTendency *MeasurementValueTendencyType `json:"valueTendency,omitempty"` + ValueState *MeasurementValueStateType `json:"valueState,omitempty"` +} + +type MeasurementDataElementsType struct { + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + ValueType *ElementTagType `json:"valueType,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + Value *ElementTagType `json:"value,omitempty"` + EvaluationPeriod *ElementTagType `json:"evaluationPeriod,omitempty"` + ValueSource *ElementTagType `json:"valueSource,omitempty"` + ValueTendency *ElementTagType `json:"valueTendency,omitempty"` + ValueState *ElementTagType `json:"valueState,omitempty"` +} + +type MeasurementListDataType struct { + MeasurementData []MeasurementDataType `json:"measurementData,omitempty"` +} + +type MeasurementListDataSelectorsType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ValueType *MeasurementValueTypeType `json:"valueType,omitempty"` + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` +} + +type MeasurementSeriesDataType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty" eebus:"key"` + ValueType *MeasurementValueTypeType `json:"valueType,omitempty" eebus:"key"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` + EvaluationPeriod *TimePeriodType `json:"evaluationPeriod,omitempty"` + ValueSource *MeasurementValueSourceType `json:"valueSource,omitempty"` + ValueTendency *MeasurementValueTendencyType `json:"valueTendency,omitempty"` + ValueState *MeasurementValueStateType `json:"valueState,omitempty"` +} + +type MeasurementSeriesDataElementsType struct { + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + ValueType *ElementTagType `json:"valueType,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + Value *ElementTagType `json:"value,omitempty"` + EvaluationPeriod *ElementTagType `json:"evaluationPeriod,omitempty"` + ValueSource *ElementTagType `json:"valueSource,omitempty"` + ValueTendency *ElementTagType `json:"valueTendency,omitempty"` + ValueState *ElementTagType `json:"valueState,omitempty"` +} + +type MeasurementSeriesListDataType struct { + MeasurementSeriesData []MeasurementSeriesDataType `json:"measurementSeriesData,omitempty"` +} + +type MeasurementSeriesListDataSelectorsType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ValueType *MeasurementValueTypeType `json:"valueType,omitempty"` + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` +} + +type MeasurementConstraintsDataType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty" eebus:"key"` + ValueRangeMin *ScaledNumberType `json:"valueRangeMin,omitempty"` + ValueRangeMax *ScaledNumberType `json:"valueRangeMax,omitempty"` + ValueStepSize *ScaledNumberType `json:"valueStepSize,omitempty"` +} + +type MeasurementConstraintsDataElementsType struct { + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + ValueRangeMin *ScaledNumberElementsType `json:"valueRangeMin,omitempty"` + ValueRangeMax *ScaledNumberElementsType `json:"valueRangeMax,omitempty"` + ValueStepSize *ScaledNumberElementsType `json:"valueStepSize,omitempty"` +} + +type MeasurementConstraintsListDataType struct { + MeasurementConstraintsData []MeasurementConstraintsDataType `json:"measurementConstraintsData,omitempty"` +} + +type MeasurementConstraintsListDataSelectorsType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` +} + +type MeasurementDescriptionDataType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty" eebus:"key"` + MeasurementType *MeasurementTypeType `json:"measurementType,omitempty"` + CommodityType *CommodityTypeType `json:"commodityType,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + CalibrationValue *ScaledNumberType `json:"calibrationValue,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type MeasurementDescriptionDataElementsType struct { + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + MeasurementType *ElementTagType `json:"measurementType,omitempty"` + CommodityType *ElementTagType `json:"commodityType,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + CalibrationValue *ScaledNumberElementsType `json:"calibrationValue,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type MeasurementDescriptionListDataType struct { + MeasurementDescriptionData []MeasurementDescriptionDataType `json:"measurementDescriptionData,omitempty"` +} + +type MeasurementDescriptionListDataSelectorsType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + MeasurementType *MeasurementTypeType `json:"measurementType,omitempty"` + CommodityType *CommodityTypeType `json:"commodityType,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type MeasurementThresholdRelationDataType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty" eebus:"key"` + ThresholdId []ThresholdIdType `json:"thresholdId,omitempty"` +} + +type MeasurementThresholdRelationDataElementsType struct { + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` +} + +type MeasurementThresholdRelationListDataType struct { + MeasurementThresholdRelationData []MeasurementThresholdRelationDataType `json:"measurementThresholdRelationData,omitempty"` +} + +type MeasurementThresholdRelationListDataSelectorsType struct { + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/measurement_additions.go b/src/eebus-bridge/third_party/spine-go/model/measurement_additions.go new file mode 100644 index 0000000..0b21a73 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/measurement_additions.go @@ -0,0 +1,96 @@ +package model + +// MeasurementListDataType + +var _ Updater = (*MeasurementListDataType)(nil) + +func (r *MeasurementListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MeasurementDataType + if newList != nil { + newData = newList.(*MeasurementListDataType).MeasurementData + } + + data, success := UpdateList(remoteWrite, r.MeasurementData, newData, filterPartial, filterDelete) + + if success && persist { + r.MeasurementData = data + } + + return data, success +} + +// MeasurementSeriesListDataType + +var _ Updater = (*MeasurementSeriesListDataType)(nil) + +func (r *MeasurementSeriesListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MeasurementSeriesDataType + if newList != nil { + newData = newList.(*MeasurementSeriesListDataType).MeasurementSeriesData + } + + data, success := UpdateList(remoteWrite, r.MeasurementSeriesData, newData, filterPartial, filterDelete) + + if success && persist { + r.MeasurementSeriesData = data + } + + return data, success +} + +// MeasurementConstraintsListDataType + +var _ Updater = (*MeasurementConstraintsListDataType)(nil) + +func (r *MeasurementConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MeasurementConstraintsDataType + if newList != nil { + newData = newList.(*MeasurementConstraintsListDataType).MeasurementConstraintsData + } + + data, success := UpdateList(remoteWrite, r.MeasurementConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.MeasurementConstraintsData = data + } + + return data, success +} + +// MeasurementDescriptionListDataType + +var _ Updater = (*MeasurementDescriptionListDataType)(nil) + +func (r *MeasurementDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MeasurementDescriptionDataType + if newList != nil { + newData = newList.(*MeasurementDescriptionListDataType).MeasurementDescriptionData + } + + data, success := UpdateList(remoteWrite, r.MeasurementDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.MeasurementDescriptionData = data + } + + return data, success +} + +// MeasurementThresholdRelationListDataType + +var _ Updater = (*MeasurementThresholdRelationListDataType)(nil) + +func (r *MeasurementThresholdRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MeasurementThresholdRelationDataType + if newList != nil { + newData = newList.(*MeasurementThresholdRelationListDataType).MeasurementThresholdRelationData + } + + data, success := UpdateList(remoteWrite, r.MeasurementThresholdRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.MeasurementThresholdRelationData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/messaging.go b/src/eebus-bridge/third_party/spine-go/model/messaging.go new file mode 100644 index 0000000..07c606d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/messaging.go @@ -0,0 +1,39 @@ +package model + +type MessagingNumberType uint + +type MessagingDataTextType string + +type MessagingTypeType string + +const ( + MessagingTypeTypeLogging MessagingTypeType = "logging" + MessagingTypeTypeInformation MessagingTypeType = "information" + MessagingTypeTypeWarning MessagingTypeType = "warning" + MessagingTypeTypeAlarm MessagingTypeType = "alarm" + MessagingTypeTypeEmergency MessagingTypeType = "emergency" + MessagingTypeTypeObsolete MessagingTypeType = "obsolete" +) + +type MessagingDataType struct { + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + MessagingNumber *MessagingNumberType `json:"messagingNumber,omitempty" eebus:"key"` + MessagingType *MessagingTypeType `json:"type,omitempty"` // xsd defines "type", but that is a reserved keyword + Text *MessagingDataTextType `json:"text,omitempty"` +} + +type MessagingDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + MessagingNumber *ElementTagType `json:"messagingNumber,omitempty"` + MessagingType *ElementTagType `json:"type,omitempty"` + Text *ElementTagType `json:"text,omitempty"` +} + +type MessagingListDataType struct { + MessagingData []MessagingDataType `json:"messagingData,omitempty"` +} + +type MessagingListDataSelectorsType struct { + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` + MessagingNumber *MessagingNumberType `json:"messagingNumber,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/messaging_additions.go b/src/eebus-bridge/third_party/spine-go/model/messaging_additions.go new file mode 100644 index 0000000..e486112 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/messaging_additions.go @@ -0,0 +1,20 @@ +package model + +// MessagingListDataType + +var _ Updater = (*MessagingListDataType)(nil) + +func (r *MessagingListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []MessagingDataType + if newList != nil { + newData = newList.(*MessagingListDataType).MessagingData + } + + data, success := UpdateList(remoteWrite, r.MessagingData, newData, filterPartial, filterDelete) + + if success && persist { + r.MessagingData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/networkmanagement.go b/src/eebus-bridge/third_party/spine-go/model/networkmanagement.go new file mode 100644 index 0000000..2d3457f --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/networkmanagement.go @@ -0,0 +1,239 @@ +package model + +type NetworkManagementNativeSetupType string + +type NetworkManagementScanSetupType string + +type NetworkManagementSetupType string + +type NetworkManagementCandidateSetupType string + +type NetworkManagementTechnologyAddressType string + +type NetworkManagementCommunicationsTechnologyInformationType string + +type NetworkManagementMinimumTrustLevelType string + +type NetworkManagementProcessTimeoutType DurationType + +type NetworkManagementFeatureSetType string + +const ( + NetworkManagementFeatureSetTypeGateway NetworkManagementFeatureSetType = "gateway" + NetworkManagementFeatureSetTypeRouter NetworkManagementFeatureSetType = "router" + NetworkManagementFeatureSetTypeSmart NetworkManagementFeatureSetType = "smart" + NetworkManagementFeatureSetTypeSimple NetworkManagementFeatureSetType = "simple" +) + +type NetworkManagementProcessStateStateType string + +const ( + NetworkManagementProcessStateStateTypeSucceeded NetworkManagementProcessStateStateType = "succeeded" + NetworkManagementProcessStateStateTypeFailed NetworkManagementProcessStateStateType = "failed" + NetworkManagementProcessStateStateTypeAborted NetworkManagementProcessStateStateType = "aborted" +) + +type NetworkManagementStateChangeType string + +const ( + NetworkManagementStateChangeTypeAdded NetworkManagementStateChangeType = "added" + NetworkManagementStateChangeTypeRemoved NetworkManagementStateChangeType = "removed" + NetworkManagementStateChangeTypeModified NetworkManagementStateChangeType = "modified" +) + +type NetworkManagementAddNodeCallType struct { + NodeAddress *FeatureAddressType `json:"nodeAddress,omitempty"` + NativeSetup *NetworkManagementNativeSetupType `json:"nativeSetup,omitempty"` + Timeout *NetworkManagementProcessTimeoutType `json:"timeout,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementAddNodeCallElementsType struct { + NodeAddress *FeatureAddressElementsType `json:"nodeAddress,omitempty"` + NativeSetup *ElementTagType `json:"nativeSetup,omitempty"` + Timeout *ElementTagType `json:"timeout,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementRemoveNodeCallType struct { + NodeAddress *FeatureAddressType `json:"nodeAddress,omitempty"` + Timeout *NetworkManagementProcessTimeoutType `json:"timeout,omitempty"` +} + +type NetworkManagementRemoveNodeCallElementsType struct { + NodeAddress *FeatureAddressElementsType `json:"nodeAddress,omitempty"` + Timeout *ElementTagType `json:"timeout,omitempty"` +} + +type NetworkManagementModifyNodeCallType struct { + NodeAddress *FeatureAddressType `json:"nodeAddress,omitempty"` + NativeSetup *NetworkManagementNativeSetupType `json:"nativeSetup,omitempty"` + Timeout *NetworkManagementProcessTimeoutType `json:"timeout,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementModifyNodeCallElementsType struct { + NodeAddress *FeatureAddressElementsType `json:"nodeAddress,omitempty"` + NativeSetup *ElementTagType `json:"nativeSetup,omitempty"` + Timeout *ElementTagType `json:"timeout,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementScanNetworkCallType struct { + ScanSetup *NetworkManagementScanSetupType `json:"scanSetup,omitempty"` + Timeout *NetworkManagementProcessTimeoutType `json:"timeout,omitempty"` +} + +type NetworkManagementScanNetworkCallElementsType struct { + ScanSetup *ElementTagType `json:"scanSetup,omitempty"` + Timeout *ElementTagType `json:"timeout,omitempty"` +} + +type NetworkManagementDiscoverCallType struct { + DiscoverAddress *FeatureAddressType `json:"discoverAddress,omitempty"` +} + +type NetworkManagementDiscoverCallElementsType struct { + DiscoverAddress *FeatureAddressElementsType `json:"discoverAddress,omitempty"` +} + +type NetworkManagementAbortCallType struct{} + +type NetworkManagementAbortCallElementsType struct{} + +type NetworkManagementProcessStateDataType struct { + State *NetworkManagementProcessStateStateType `json:"state,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementProcessStateDataElementsType struct { + State *ElementTagType `json:"state,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementJoiningModeDataType struct { + Setup *NetworkManagementSetupType `json:"setup,omitempty"` +} + +type NetworkManagementJoiningModeDataElementsType struct { + Setup *ElementTagType `json:"setup,omitempty"` +} + +type NetworkManagementReportCandidateDataType struct { + CandidateSetup *NetworkManagementCandidateSetupType `json:"candidateSetup,omitempty"` + SetupUsableForAdd *bool `json:"setupUsableForAdd,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementReportCandidateDataElementsType struct { + CandidateSetup *ElementTagType `json:"candidateSetup,omitempty"` + SetupUsableForAdd *ElementTagType `json:"setupUsableForAdd,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementDeviceDescriptionDataType struct { + DeviceAddress *DeviceAddressType `json:"deviceAddress,omitempty" eebus:"key"` + DeviceType *DeviceTypeType `json:"deviceType,omitempty"` + NetworkManagementResponsibleAddress *FeatureAddressType `json:"networkManagementResponsibleAddress,omitempty"` + NativeSetup *NetworkManagementNativeSetupType `json:"nativeSetup,omitempty"` + TechnologyAddress *NetworkManagementTechnologyAddressType `json:"technologyAddress,omitempty"` + CommunicationsTechnologyInformation *NetworkManagementCommunicationsTechnologyInformationType `json:"communicationsTechnologyInformation,omitempty"` + NetworkFeatureSet *NetworkManagementFeatureSetType `json:"networkFeatureSet,omitempty"` + LastStateChange *NetworkManagementStateChangeType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *NetworkManagementMinimumTrustLevelType `json:"minimumTrustLevel,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementDeviceDescriptionDataElementsType struct { + DeviceAddress *ElementTagType `json:"deviceAddress,omitempty"` + DeviceType *ElementTagType `json:"deviceType,omitempty"` + NetworkManagementResponsibleAddress *ElementTagType `json:"networkManagementResponsibleAddress,omitempty"` + NativeSetup *ElementTagType `json:"nativeSetup,omitempty"` + TechnologyAddress *ElementTagType `json:"technologyAddress,omitempty"` + CommunicationsTechnologyInformation *ElementTagType `json:"communicationsTechnologyInformation,omitempty"` + NetworkFeatureSet *ElementTagType `json:"networkFeatureSet,omitempty"` + LastStateChange *ElementTagType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *ElementTagType `json:"minimumTrustLevel,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementDeviceDescriptionListDataType struct { + NetworkManagementDeviceDescriptionData []NetworkManagementDeviceDescriptionDataType `json:"networkManagementDeviceDescriptionData,omitempty"` +} + +type NetworkManagementDeviceDescriptionListDataSelectorsType struct { + DeviceAddress *DeviceAddressType `json:"deviceAddress,omitempty"` + DeviceType *DeviceTypeType `json:"deviceType,omitempty"` +} + +type NetworkManagementEntityDescriptionDataType struct { + EntityAddress *EntityAddressType `json:"entityAddress,omitempty" eebus:"key"` + EntityType *EntityTypeType `json:"entityType,omitempty"` + LastStateChange *NetworkManagementStateChangeType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *NetworkManagementMinimumTrustLevelType `json:"minimumTrustLevel,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type NetworkManagementEntityDescriptionDataElementsType struct { + EntityAddress *ElementTagType `json:"entityAddress,omitempty"` + EntityType *ElementTagType `json:"entityType,omitempty"` + LastStateChange *ElementTagType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *ElementTagType `json:"minimumTrustLevel,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type NetworkManagementEntityDescriptionListDataType struct { + NetworkManagementEntityDescriptionData []NetworkManagementEntityDescriptionDataType `json:"networkManagementEntityDescriptionData,omitempty"` +} + +type NetworkManagementEntityDescriptionListDataSelectorsType struct { + EntityAddress *EntityAddressType `json:"entityAddress,omitempty"` + EntityType *EntityTypeType `json:"entityType,omitempty"` +} + +type NetworkManagementFeatureDescriptionDataType struct { + FeatureAddress *FeatureAddressType `json:"featureAddress,omitempty" eebus:"key"` + FeatureType *FeatureTypeType `json:"featureType,omitempty"` + SpecificUsage []FeatureSpecificUsageType `json:"specificUsage,omitempty"` + FeatureGroup *FeatureGroupType `json:"featureGroup,omitempty"` + Role *RoleType `json:"role,omitempty"` + SupportedFunction []FunctionPropertyType `json:"supportedFunction,omitempty"` + LastStateChange *NetworkManagementStateChangeType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *NetworkManagementMinimumTrustLevelType `json:"minimumTrustLevel,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` + MaxResponseDelay *MaxResponseDelayType `json:"maxResponseDelay,omitempty"` +} + +type NetworkManagementFeatureDescriptionDataElementsType struct { + FeatureAddress *FeatureAddressElementsType `json:"featureAddress,omitempty"` + FeatureType *ElementTagType `json:"featureType,omitempty"` + SpecificUsage *ElementTagType `json:"specificUsage,omitempty"` + FeatureGroup *ElementTagType `json:"featureGroup,omitempty"` + Role *ElementTagType `json:"role,omitempty"` + SupportedFunction *FunctionPropertyElementsType `json:"supportedFunction,omitempty"` + LastStateChange *ElementTagType `json:"lastStateChange,omitempty"` + MinimumTrustLevel *ElementTagType `json:"minimumTrustLevel,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + MaxResponseDelay *ElementTagType `json:"maxResponseDelay,omitempty"` +} + +type NetworkManagementFeatureDescriptionListDataType struct { + NetworkManagementFeatureDescriptionData []NetworkManagementFeatureDescriptionDataType `json:"networkManagementFeatureDescriptionData,omitempty"` +} + +type NetworkManagementFeatureDescriptionListDataSelectorsType struct { + FeatureAddress *FeatureAddressType `json:"featureAddress,omitempty"` + FeatureType *FeatureTypeType `json:"featureType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/networkmanagement_additions.go b/src/eebus-bridge/third_party/spine-go/model/networkmanagement_additions.go new file mode 100644 index 0000000..74ba95c --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/networkmanagement_additions.go @@ -0,0 +1,58 @@ +package model + +// NetworkManagementDeviceDescriptionListDataType + +var _ Updater = (*NetworkManagementDeviceDescriptionListDataType)(nil) + +func (r *NetworkManagementDeviceDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []NetworkManagementDeviceDescriptionDataType + if newList != nil { + newData = newList.(*NetworkManagementDeviceDescriptionListDataType).NetworkManagementDeviceDescriptionData + } + + data, success := UpdateList(remoteWrite, r.NetworkManagementDeviceDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.NetworkManagementDeviceDescriptionData = data + } + + return data, success +} + +// NetworkManagementEntityDescriptionListDataType + +var _ Updater = (*NetworkManagementEntityDescriptionListDataType)(nil) + +func (r *NetworkManagementEntityDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []NetworkManagementEntityDescriptionDataType + if newList != nil { + newData = newList.(*NetworkManagementEntityDescriptionListDataType).NetworkManagementEntityDescriptionData + } + + data, success := UpdateList(remoteWrite, r.NetworkManagementEntityDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.NetworkManagementEntityDescriptionData = data + } + + return data, success +} + +// NetworkManagementFeatureDescriptionListDataType + +var _ Updater = (*NetworkManagementFeatureDescriptionListDataType)(nil) + +func (r *NetworkManagementFeatureDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []NetworkManagementFeatureDescriptionDataType + if newList != nil { + newData = newList.(*NetworkManagementFeatureDescriptionListDataType).NetworkManagementFeatureDescriptionData + } + + data, success := UpdateList(remoteWrite, r.NetworkManagementFeatureDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.NetworkManagementFeatureDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/nodemanagement.go b/src/eebus-bridge/third_party/spine-go/model/nodemanagement.go new file mode 100644 index 0000000..afbd6e4 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/nodemanagement.go @@ -0,0 +1,136 @@ +package model + +type NodeManagementSpecificationVersionListType struct { + SpecificationVersion []SpecificationVersionDataType `json:"specificationVersion,omitempty"` +} +type NodeManagementSpecificationVersionListElementsType struct { + SpecificationVersion *SpecificationVersionDataElementsType `json:"specificationVersion,omitempty"` +} + +type NodeManagementDetailedDiscoveryDeviceInformationType struct { + Description *NetworkManagementDeviceDescriptionDataType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryDeviceInformationElementsType struct { + Description *NetworkManagementDeviceDescriptionDataElementsType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryEntityInformationType struct { + Description *NetworkManagementEntityDescriptionDataType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryEntityInformationElementsType struct { + Description *NetworkManagementEntityDescriptionDataElementsType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryFeatureInformationType struct { + Description *NetworkManagementFeatureDescriptionDataType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryFeatureInformationElementsType struct { + Description *NetworkManagementFeatureDescriptionDataElementsType `json:"description,omitempty"` +} + +type NodeManagementDetailedDiscoveryDataType struct { + SpecificationVersionList *NodeManagementSpecificationVersionListType `json:"specificationVersionList,omitempty"` + DeviceInformation *NodeManagementDetailedDiscoveryDeviceInformationType `json:"deviceInformation,omitempty"` + EntityInformation []NodeManagementDetailedDiscoveryEntityInformationType `json:"entityInformation,omitempty"` + FeatureInformation []NodeManagementDetailedDiscoveryFeatureInformationType `json:"featureInformation,omitempty"` +} + +type NodeManagementDetailedDiscoveryDataElementsType struct { + SpecificationVersionList *NodeManagementSpecificationVersionListElementsType `json:"specificationVersionList,omitempty"` + DeviceInformation *NodeManagementDetailedDiscoveryDeviceInformationElementsType `json:"deviceInformation,omitempty"` + EntityInformation *NodeManagementDetailedDiscoveryEntityInformationElementsType `json:"entityInformation,omitempty"` + FeatureInformation *NodeManagementDetailedDiscoveryFeatureInformationElementsType `json:"featureInformation,omitempty"` +} + +type NodeManagementDetailedDiscoveryDataSelectorsType struct { + DeviceInformation *NetworkManagementDeviceDescriptionListDataSelectorsType `json:"deviceInformation,omitempty"` + EntityInformation *NetworkManagementEntityDescriptionListDataSelectorsType `json:"entityInformation,omitempty"` + FeatureInformation *NetworkManagementFeatureDescriptionListDataSelectorsType `json:"featureInformation,omitempty"` +} + +type NodeManagementBindingDataType struct { + BindingEntry []BindingManagementEntryDataType `json:"bindingEntry,omitempty"` +} + +type NodeManagementBindingDataElementsType struct { + BindingEntry *BindingManagementEntryDataElementsType `json:"bindingEntry,omitempty"` +} + +type NodeManagementBindingDataSelectorsType struct { + BindingEntry *BindingManagementEntryListDataSelectorsType `json:"bindingEntry,omitempty"` +} + +type NodeManagementBindingRequestCallType struct { + BindingRequest *BindingManagementRequestCallType `json:"bindingRequest,omitempty"` +} + +type NodeManagementBindingRequestCallElementsType struct { + BindingRequest *BindingManagementRequestCallElementsType `json:"bindingRequest,omitempty"` +} + +type NodeManagementBindingDeleteCallType struct { + BindingDelete *BindingManagementDeleteCallType `json:"bindingDelete,omitempty"` +} + +type NodeManagementBindingDeleteCallElementsType struct { + BindingDelete *BindingManagementDeleteCallElementsType `json:"bindingDelete,omitempty"` +} + +type NodeManagementSubscriptionDataType struct { + SubscriptionEntry []SubscriptionManagementEntryDataType `json:"subscriptionEntry,omitempty"` +} + +type NodeManagementSubscriptionDataElementsType struct { + SubscriptionEntry *SubscriptionManagementEntryDataElementsType `json:"subscriptionEntry,omitempty"` +} + +type NodeManagementSubscriptionDataSelectorsType struct { + SubscriptionEntry *SubscriptionManagementEntryListDataSelectorsType `json:"subscriptionEntry,omitempty"` +} + +type NodeManagementSubscriptionRequestCallType struct { + SubscriptionRequest *SubscriptionManagementRequestCallType `json:"subscriptionRequest,omitempty"` +} + +type NodeManagementSubscriptionRequestCallElementsType struct { + SubscriptionRequest *SubscriptionManagementRequestCallElementsType `json:"subscriptionRequest,omitempty"` +} + +type NodeManagementSubscriptionDeleteCallType struct { + SubscriptionDelete *SubscriptionManagementDeleteCallType `json:"subscriptionDelete,omitempty"` +} + +type NodeManagementSubscriptionDeleteCallElementsType struct { + SubscriptionDelete *SubscriptionManagementDeleteCallElementsType `json:"subscriptionDelete,omitempty"` +} + +type NodeManagementDestinationDataType struct { + DeviceDescription *NetworkManagementDeviceDescriptionDataType `json:"deviceDescription,omitempty"` +} + +type NodeManagementDestinationDataElementsType struct { + DeviceDescription *NetworkManagementDeviceDescriptionDataElementsType `json:"deviceDescription,omitempty"` +} + +type NodeManagementDestinationListDataType struct { + NodeManagementDestinationData []NodeManagementDestinationDataType `json:"nodeManagementDestinationData,omitempty"` +} + +type NodeManagementDestinationListDataSelectorsType struct { + DeviceDescription *NetworkManagementDeviceDescriptionListDataSelectorsType `json:"deviceDescription,omitempty"` +} + +type NodeManagementUseCaseDataType struct { + UseCaseInformation []UseCaseInformationDataType `json:"useCaseInformation,omitempty"` +} + +type NodeManagementUseCaseDataElementsType struct { + UseCaseInformation *UseCaseInformationDataElementsType `json:"useCaseInformation,omitempty"` +} + +type NodeManagementUseCaseDataSelectorsType struct { + UseCaseInformation *UseCaseInformationListDataSelectorsType `json:"useCaseInformation,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/nodemanagement_additions.go b/src/eebus-bridge/third_party/spine-go/model/nodemanagement_additions.go new file mode 100644 index 0000000..b15baa1 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/nodemanagement_additions.go @@ -0,0 +1,204 @@ +package model + +import ( + "reflect" + "sync" + + "github.com/enbility/spine-go/util" +) + +var nmMux sync.Mutex + +// NodeManagementDestinationListDataType + +var _ Updater = (*NodeManagementDestinationListDataType)(nil) + +func (r *NodeManagementDestinationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []NodeManagementDestinationDataType + if newList != nil { + newData = newList.(*NodeManagementDestinationListDataType).NodeManagementDestinationData + } + + data, success := UpdateList(remoteWrite, r.NodeManagementDestinationData, newData, filterPartial, filterDelete) + + if success && persist { + r.NodeManagementDestinationData = data + } + + return data, success +} + +// NodeManagementUseCaseDataType + +// find the matching UseCaseInformation index for +// a given FeatureAddressType, UseCaseActorType and UseCaseNameType +// +// if UseCaseActorType and UseCaseNameType are empty they are ignored, +// and the first matching UseCaseInformation item is returned +func (n *NodeManagementUseCaseDataType) useCaseInformationIndex( + address FeatureAddressType, + actor UseCaseActorType, + useCaseName UseCaseNameType, +) (int, bool) { + // get the element with the same entity + for index, item := range n.UseCaseInformation { + if item.Address.Device == nil || + item.Address.Entity == nil || + !reflect.DeepEqual(item.Address.Device, address.Device) || + !reflect.DeepEqual(item.Address.Entity, address.Entity) { + continue + } + + if len(actor) == 0 && len(useCaseName) == 0 { + return index, true + } + + if len(actor) > 0 { + if item.Actor == nil || *item.Actor != actor { + continue + } + } + + if len(useCaseName) == 0 { + return index, true + } + + if _, ok := item.useCaseSupportIndex(useCaseName); ok { + return index, true + } + } + + return -1, false +} + +// add a new UseCaseSupportType +func (n *NodeManagementUseCaseDataType) AddUseCaseSupport( + address FeatureAddressType, + actor UseCaseActorType, + useCaseName UseCaseNameType, + useCaseVersion SpecificationVersionType, + useCaseDocumemtSubRevision string, + useCaseAvailable bool, + scenarios []UseCaseScenarioSupportType, +) { + nmMux.Lock() + defer nmMux.Unlock() + + useCaseSupport := UseCaseSupportType{ + UseCaseName: &useCaseName, + UseCaseVersion: &useCaseVersion, + UseCaseAvailable: &useCaseAvailable, + ScenarioSupport: scenarios, + UseCaseDocumentSubRevision: &useCaseDocumemtSubRevision, + } + + // is there an entry for the entity address and actor + usecaseIndex, ok := n.useCaseInformationIndex(address, actor, "") + + if ok { + n.UseCaseInformation[usecaseIndex].Add(useCaseSupport) + } else { + // create a new element for this entity + useCaseInformation := UseCaseInformationDataType{ + Address: &FeatureAddressType{ + Device: address.Device, + Entity: address.Entity, + }, + Actor: &actor, + UseCaseSupport: []UseCaseSupportType{useCaseSupport}, + } + n.UseCaseInformation = append(n.UseCaseInformation, useCaseInformation) + } +} + +func (n *NodeManagementUseCaseDataType) HasUseCaseSupport( + address FeatureAddressType, + actor UseCaseActorType, + useCaseName UseCaseNameType) bool { + nmMux.Lock() + defer nmMux.Unlock() + + // is there an entry for the entity address, actor and usecase name + _, ok := n.useCaseInformationIndex(address, actor, useCaseName) + return ok +} + +// Set the availability of a usecase +func (n *NodeManagementUseCaseDataType) SetAvailability( + address FeatureAddressType, + actor UseCaseActorType, + useCaseName UseCaseNameType, + availability bool, +) { + nmMux.Lock() + defer nmMux.Unlock() + + // is there an entry for the entity address, actor and usecase name + usecaseIndex, ok := n.useCaseInformationIndex(address, actor, useCaseName) + if !ok { + return + } + + useCaseInformation := n.UseCaseInformation[usecaseIndex] + for index, item := range useCaseInformation.UseCaseSupport { + if item.UseCaseName != nil && *item.UseCaseName == useCaseName { + n.UseCaseInformation[usecaseIndex].UseCaseSupport[index].UseCaseAvailable = util.Ptr(availability) + + return + } + } +} + +// Remove a UseCaseSupportType with +// a provided FeatureAddressType, UseCaseActorType and UseCaseNameType +func (n *NodeManagementUseCaseDataType) RemoveUseCaseSupport( + address FeatureAddressType, + actor UseCaseActorType, + useCaseName UseCaseNameType, +) { + nmMux.Lock() + defer nmMux.Unlock() + + // is there an entry for the entity address, actor and usecase name + usecaseIndex, ok := n.useCaseInformationIndex(address, actor, useCaseName) + if !ok { + return + } + + var usecaseInfo []UseCaseInformationDataType + + for index, item := range n.UseCaseInformation { + if index != usecaseIndex { + usecaseInfo = append(usecaseInfo, item) + continue + } + + item.Remove(useCaseName) + + // only add the item if there are any usecases left + if len(item.UseCaseSupport) == 0 { + continue + } + + usecaseInfo = append(usecaseInfo, item) + } + + n.UseCaseInformation = usecaseInfo +} + +// Remove all data for a given address type +func (n *NodeManagementUseCaseDataType) RemoveUseCaseDataForAddress(address FeatureAddressType) { + nmMux.Lock() + defer nmMux.Unlock() + + var usecaseInfo []UseCaseInformationDataType + + for _, item := range n.UseCaseInformation { + if !reflect.DeepEqual(item.Address, &address) { + usecaseInfo = append(usecaseInfo, item) + continue + } + } + + n.UseCaseInformation = usecaseInfo +} diff --git a/src/eebus-bridge/third_party/spine-go/model/operatingconstraints.go b/src/eebus-bridge/third_party/spine-go/model/operatingconstraints.go new file mode 100644 index 0000000..5d76048 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/operatingconstraints.go @@ -0,0 +1,143 @@ +package model + +type OperatingConstraintsInterruptDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + IsPausable *bool `json:"isPausable,omitempty"` + IsStoppable *bool `json:"isStoppable,omitempty"` + NotInterruptibleAtHighPower *bool `json:"notInterruptibleAtHighPower,omitempty"` + MaxCyclesPerDay *uint `json:"maxCyclesPerDay,omitempty"` +} + +type OperatingConstraintsInterruptDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + IsPausable *ElementTagType `json:"isPausable,omitempty"` + IsStoppable *ElementTagType `json:"isStoppable,omitempty"` + NotInterruptibleAtHighPower *ElementTagType `json:"notInterruptibleAtHighPower,omitempty"` + MaxCyclesPerDay *ElementTagType `json:"maxCyclesPerDay,omitempty"` +} + +type OperatingConstraintsInterruptListDataType struct { + OperatingConstraintsInterruptData []OperatingConstraintsInterruptDataType `json:"operatingConstraintsInterruptData,omitempty"` +} + +type OperatingConstraintsInterruptListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type OperatingConstraintsDurationDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + ActiveDurationMin *DurationType `json:"activeDurationMin,omitempty"` + ActiveDurationMax *DurationType `json:"activeDurationMax,omitempty"` + PauseDurationMin *DurationType `json:"pauseDurationMin,omitempty"` + PauseDurationMax *DurationType `json:"pauseDurationMax,omitempty"` + ActiveDurationSumMin *DurationType `json:"activeDurationSumMin,omitempty"` + ActiveDurationSumMax *DurationType `json:"activeDurationSumMax,omitempty"` +} + +type OperatingConstraintsDurationDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + ActiveDurationMin *ElementTagType `json:"activeDurationMin,omitempty"` + ActiveDurationMax *ElementTagType `json:"activeDurationMax,omitempty"` + PauseDurationMin *ElementTagType `json:"pauseDurationMin,omitempty"` + PauseDurationMax *ElementTagType `json:"pauseDurationMax,omitempty"` + ActiveDurationSumMin *ElementTagType `json:"activeDurationSumMin,omitempty"` + ActiveDurationSumMax *ElementTagType `json:"activeDurationSumMax,omitempty"` +} + +type OperatingConstraintsDurationListDataType struct { + OperatingConstraintsDurationData []OperatingConstraintsDurationDataType `json:"operatingConstraintsDurationData,omitempty"` +} + +type OperatingConstraintsDurationListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type OperatingConstraintsPowerDescriptionDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *UnitOfMeasurementType `json:"powerUnit,omitempty"` + EnergyUnit *UnitOfMeasurementType `json:"energyUnit,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type OperatingConstraintsPowerDescriptionDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *ElementTagType `json:"powerUnit,omitempty"` + EnergyUnit *ElementTagType `json:"energyUnit,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type OperatingConstraintsPowerDescriptionListDataType struct { + OperatingConstraintsPowerDescriptionData []OperatingConstraintsPowerDescriptionDataType `json:"operatingConstraintsPowerDescriptionData,omitempty"` +} + +type OperatingConstraintsPowerDescriptionListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type OperatingConstraintsPowerRangeDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + PowerMin *ScaledNumberType `json:"powerMin,omitempty"` + PowerMax *ScaledNumberType `json:"powerMax,omitempty"` + EnergyMin *ScaledNumberType `json:"energyMin,omitempty"` + EnergyMax *ScaledNumberType `json:"energyMax,omitempty"` +} + +type OperatingConstraintsPowerRangeDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + PowerMin *ElementTagType `json:"powerMin,omitempty"` + PowerMax *ElementTagType `json:"powerMax,omitempty"` + EnergyMin *ElementTagType `json:"energyMin,omitempty"` + EnergyMax *ElementTagType `json:"energyMax,omitempty"` +} + +type OperatingConstraintsPowerRangeListDataType struct { + OperatingConstraintsPowerRangeData []OperatingConstraintsPowerRangeDataType `json:"operatingConstraintsPowerRangeData,omitempty"` +} + +type OperatingConstraintsPowerRangeListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type OperatingConstraintsPowerLevelDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + Power *ScaledNumberType `json:"power,omitempty"` +} + +type OperatingConstraintsPowerLevelDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + Power *ElementTagType `json:"power,omitempty"` +} + +type OperatingConstraintsPowerLevelListDataType struct { + OperatingConstraintsPowerLevelData []OperatingConstraintsPowerLevelDataType `json:"operatingConstraintsPowerLevelData,omitempty"` +} + +type OperatingConstraintsPowerLevelListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type OperatingConstraintsResumeImplicationDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + ResumeEnergyEstimated *ScaledNumberType `json:"resumeEnergyEstimated,omitempty"` + EnergyUnit *UnitOfMeasurementType `json:"energyUnit,omitempty"` + ResumeCostEstimated *ScaledNumberType `json:"resumeCostEstimated,omitempty"` + Currency *CurrencyType `json:"currency,omitempty"` +} + +type OperatingConstraintsResumeImplicationDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + ResumeEnergyEstimated *ScaledNumberElementsType `json:"resumeEnergyEstimated,omitempty"` + EnergyUnit *ElementTagType `json:"energyUnit,omitempty"` + ResumeCostEstimated *ScaledNumberElementsType `json:"resumeCostEstimated,omitempty"` + Currency *ElementTagType `json:"currency,omitempty"` +} + +type OperatingConstraintsResumeImplicationListDataType struct { + OperatingConstraintsResumeImplicationData []OperatingConstraintsResumeImplicationDataType `json:"operatingConstraintsResumeImplicationData,omitempty"` +} + +type OperatingConstraintsResumeImplicationListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/operatingconstraints_additions.go b/src/eebus-bridge/third_party/spine-go/model/operatingconstraints_additions.go new file mode 100644 index 0000000..ce2347f --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/operatingconstraints_additions.go @@ -0,0 +1,115 @@ +package model + +// OperatingConstraintsInterruptListDataType + +var _ Updater = (*OperatingConstraintsInterruptListDataType)(nil) + +func (r *OperatingConstraintsInterruptListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsInterruptDataType + if newList != nil { + newData = newList.(*OperatingConstraintsInterruptListDataType).OperatingConstraintsInterruptData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsInterruptData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsInterruptData = data + } + + return data, success +} + +// OperatingConstraintsDurationListDataType + +var _ Updater = (*OperatingConstraintsDurationListDataType)(nil) + +func (r *OperatingConstraintsDurationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsDurationDataType + if newList != nil { + newData = newList.(*OperatingConstraintsDurationListDataType).OperatingConstraintsDurationData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsDurationData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsDurationData = data + } + + return data, success +} + +// OperatingConstraintsPowerDescriptionListDataType + +var _ Updater = (*OperatingConstraintsPowerDescriptionListDataType)(nil) + +func (r *OperatingConstraintsPowerDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsPowerDescriptionDataType + if newList != nil { + newData = newList.(*OperatingConstraintsPowerDescriptionListDataType).OperatingConstraintsPowerDescriptionData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsPowerDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsPowerDescriptionData = data + } + + return data, success +} + +// OperatingConstraintsPowerRangeListDataType + +var _ Updater = (*OperatingConstraintsPowerRangeListDataType)(nil) + +func (r *OperatingConstraintsPowerRangeListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsPowerRangeDataType + if newList != nil { + newData = newList.(*OperatingConstraintsPowerRangeListDataType).OperatingConstraintsPowerRangeData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsPowerRangeData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsPowerRangeData = data + } + + return data, success +} + +// OperatingConstraintsPowerLevelListDataType + +var _ Updater = (*OperatingConstraintsPowerLevelListDataType)(nil) + +func (r *OperatingConstraintsPowerLevelListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsPowerLevelDataType + if newList != nil { + newData = newList.(*OperatingConstraintsPowerLevelListDataType).OperatingConstraintsPowerLevelData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsPowerLevelData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsPowerLevelData = data + } + + return data, success +} + +// OperatingConstraintsResumeImplicationListDataType + +var _ Updater = (*OperatingConstraintsResumeImplicationListDataType)(nil) + +func (r *OperatingConstraintsResumeImplicationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []OperatingConstraintsResumeImplicationDataType + if newList != nil { + newData = newList.(*OperatingConstraintsResumeImplicationListDataType).OperatingConstraintsResumeImplicationData + } + + data, success := UpdateList(remoteWrite, r.OperatingConstraintsResumeImplicationData, newData, filterPartial, filterDelete) + + if success && persist { + r.OperatingConstraintsResumeImplicationData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/powersequences.go b/src/eebus-bridge/third_party/spine-go/model/powersequences.go new file mode 100644 index 0000000..aa3ae8b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/powersequences.go @@ -0,0 +1,331 @@ +package model + +type AlternativesIdType uint + +type PowerSequenceIdType uint + +type PowerTimeSlotNumberType uint + +type PowerTimeSlotValueTypeType string + +const ( + PowerTimeSlotValueTypeTypePower PowerTimeSlotValueTypeType = "power" + PowerTimeSlotValueTypeTypePowerMin PowerTimeSlotValueTypeType = "powerMin" + PowerTimeSlotValueTypeTypePowerMax PowerTimeSlotValueTypeType = "powerMax" + PowerTimeSlotValueTypeTypePowerExpectedValue PowerTimeSlotValueTypeType = "powerExpectedValue" + PowerTimeSlotValueTypeTypePowerStandardDeviation PowerTimeSlotValueTypeType = "powerStandardDeviation" + PowerTimeSlotValueTypeTypePowerSkewness PowerTimeSlotValueTypeType = "powerSkewness" + PowerTimeSlotValueTypeTypeEnergy PowerTimeSlotValueTypeType = "energy" + PowerTimeSlotValueTypeTypeEnergyMin PowerTimeSlotValueTypeType = "energyMin" + PowerTimeSlotValueTypeTypeEnergyMax PowerTimeSlotValueTypeType = "energyMax" + PowerTimeSlotValueTypeTypeEnergyExpectedValue PowerTimeSlotValueTypeType = "energyExpectedValue" + PowerTimeSlotValueTypeTypeEnergyStandardDeviation PowerTimeSlotValueTypeType = "energyStandardDeviation" + PowerTimeSlotValueTypeTypeEnergySkewness PowerTimeSlotValueTypeType = "energySkewness" +) + +type PowerSequenceScopeType string + +const ( + PowerSequenceScopeTypeForecast PowerSequenceScopeType = "forecast" + PowerSequenceScopeTypeMeasurement PowerSequenceScopeType = "measurement" + PowerSequenceScopeTypeRecommendation PowerSequenceScopeType = "recommendation" +) + +type PowerSequenceStateType string + +const ( + PowerSequenceStateTypeRunning PowerSequenceStateType = "running" + PowerSequenceStateTypePaused PowerSequenceStateType = "paused" + PowerSequenceStateTypeScheduled PowerSequenceStateType = "scheduled" + PowerSequenceStateTypeScheduledPaused PowerSequenceStateType = "scheduledPaused" + PowerSequenceStateTypePending PowerSequenceStateType = "pending" + PowerSequenceStateTypeInactive PowerSequenceStateType = "inactive" + PowerSequenceStateTypeCompleted PowerSequenceStateType = "completed" + PowerSequenceStateTypeInvalid PowerSequenceStateType = "invalid" +) + +type PowerTimeSlotScheduleDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + DefaultDuration *DurationType `json:"defaultDuration,omitempty"` + DurationUncertainty *DurationType `json:"durationUncertainty,omitempty"` + SlotActivated *bool `json:"slotActivated,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type PowerTimeSlotScheduleDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + SlotNumber *ElementTagType `json:"slotNumber,omitempty"` + TimePeriod *ElementTagType `json:"timePeriod,omitempty"` + DefaultDuration *ElementTagType `json:"defaultDuration,omitempty"` + DurationUncertainty *ElementTagType `json:"durationUncertainty,omitempty"` + SlotActivated *ElementTagType `json:"slotActivated,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type PowerTimeSlotScheduleListDataType struct { + PowerTimeSlotScheduleData []PowerTimeSlotScheduleDataType `json:"powerTimeSlotScheduleData,omitempty"` +} + +type PowerTimeSlotScheduleListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` +} + +type PowerTimeSlotValueDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` + ValueType *PowerTimeSlotValueTypeType `json:"valueType,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` +} + +type PowerTimeSlotValueDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + SlotNumber *ElementTagType `json:"slotNumber,omitempty"` + ValueType *ElementTagType `json:"valueType,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` +} + +type PowerTimeSlotValueListDataType struct { + PowerTimeSlotValueData []PowerTimeSlotValueDataType `json:"powerTimeSlotValueListData,omitempty"` +} + +type PowerTimeSlotValueListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` + ValueType *PowerTimeSlotValueTypeType `json:"valueType,omitempty"` +} + +type PowerTimeSlotScheduleConstraintsDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` + EarliestStartTime *AbsoluteOrRelativeTimeType `json:"earliestStartTime,omitempty"` + LatestEndTime *AbsoluteOrRelativeTimeType `json:"latestEndTime,omitempty"` + MinDuration *DurationType `json:"minDuration,omitempty"` + MaxDuration *DurationType `json:"maxDuration,omitempty"` + OptionalSlot *bool `json:"optionalSlot,omitempty"` +} + +type PowerTimeSlotScheduleConstraintsDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + SlotNumber *ElementTagType `json:"slotNumber,omitempty"` + EarliestStartTime *ElementTagType `json:"earliestStartTime,omitempty"` + LatestEndTime *ElementTagType `json:"latestEndTime,omitempty"` + MinDuration *ElementTagType `json:"minDuration,omitempty"` + MaxDuration *ElementTagType `json:"maxDuration,omitempty"` + OptionalSlot *ElementTagType `json:"optionalSlot,omitempty"` +} + +type PowerTimeSlotScheduleConstraintsListDataType struct { + PowerTimeSlotScheduleConstraintsData []PowerTimeSlotScheduleConstraintsDataType `json:"powerTimeSlotScheduleConstraintsData,omitempty"` +} + +type PowerTimeSlotScheduleConstraintsListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` + SlotNumber *PowerTimeSlotNumberType `json:"slotNumber,omitempty"` +} + +type PowerSequenceAlternativesRelationDataType struct { + AlternativesId *AlternativesIdType `json:"alternativesId,omitempty" eebus:"key"` + SequenceId []PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceAlternativesRelationDataElementsType struct { + AlternativesId *ElementTagType `json:"alternativesId,omitempty"` + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type PowerSequenceAlternativesRelationListDataType struct { + PowerSequenceAlternativesRelationData []PowerSequenceAlternativesRelationDataType `json:"powerSequenceAlternativesRelationData,omitempty"` +} + +type PowerSequenceAlternativesRelationListDataSelectorsType struct { + AlternativesId *AlternativesIdType `json:"alternativesId,omitempty"` + SequenceId []PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceDescriptionDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + Description *DescriptionType `json:"description,omitempty"` + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *UnitOfMeasurementType `json:"powerUnit,omitempty"` + EnergyUnit *UnitOfMeasurementType `json:"energyUnit,omitempty"` + ValueSource *MeasurementValueSourceType `json:"valueSource,omitempty"` + Scope *PowerSequenceScopeType `json:"scope,omitempty"` + TaskIdentifier *uint `json:"taskIdentifier,omitempty"` + RepetitionsTotal *uint `json:"repetitionsTotal,omitempty"` +} + +type PowerSequenceDescriptionDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + PowerUnit *ElementTagType `json:"powerUnit,omitempty"` + EnergyUnit *ElementTagType `json:"energyUnit,omitempty"` + ValueSource *ElementTagType `json:"valueSource,omitempty"` + Scope *ElementTagType `json:"scope,omitempty"` + TaskIdentifier *ElementTagType `json:"taskIdentifier,omitempty"` + RepetitionsTotal *ElementTagType `json:"repetitionsTotal,omitempty"` +} + +type PowerSequenceDescriptionListDataType struct { + PowerSequenceDescriptionData []PowerSequenceDescriptionDataType `json:"powerSequenceDescriptionData,omitempty"` +} + +type PowerSequenceDescriptionListDataSelectorsType struct { + SequenceId []PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceStateDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + State *PowerSequenceStateType `json:"state,omitempty"` + ActiveSlotNumber *PowerTimeSlotNumberType `json:"activeSlotNumber,omitempty"` + ElapsedSlotTime *DurationType `json:"elapsedSlotTime,omitempty"` + RemainingSlotTime *DurationType `json:"remainingSlotTime,omitempty"` + SequenceRemoteControllable *bool `json:"sequenceRemoteControllable,omitempty"` + ActiveRepetitionNumber *uint `json:"activeRepetitionNumber,omitempty"` + RemainingPauseTime *DurationType `json:"remainingPauseTime,omitempty"` +} + +type PowerSequenceStateDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + State *ElementTagType `json:"state,omitempty"` + ActiveSlotNumber *ElementTagType `json:"activeSlotNumber,omitempty"` + ElapsedSlotTime *ElementTagType `json:"elapsedSlotTime,omitempty"` + RemainingSlotTime *ElementTagType `json:"remainingSlotTime,omitempty"` + SequenceRemoteControllable *ElementTagType `json:"sequenceRemoteControllable,omitempty"` + ActiveRepetitionNumber *ElementTagType `json:"activeRepetitionNumber,omitempty"` + RemainingPauseTime *ElementTagType `json:"remainingPauseTime,omitempty"` +} + +type PowerSequenceStateListDataType struct { + PowerSequenceStateData []PowerSequenceStateDataType `json:"powerSequenceStateData,omitempty"` +} + +type PowerSequenceStateListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceScheduleDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + StartTime *AbsoluteOrRelativeTimeType `json:"startTime,omitempty"` + EndTime *AbsoluteOrRelativeTimeType `json:"endTime,omitempty"` +} + +type PowerSequenceScheduleDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + StartTime *ElementTagType `json:"startTime,omitempty"` + EndTime *ElementTagType `json:"endTime,omitempty"` +} + +type PowerSequenceScheduleListDataType struct { + PowerSequenceScheduleData []PowerSequenceScheduleDataType `json:"powerSequenceScheduleData,omitempty"` +} + +type PowerSequenceScheduleListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceScheduleConstraintsDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + EarliestStartTime *AbsoluteOrRelativeTimeType `json:"earliestStartTime,omitempty"` + LatestStartTime *AbsoluteOrRelativeTimeType `json:"latestStartTime,omitempty"` + EarliestEndTime *AbsoluteOrRelativeTimeType `json:"earliestEndTime,omitempty"` + LatestEndTime *AbsoluteOrRelativeTimeType `json:"latestEndTime,omitempty"` + OptionalSequence *bool `json:"optionalSequence,omitempty"` +} + +type PowerSequenceScheduleConstraintsDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + EarliestStartTime *ElementTagType `json:"earliestStartTime,omitempty"` + LatestStartTime *ElementTagType `json:"latestStartTime,omitempty"` + EarliestEndTime *ElementTagType `json:"earliestEndTime,omitempty"` + LatestEndTime *ElementTagType `json:"latestEndTime,omitempty"` + OptionalSequence *ElementTagType `json:"optionalSequence,omitempty"` +} + +type PowerSequenceScheduleConstraintsListDataType struct { + PowerSequenceScheduleConstraintsData []PowerSequenceScheduleConstraintsDataType `json:"powerSequenceScheduleConstraintsData,omitempty"` +} + +type PowerSequenceScheduleConstraintsListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequencePriceDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + PotentialStartTime *AbsoluteOrRelativeTimeType `json:"potentialStartTime,omitempty"` + Price *ScaledNumberType `json:"price,omitempty"` + Currency *CurrencyType `json:"currency,omitempty"` +} + +type PowerSequencePriceDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + PotentialStartTime *ElementTagType `json:"potentialStartTime,omitempty"` + Price *ElementTagType `json:"price,omitempty"` + Currency *ElementTagType `json:"currency,omitempty"` +} + +type PowerSequencePriceListDataType struct { + PowerSequencePriceData []PowerSequencePriceDataType `json:"powerSequencePriceData,omitempty"` +} + +type PowerSequencePriceListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` + PotentialStartTimeInterval *AbsoluteOrRelativeTimeType `json:"potentialStartTimeInterval,omitempty"` +} + +type PowerSequenceSchedulePreferenceDataType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty" eebus:"key"` + Greenest *bool `json:"greenest,omitempty"` + Cheapest *bool `json:"cheapest,omitempty"` +} + +type PowerSequenceSchedulePreferenceDataElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + Greenest *ElementTagType `json:"greenest,omitempty"` + Cheapest *ElementTagType `json:"cheapest,omitempty"` +} + +type PowerSequenceSchedulePreferenceListDataType struct { + PowerSequenceSchedulePreferenceData []PowerSequenceSchedulePreferenceDataType `json:"powerSequenceSchedulePreferenceData,omitempty"` +} + +type PowerSequenceSchedulePreferenceListDataSelectorsType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceNodeScheduleInformationDataType struct { + NodeRemoteControllable *bool `json:"nodeRemoteControllable,omitempty"` + SupportsSingleSlotSchedulingOnly *bool `json:"supportsSingleSlotSchedulingOnly,omitempty"` + AlternativesCount *uint `json:"alternativesCount,omitempty"` + TotalSequencesCountMax *uint `json:"totalSequencesCountMax,omitempty"` + SupportsReselection *bool `json:"supportsReselection,omitempty"` +} + +type PowerSequenceNodeScheduleInformationDataElementsType struct { + NodeRemoteControllable *ElementTagType `json:"nodeRemoteControllable,omitempty"` + SupportsSingleSlotSchedulingOnly *ElementTagType `json:"supportsSingleSlotSchedulingOnly,omitempty"` + AlternativesCount *ElementTagType `json:"alternativesCount,omitempty"` + TotalSequencesCountMax *ElementTagType `json:"totalSequencesCountMax,omitempty"` + SupportsReselection *ElementTagType `json:"supportsReselection,omitempty"` +} + +type PowerSequenceScheduleConfigurationRequestCallType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type PowerSequenceScheduleConfigurationRequestCallElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type PowerSequencePriceCalculationRequestCallType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` + PotentialStartTime *AbsoluteOrRelativeTimeType `json:"potentialStartTime,omitempty"` +} + +type PowerSequencePriceCalculationRequestCallElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` + PotentialStartTime *ElementTagType `json:"potentialStartTime,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/powersequences_additions.go b/src/eebus-bridge/third_party/spine-go/model/powersequences_additions.go new file mode 100644 index 0000000..ac15c5f --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/powersequences_additions.go @@ -0,0 +1,191 @@ +package model + +// PowerTimeSlotScheduleListDataType + +var _ Updater = (*PowerTimeSlotScheduleListDataType)(nil) + +func (r *PowerTimeSlotScheduleListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerTimeSlotScheduleDataType + if newList != nil { + newData = newList.(*PowerTimeSlotScheduleListDataType).PowerTimeSlotScheduleData + } + + data, success := UpdateList(remoteWrite, r.PowerTimeSlotScheduleData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerTimeSlotScheduleData = data + } + + return data, success +} + +// PowerTimeSlotValueListDataType + +var _ Updater = (*PowerTimeSlotValueListDataType)(nil) + +func (r *PowerTimeSlotValueListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerTimeSlotValueDataType + if newList != nil { + newData = newList.(*PowerTimeSlotValueListDataType).PowerTimeSlotValueData + } + + data, success := UpdateList(remoteWrite, r.PowerTimeSlotValueData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerTimeSlotValueData = data + } + + return data, success +} + +// PowerTimeSlotScheduleConstraintsListDataType + +var _ Updater = (*PowerTimeSlotScheduleConstraintsListDataType)(nil) + +func (r *PowerTimeSlotScheduleConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerTimeSlotScheduleConstraintsDataType + if newList != nil { + newData = newList.(*PowerTimeSlotScheduleConstraintsListDataType).PowerTimeSlotScheduleConstraintsData + } + + data, success := UpdateList(remoteWrite, r.PowerTimeSlotScheduleConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerTimeSlotScheduleConstraintsData = data + } + + return data, success +} + +// PowerSequenceAlternativesRelationListDataType + +var _ Updater = (*PowerSequenceAlternativesRelationListDataType)(nil) + +func (r *PowerSequenceAlternativesRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceAlternativesRelationDataType + if newList != nil { + newData = newList.(*PowerSequenceAlternativesRelationListDataType).PowerSequenceAlternativesRelationData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceAlternativesRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceAlternativesRelationData = data + } + + return data, success +} + +// PowerSequenceDescriptionListDataType + +var _ Updater = (*PowerSequenceDescriptionListDataType)(nil) + +func (r *PowerSequenceDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceDescriptionDataType + if newList != nil { + newData = newList.(*PowerSequenceDescriptionListDataType).PowerSequenceDescriptionData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceDescriptionData = data + } + + return data, success +} + +// PowerSequenceStateListDataType + +var _ Updater = (*PowerSequenceStateListDataType)(nil) + +func (r *PowerSequenceStateListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceStateDataType + if newList != nil { + newData = newList.(*PowerSequenceStateListDataType).PowerSequenceStateData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceStateData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceStateData = data + } + + return data, success +} + +// PowerSequenceScheduleListDataType + +var _ Updater = (*PowerSequenceScheduleListDataType)(nil) + +func (r *PowerSequenceScheduleListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceScheduleDataType + if newList != nil { + newData = newList.(*PowerSequenceScheduleListDataType).PowerSequenceScheduleData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceScheduleData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceScheduleData = data + } + + return data, success +} + +// PowerSequenceScheduleConstraintsListDataType + +var _ Updater = (*PowerSequenceScheduleConstraintsListDataType)(nil) + +func (r *PowerSequenceScheduleConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceScheduleConstraintsDataType + if newList != nil { + newData = newList.(*PowerSequenceScheduleConstraintsListDataType).PowerSequenceScheduleConstraintsData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceScheduleConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceScheduleConstraintsData = data + } + + return data, success +} + +// PowerSequencePriceListDataType + +var _ Updater = (*PowerSequencePriceListDataType)(nil) + +func (r *PowerSequencePriceListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequencePriceDataType + if newList != nil { + newData = newList.(*PowerSequencePriceListDataType).PowerSequencePriceData + } + + data, success := UpdateList(remoteWrite, r.PowerSequencePriceData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequencePriceData = data + } + + return data, success +} + +// PowerSequenceSchedulePreferenceListDataType + +var _ Updater = (*PowerSequenceSchedulePreferenceListDataType)(nil) + +func (r *PowerSequenceSchedulePreferenceListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []PowerSequenceSchedulePreferenceDataType + if newList != nil { + newData = newList.(*PowerSequenceSchedulePreferenceListDataType).PowerSequenceSchedulePreferenceData + } + + data, success := UpdateList(remoteWrite, r.PowerSequenceSchedulePreferenceData, newData, filterPartial, filterDelete) + + if success && persist { + r.PowerSequenceSchedulePreferenceData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/result.go b/src/eebus-bridge/third_party/spine-go/model/result.go new file mode 100644 index 0000000..59c2bcd --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/result.go @@ -0,0 +1,21 @@ +package model + +type ErrorNumberType uint + +const ( + ErrorNumberTypeNoError ErrorNumberType = iota + ErrorNumberTypeGeneralError + ErrorNumberTypeTimeout + ErrorNumberTypeOverload + ErrorNumberTypeDestinationUnknown + ErrorNumberTypeDestinationUnreachable + ErrorNumberTypeCommandNotSupported + ErrorNumberTypeCommandRejected + ErrorNumberTypeRestrictedFunctionExchangeCombinationNotSupported + ErrorNumberTypeBindingIsNecessaryForThisCommand +) + +type ResultDataType struct { + ErrorNumber *ErrorNumberType `json:"errorNumber,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/sensing.go b/src/eebus-bridge/third_party/spine-go/model/sensing.go new file mode 100644 index 0000000..e19ba3d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/sensing.go @@ -0,0 +1,99 @@ +package model + +type SensingStateType string + +const ( + SensingStateTypeOn SensingStateType = "on" + SensingStateTypeOff SensingStateType = "off" + SensingStateTypeToggle SensingStateType = "toggle" + SensingStateTypeLevel SensingStateType = "level" + SensingStateTypeLevelUp SensingStateType = "levelUp" + SensingStateTypeLevelDown SensingStateType = "levelDown" + SensingStateTypeLevelStart SensingStateType = "levelStart" + SensingStateTypeLevelStop SensingStateType = "levelStop" + SensingStateTypeLevelAbsolute SensingStateType = "levelAbsolute" + SensingStateTypeLevelRelative SensingStateType = "levelRelative" + SensingStateTypeLevelPercentageAbsolute SensingStateType = "levelPercentageAbsolute" + SensingStateTypeLevelPercentageRelative SensingStateType = "levelPercentageRelative" + SensingStateTypePressed SensingStateType = "pressed" + SensingStateTypeLongPressed SensingStateType = "longPressed" + SensingStateTypeReleased SensingStateType = "released" + SensingStateTypeChanged SensingStateType = "changed" + SensingStateTypeStarted SensingStateType = "started" + SensingStateTypeStopped SensingStateType = "stopped" + SensingStateTypePaused SensingStateType = "paused" + SensingStateTypeMiddle SensingStateType = "middle" + SensingStateTypeUp SensingStateType = "up" + SensingStateTypeDown SensingStateType = "down" + SensingStateTypeForward SensingStateType = "forward" + SensingStateTypeBackwards SensingStateType = "backwards" + SensingStateTypeOpen SensingStateType = "open" + SensingStateTypeClosed SensingStateType = "closed" + SensingStateTypeOpening SensingStateType = "opening" + SensingStateTypeClosing SensingStateType = "closing" + SensingStateTypeHigh SensingStateType = "high" + SensingStateTypeLow SensingStateType = "low" + SensingStateTypeDay SensingStateType = "day" + SensingStateTypeNight SensingStateType = "night" + SensingStateTypeDetected SensingStateType = "detected" + SensingStateTypeNotDetected SensingStateType = "notDetected" + SensingStateTypeAlarmed SensingStateType = "alarmed" + SensingStateTypeNotAlarmed SensingStateType = "notAlarmed" +) + +type SensingTypeType string + +const ( + SensingTypeTypeSwitch SensingTypeType = "switch" + SensingTypeTypeButton SensingTypeType = "button" + SensingTypeTypeLevel SensingTypeType = "level" + SensingTypeTypeLevelSwitch SensingTypeType = "levelSwitch" + SensingTypeTypeWindowHandle SensingTypeType = "windowHandle" + SensingTypeTypeContactSensor SensingTypeType = "contactSensor" + SensingTypeTypeOccupancySensor SensingTypeType = "occupancySensor" + SensingTypeTypeMotionDetector SensingTypeType = "motionDetector" + SensingTypeTypeFireDetector SensingTypeType = "fireDetector" + SensingTypeTypeSmokeDetector SensingTypeType = "smokeDetector" + SensingTypeTypeHeatDetector SensingTypeType = "heatDetector" + SensingTypeTypeWaterDetector SensingTypeType = "waterDetector" + SensingTypeTypeGasDetector SensingTypeType = "gasDetector" + SensingTypeTypeAlarmSensor SensingTypeType = "alarmSensor" + SensingTypeTypePowerAlarmSensor SensingTypeType = "powerAlarmSensor" + SensingTypeTypeDayNightIndicator SensingTypeType = "dayNightIndicator" +) + +type SensingDataType struct { + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + State *SensingStateType `json:"state,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` +} + +type SensingDataElementsType struct { + Timestamp *ElementTagType `json:"timestamp,omitempty"` + State *ElementTagType `json:"state,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` +} + +type SensingListDataType struct { + SensingData []SensingDataType `json:"sensingData,omitempty"` +} + +type SensingListDataSelectorsType struct { + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` +} + +type SensingDescriptionDataType struct { + SensingType *SensingTypeType `json:"sensingType,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type SensingDescriptionDataElementsType struct { + SensingType *ElementTagType `json:"sensingType,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/setpoint.go b/src/eebus-bridge/third_party/spine-go/model/setpoint.go new file mode 100644 index 0000000..c082e23 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/setpoint.go @@ -0,0 +1,98 @@ +package model + +type SetpointIdType uint + +type SetpointTypeType string + +const ( + SetpointTypeTypeValueAbsolute SetpointTypeType = "valueAbsolute" + SetpointTypeTypeValueRelative SetpointTypeType = "valueRelative" +) + +type SetpointDataType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"` + Value *ScaledNumberType `json:"value,omitempty"` + ValueMin *ScaledNumberType `json:"valueMin,omitempty"` + ValueMax *ScaledNumberType `json:"valueMax,omitempty"` + ValueToleranceAbsolute *ScaledNumberType `json:"valueToleranceAbsolute,omitempty"` + ValueTolerancePercentage *ScaledNumberType `json:"valueTolerancePercentage,omitempty"` + IsSetpointChangeable *bool `json:"isSetpointChangeable,omitempty" eebus:"writecheck"` + IsSetpointActive *bool `json:"isSetpointActive,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` +} + +type SetpointDataElementsType struct { + SetpointId *ElementTagType `json:"setpointId,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` + ValueMin *ScaledNumberElementsType `json:"valueMin,omitempty"` + ValueMax *ScaledNumberElementsType `json:"valueMax,omitempty"` + ValueToleranceAbsolute *ScaledNumberElementsType `json:"valueToleranceAbsolute,omitempty"` + ValueTolerancePercentage *ScaledNumberElementsType `json:"valueTolerancePercentage,omitempty"` + IsSetpointChangeable *ElementTagType `json:"isSetpointChangeable,omitempty"` + IsSetpointActive *ElementTagType `json:"isSetpointActive,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` +} + +type SetpointListDataType struct { + SetpointData []SetpointDataType `json:"setpointData,omitempty"` +} + +type SetpointListDataSelectorsType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty"` +} + +type SetpointConstraintsDataType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"` + SetpointRangeMin *ScaledNumberType `json:"setpointRangeMin,omitempty"` + SetpointRangeMax *ScaledNumberType `json:"setpointRangeMax,omitempty"` + SetpointStepSize *ScaledNumberType `json:"setpointStepSize,omitempty"` +} + +type SetpointConstraintsDataElementsType struct { + SetpointId *ElementTagType `json:"setpointId,omitempty"` + SetpointRangeMin *ScaledNumberElementsType `json:"setpointRangeMin,omitempty"` + SetpointRangeMax *ScaledNumberElementsType `json:"setpointRangeMax,omitempty"` + SetpointStepSize *ScaledNumberElementsType `json:"setpointStepSize,omitempty"` +} + +type SetpointConstraintsListDataType struct { + SetpointConstraintsData []SetpointConstraintsDataType `json:"setpointConstraintsData,omitempty"` +} + +type SetpointConstraintsListDataSelectorsType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty"` +} + +type SetpointDescriptionDataType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty" eebus:"key"` + MeasurementId *SetpointIdType `json:"measurementId,omitempty"` + TimeTableId *SetpointIdType `json:"timeTableId,omitempty"` + SetpointType *SetpointTypeType `json:"setpointType,omitempty"` + Unit *ScaledNumberType `json:"unit,omitempty"` + ScopeType *ScaledNumberType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type SetpointDescriptionDataElementsType struct { + SetpointId *ElementTagType `json:"setpointId,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + SetpointType *ElementTagType `json:"setpointType,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type SetpointDescriptionListDataType struct { + SetpointDescriptionData []SetpointDescriptionDataType `json:"setpointDescriptionData,omitempty"` +} + +type SetpointDescriptionListDataSelectorsType struct { + SetpointId *SetpointIdType `json:"setpointId,omitempty"` + MeasurementId *SetpointIdType `json:"measurementId,omitempty"` + TimeTableId *SetpointIdType `json:"timeTableId,omitempty"` + SetpointType *SetpointIdType `json:"setpointType,omitempty"` + ScopeType *ScaledNumberType `json:"scopeType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/setpoint_additions.go b/src/eebus-bridge/third_party/spine-go/model/setpoint_additions.go new file mode 100644 index 0000000..faf1f1e --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/setpoint_additions.go @@ -0,0 +1,39 @@ +package model + +// SetpointListDataType + +var _ Updater = (*SetpointListDataType)(nil) + +func (r *SetpointListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SetpointDataType + if newList != nil { + newData = newList.(*SetpointListDataType).SetpointData + } + + data, success := UpdateList(remoteWrite, r.SetpointData, newData, filterPartial, filterDelete) + + if success && persist { + r.SetpointData = data + } + + return data, success +} + +// SetpointDescriptionListDataType + +var _ Updater = (*SetpointDescriptionListDataType)(nil) + +func (r *SetpointDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SetpointDescriptionDataType + if newList != nil { + newData = newList.(*SetpointDescriptionListDataType).SetpointDescriptionData + } + + data, success := UpdateList(remoteWrite, r.SetpointDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.SetpointDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/smartenergymanagementps.go b/src/eebus-bridge/third_party/spine-go/model/smartenergymanagementps.go new file mode 100644 index 0000000..7f95c00 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/smartenergymanagementps.go @@ -0,0 +1,104 @@ +package model + +type SmartEnergyManagementPsAlternativesRelationType PowerSequenceAlternativesRelationDataType // ignoring the custom changes + +type SmartEnergyManagementPsAlternativesRelationElementsType PowerSequenceAlternativesRelationDataElementsType // ignoring changes + +type SmartEnergyManagementPsAlternativesType struct { + Relation *SmartEnergyManagementPsAlternativesRelationType `json:"relation,omitempty"` + PowerSequence []SmartEnergyManagementPsPowerSequenceType `json:"powerSequence,omitempty"` +} + +type SmartEnergyManagementPsAlternativesElementsType struct { + Relation *SmartEnergyManagementPsAlternativesRelationElementsType `json:"relation,omitempty"` + PowerSequence *SmartEnergyManagementPsPowerSequenceElementsType `json:"powerSequence,omitempty"` +} + +type SmartEnergyManagementPsPowerSequenceType struct { + Description *PowerSequenceDescriptionDataType `json:"description,omitempty"` // ignoring changes + State *PowerSequenceStateDataType `json:"state,omitempty"` // ignoring changes + Schedule *PowerSequenceScheduleDataType `json:"schedule,omitempty"` // ignoring changes + ScheduleConstraints *PowerSequenceScheduleConstraintsDataType `json:"scheduleConstraints,omitempty"` // ignoring changes + SchedulePreference *PowerSequenceSchedulePreferenceDataType `json:"schedulePreference,omitempty"` // ignoring changes + OperatingConstraintsInterrupt *OperatingConstraintsInterruptDataType `json:"operatingConstraintsInterrupt,omitempty"` // ignoring changes + OperatingConstraintsDuration *OperatingConstraintsDurationDataType `json:"operatingConstraintsDuration,omitempty"` // ignoring changes + OperatingConstraintsResumeImplication *OperatingConstraintsResumeImplicationDataType `json:"operatingConstraintsResumeImplication,omitempty"` // ignoring changes + PowerTimeSlot []SmartEnergyManagementPsPowerTimeSlotType `json:"powerTimeSlot,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPowerSequenceElementsType struct { + Description *PowerSequenceDescriptionDataElementsType `json:"description,omitempty"` + State *PowerSequenceStateDataElementsType `json:"state,omitempty"` + Schedule *PowerSequenceScheduleDataElementsType `json:"schedule,omitempty"` + ScheduleConstraints *PowerSequenceScheduleConstraintsDataElementsType `json:"scheduleConstraints,omitempty"` + SchedulePreference *PowerSequenceSchedulePreferenceDataElementsType `json:"schedulePreference,omitempty"` + OperatingConstraintsInterrupt *OperatingConstraintsInterruptDataElementsType `json:"operatingConstraintsInterrupt,omitempty"` + OperatingConstraintsDuration *OperatingConstraintsDurationDataElementsType `json:"operatingConstraintsDuration,omitempty"` + OperatingConstraintsResumeImplication *OperatingConstraintsResumeImplicationDataElementsType `json:"operatingConstraintsResumeImplication,omitempty"` + PowerTimeSlot *SmartEnergyManagementPsPowerTimeSlotElementsType `json:"powerTimeSlot,omitempty"` +} + +type SmartEnergyManagementPsPowerTimeSlotType struct { + Schedule *PowerTimeSlotScheduleDataType `json:"schedule,omitempty"` // ignoring changes + ValueList *SmartEnergyManagementPsPowerTimeSlotValueListType `json:"valueList,omitempty"` + ScheduleConstraints *PowerTimeSlotScheduleConstraintsDataType `json:"scheduleConstraints,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPowerTimeSlotElementsType struct { + Schedule *PowerTimeSlotScheduleDataElementsType `json:"schedule,omitempty"` // ignoring changes + ValueList *SmartEnergyManagementPsPowerTimeSlotValueListElementsType `json:"valueList,omitempty"` + ScheduleConstraints *PowerTimeSlotScheduleConstraintsDataElementsType `json:"scheduleConstraints,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPowerTimeSlotValueListType struct { + Value []PowerTimeSlotValueDataType `json:"value,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPowerTimeSlotValueListElementsType struct { + Value *PowerTimeSlotValueDataElementsType `json:"value,omitempty"` +} + +type SmartEnergyManagementPsDataType struct { + NodeScheduleInformation *PowerSequenceNodeScheduleInformationDataType `json:"nodeScheduleInformation,omitempty"` // ignoring changes + Alternatives []SmartEnergyManagementPsAlternativesType `json:"alternatives,omitempty"` +} + +type SmartEnergyManagementPsDataElementsType struct { + NodeScheduleInformation *PowerSequenceNodeScheduleInformationDataElementsType `json:"nodeScheduleInformation,omitempty"` + Alternatives *SmartEnergyManagementPsAlternativesElementsType `json:"alternatives,omitempty"` +} + +type SmartEnergyManagementPsDataSelectorsType struct { + AlternativesRelation *PowerSequenceAlternativesRelationListDataSelectorsType `json:"alternativesRelation,omitempty"` // ignoring changes + PowerSequenceDescription *PowerSequenceDescriptionListDataSelectorsType `json:"powerSequenceDescription,omitempty"` // ignoring changes + PowerTimeSlotSchedule *PowerTimeSlotScheduleListDataSelectorsType `json:"powerTimeSlotSchedule,omitempty"` // ignoring changes + PowerTimeSlotValue *PowerTimeSlotValueListDataSelectorsType `json:"powerTimeSlotValue,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPriceDataType struct { + Price *PowerSequencePriceDataType `json:"price,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPriceDataElementsType struct { + Price *PowerSequencePriceDataElementsType `json:"price,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPriceDataSelectorsType struct { + Price *PowerSequencePriceListDataSelectorsType `json:"price,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsConfigurationRequestCallType struct { + ScheduleConfigurationRequest *PowerSequenceScheduleConfigurationRequestCallType `json:"scheduleConfigurationRequest,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsConfigurationRequestCallElementsType struct { + ScheduleConfigurationRequest *PowerSequenceScheduleConfigurationRequestCallElementsType `json:"scheduleConfigurationRequest,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPriceCalculationRequestCallType struct { + PriceCalculationRequest *PowerSequencePriceCalculationRequestCallType `json:"priceCalculationRequest,omitempty"` // ignoring changes +} + +type SmartEnergyManagementPsPriceCalculationRequestCallElementsType struct { + PriceCalculationRequest *PowerSequencePriceCalculationRequestCallElementsType `json:"priceCalculationRequest,omitempty"` // ignoring changes +} diff --git a/src/eebus-bridge/third_party/spine-go/model/stateinformation.go b/src/eebus-bridge/third_party/spine-go/model/stateinformation.go new file mode 100644 index 0000000..795f303 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/stateinformation.go @@ -0,0 +1,115 @@ +package model + +type StateInformationIdType uint + +type StateInformationType string + +// union StateInformationFunctionalityType StateInformationFunctionalityType +const ( + StateInformationTypeExternalOverrideFromGrid StateInformationType = "externalOverrideFromGrid" + StateInformationTypeAutonomousGridSupport StateInformationType = "autonomousGridSupport" + StateInformationTypeIslandingMode StateInformationType = "islandingMode" + StateInformationTypeBalancing StateInformationType = "balancing" + StateInformationTypeTrickleCharging StateInformationType = "trickleCharging" + StateInformationTypeCalibration StateInformationType = "calibration" + StateInformationTypeCommissioningMissing StateInformationType = "commissioningMissing" + StateInformationTypeSleeping StateInformationType = "sleeping" + StateInformationTypeStarting StateInformationType = "starting" + StateInformationTypeMppt StateInformationType = "mppt" + StateInformationTypeThrottled StateInformationType = "throttled" + StateInformationTypeShuttingDown StateInformationType = "shuttingDown" + StateInformationTypeManualShutdown StateInformationType = "manualShutdown" + StateInformationTypeInverterDefective StateInformationType = "inverterDefective" + StateInformationTypeBatteryOvercurrentProtection StateInformationType = "batteryOvercurrentProtection" + StateInformationTypePvStringOvercurrentProtection StateInformationType = "pvStringOvercurrentProtection" + StateInformationTypeGridFault StateInformationType = "gridFault" + StateInformationTypeGroundFault StateInformationType = "groundFault" + StateInformationTypeAcDisconnected StateInformationType = "acDisconnected" + StateInformationTypeDcDisconnected StateInformationType = "dcDisconnected" + StateInformationTypeCabinetOpen StateInformationType = "cabinetOpen" + StateInformationTypeOverTemperature StateInformationType = "overTemperature" + StateInformationTypeUnderTemperature StateInformationType = "underTemperature" + StateInformationTypeFrequencyAboveLimit StateInformationType = "frequencyAboveLimit" + StateInformationTypeFrequencyBelowLimit StateInformationType = "frequencyBelowLimit" + StateInformationTypeAcVoltageAboveLimit StateInformationType = "acVoltageAboveLimit" + StateInformationTypeAcVoltageBelowLimit StateInformationType = "acVoltageBelowLimit" + StateInformationTypeDcVoltageAboveLimit StateInformationType = "dcVoltageAboveLimit" + StateInformationTypeDcVoltageBelowLimit StateInformationType = "dcVoltageBelowLimit" + StateInformationTypeHardwareTestFailure StateInformationType = "hardwareTestFailure" + StateInformationTypeGenericInternalError StateInformationType = "genericInternalError" +) + +type StateInformationFunctionalityType string + +const ( + StateInformationFunctionalityTypeExternalOverrideFromGrid StateInformationFunctionalityType = "externalOverrideFromGrid" + StateInformationFunctionalityTypeAutonomousGridSupport StateInformationFunctionalityType = "autonomousGridSupport" + StateInformationFunctionalityTypeIslandingMode StateInformationFunctionalityType = "islandingMode" + StateInformationFunctionalityTypeBalancing StateInformationFunctionalityType = "balancing" + StateInformationFunctionalityTypeTrickleCharging StateInformationFunctionalityType = "trickleCharging" + StateInformationFunctionalityTypeCalibration StateInformationFunctionalityType = "calibration" + StateInformationFunctionalityTypeCommissioningMissing StateInformationFunctionalityType = "commissioningMissing" + StateInformationFunctionalityTypeSleeping StateInformationFunctionalityType = "sleeping" + StateInformationFunctionalityTypeStarting StateInformationFunctionalityType = "starting" + StateInformationFunctionalityTypeMppt StateInformationFunctionalityType = "mppt" + StateInformationFunctionalityTypeThrottled StateInformationFunctionalityType = "throttled" + StateInformationFunctionalityTypeShuttingDown StateInformationFunctionalityType = "shuttingDown" + StateInformationFunctionalityTypeManualShutdown StateInformationFunctionalityType = "manualShutdown" +) + +type StateInformationFailureType string + +const ( + StateInformationFailureTypeInverterDefective StateInformationFailureType = "inverterDefective" + StateInformationFailureTypeBatteryOvercurrentProtection StateInformationFailureType = "batteryOvercurrentProtection" + StateInformationFailureTypePvStringOvercurrentProtection StateInformationFailureType = "pvStringOvercurrentProtection" + StateInformationFailureTypeGridFault StateInformationFailureType = "gridFault" + StateInformationFailureTypeGroundFault StateInformationFailureType = "groundFault" + StateInformationFailureTypeAcDisconnected StateInformationFailureType = "acDisconnected" + StateInformationFailureTypeDcDisconnected StateInformationFailureType = "dcDisconnected" + StateInformationFailureTypeCabinetOpen StateInformationFailureType = "cabinetOpen" + StateInformationFailureTypeOverTemperature StateInformationFailureType = "overTemperature" + StateInformationFailureTypeUnderTemperature StateInformationFailureType = "underTemperature" + StateInformationFailureTypeFrequencyAboveLimit StateInformationFailureType = "frequencyAboveLimit" + StateInformationFailureTypeFrequencyBelowLimit StateInformationFailureType = "frequencyBelowLimit" + StateInformationFailureTypeAcVoltageAboveLimit StateInformationFailureType = "acVoltageAboveLimit" + StateInformationFailureTypeAcVoltageBelowLimit StateInformationFailureType = "acVoltageBelowLimit" + StateInformationFailureTypeDcVoltageAboveLimit StateInformationFailureType = "dcVoltageAboveLimit" + StateInformationFailureTypeDcVoltageBelowLimit StateInformationFailureType = "dcVoltageBelowLimit" + StateInformationFailureTypeHardwareTestFailure StateInformationFailureType = "hardwareTestFailure" + StateInformationFailureTypeGenericInternalError StateInformationFailureType = "genericInternalError" +) + +type StateInformationCategoryType string + +const ( + StateInformationCategoryTypeFunctionality StateInformationCategoryType = "functionality" + StateInformationCategoryTypeFailure StateInformationCategoryType = "failure" +) + +type StateInformationDataType struct { + StateInformationId *StateInformationIdType `json:"stateInformationId,omitempty" eebus:"key"` + StateInformation *StateInformationType `json:"stateInformation,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + Category *StateInformationCategoryType `json:"category,omitempty"` + TimeOfLastChange *AbsoluteOrRelativeTimeType `json:"timeOfLastChange,omitempty"` +} + +type StateInformationDataElementsType struct { + StateInformationId *ElementTagType `json:"stateInformationId,omitempty"` + StateInformation *ElementTagType `json:"stateInformation,omitempty"` + IsActive *ElementTagType `json:"isActive,omitempty"` + Category *ElementTagType `json:"category,omitempty"` + TimeOfLastChange *ElementTagType `json:"timeOfLastChange,omitempty"` +} + +type StateInformationListDataType struct { + StateInformationData []StateInformationDataType `json:"stateInformationData,omitempty"` +} + +type StateInformationListDataSelectorsType struct { + StateInformationId *StateInformationIdType `json:"stateInformationId,omitempty"` + StateInformation *StateInformationType `json:"stateInformation,omitempty"` + IsActive *bool `json:"isActive,omitempty"` + Category *StateInformationCategoryType `json:"category,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/stateinformation_additions.go b/src/eebus-bridge/third_party/spine-go/model/stateinformation_additions.go new file mode 100644 index 0000000..732ff5d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/stateinformation_additions.go @@ -0,0 +1,20 @@ +package model + +// StateInformationListDataType + +var _ Updater = (*StateInformationListDataType)(nil) + +func (r *StateInformationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []StateInformationDataType + if newList != nil { + newData = newList.(*StateInformationListDataType).StateInformationData + } + + data, success := UpdateList(remoteWrite, r.StateInformationData, newData, filterPartial, filterDelete) + + if success && persist { + r.StateInformationData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement.go b/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement.go new file mode 100644 index 0000000..d571400 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement.go @@ -0,0 +1,53 @@ +package model + +type SubscriptionIdType uint + +type SubscriptionManagementEntryDataType struct { + SubscriptionId *SubscriptionIdType `json:"subscriptionId,omitempty" eebus:"key"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type SubscriptionManagementEntryDataElementsType struct { + SubscriptionId *ElementTagType `json:"subscriptionId,omitempty"` + ClientAddress *FeatureAddressElementsType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressElementsType `json:"serverAddress,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type SubscriptionManagementEntryListDataType struct { + SubscriptionManagementEntryData []SubscriptionManagementEntryDataType `json:"subscriptionManagementEntryData,omitempty"` +} + +type SubscriptionManagementEntryListDataSelectorsType struct { + SubscriptionId *SubscriptionIdType `json:"subscriptionId,omitempty"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` +} + +type SubscriptionManagementRequestCallType struct { + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` + ServerFeatureType *FeatureTypeType `json:"serverFeatureType,omitempty"` +} + +type SubscriptionManagementRequestCallElementsType struct { + ClientAddress *FeatureAddressElementsType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressElementsType `json:"serverAddress,omitempty"` + ServerFeatureType *ElementTagType `json:"serverFeatureType,omitempty"` +} + +type SubscriptionManagementDeleteCallType struct { + SubscriptionId *SubscriptionIdType `json:"subscriptionId,omitempty"` + ClientAddress *FeatureAddressType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressType `json:"serverAddress,omitempty"` +} + +type SubscriptionManagementDeleteCallElementsType struct { + SubscriptionId *ElementTagType `json:"subscriptionId,omitempty"` + ClientAddress *FeatureAddressElementsType `json:"clientAddress,omitempty"` + ServerAddress *FeatureAddressElementsType `json:"serverAddress,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement_additions.go b/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement_additions.go new file mode 100644 index 0000000..b93a55b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/subscriptionmanagement_additions.go @@ -0,0 +1,20 @@ +package model + +// SubscriptionManagementEntryListDataType + +var _ Updater = (*SubscriptionManagementEntryListDataType)(nil) + +func (r *SubscriptionManagementEntryListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SubscriptionManagementEntryDataType + if newList != nil { + newData = newList.(*SubscriptionManagementEntryListDataType).SubscriptionManagementEntryData + } + + data, success := UpdateList(remoteWrite, r.SubscriptionManagementEntryData, newData, filterPartial, filterDelete) + + if success && persist { + r.SubscriptionManagementEntryData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/supplyconditions.go b/src/eebus-bridge/third_party/spine-go/model/supplyconditions.go new file mode 100644 index 0000000..91cbf63 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/supplyconditions.go @@ -0,0 +1,112 @@ +package model + +type ConditionIdType uint + +type SupplyConditionEventTypeType string + +const ( + SupplyConditionEventTypeTypeThesholdExceeded SupplyConditionEventTypeType = "thesholdExceeded" + SupplyConditionEventTypeTypeFallenBelowThreshold SupplyConditionEventTypeType = "fallenBelowThreshold" + SupplyConditionEventTypeTypeSupplyInterrupt SupplyConditionEventTypeType = "supplyInterrupt" + SupplyConditionEventTypeTypeReleaseOfLimitations SupplyConditionEventTypeType = "releaseOfLimitations" + SupplyConditionEventTypeTypeOtherProblem SupplyConditionEventTypeType = "otherProblem" + SupplyConditionEventTypeTypeGridConditionUpdate SupplyConditionEventTypeType = "gridConditionUpdate" +) + +type SupplyConditionOriginatorType string + +const ( + SupplyConditionOriginatorTypeExternDSO SupplyConditionOriginatorType = "externDSO" + SupplyConditionOriginatorTypeExternSupplier SupplyConditionOriginatorType = "externSupplier" + SupplyConditionOriginatorTypeInternalLimit SupplyConditionOriginatorType = "internalLimit" + SupplyConditionOriginatorTypeInternalService SupplyConditionOriginatorType = "internalService" + SupplyConditionOriginatorTypeInternalUser SupplyConditionOriginatorType = "internalUser" +) + +type GridConditionType string + +const ( + GridConditionTypeConsumptionRed GridConditionType = "consumptionRed" + GridConditionTypeConsumptionYellow GridConditionType = "consumptionYellow" + GridConditionTypeGood GridConditionType = "good" + GridConditionTypeProductionRed GridConditionType = "productionRed" + GridConditionTypeProductionYellow GridConditionType = "productionYellow" +) + +type SupplyConditionDataType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty" eebus:"key"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + EventType *SupplyConditionEventTypeType `json:"eventType,omitempty"` + Originator *SupplyConditionOriginatorType `json:"originator,omitempty"` + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` + ThresholdPercentage *ScaledNumberType `json:"thresholdPercentage,omitempty"` + RelevantPeriod *TimePeriodType `json:"relevantPeriod,omitempty"` + Description *DescriptionType `json:"description,omitempty"` + GridCondition *GridConditionType `json:"gridCondition,omitempty"` +} + +type SupplyConditionDataElementsType struct { + ConditionId *ElementTagType `json:"conditionId,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + EventType *ElementTagType `json:"eventType,omitempty"` + Originator *ElementTagType `json:"originator,omitempty"` + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` + ThresholdPercentage *ScaledNumberElementsType `json:"thresholdPercentage,omitempty"` + RelevantPeriod *TimePeriodElementsType `json:"relevantPeriod,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + GridCondition *ElementTagType `json:"gridCondition,omitempty"` +} + +type SupplyConditionListDataType struct { + SupplyConditionData []SupplyConditionDataType `json:"supplyConditionData,omitempty"` +} + +type SupplyConditionListDataSelectorsType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty"` + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` + EventType *SupplyConditionEventTypeType `json:"eventType,omitempty"` + Originator *SupplyConditionOriginatorType `json:"originator,omitempty"` +} + +type SupplyConditionDescriptionDataType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty" eebus:"key"` + CommodityType *CommodityTypeType `json:"commodityType,omitempty"` + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type SupplyConditionDescriptionDataElementsType struct { + ConditionId *ElementTagType `json:"conditionId,omitempty"` + CommodityType *ElementTagType `json:"commodityType,omitempty"` + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type SupplyConditionDescriptionListDataType struct { + SupplyConditionDescriptionData []SupplyConditionDescriptionDataType `json:"supplyConditionDescriptionData,omitempty"` +} + +type SupplyConditionDescriptionListDataSelectorsType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty"` +} + +type SupplyConditionThresholdRelationDataType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty" eebus:"key"` + ThresholdId []ThresholdIdType `json:"thresholdId,omitempty"` +} + +type SupplyConditionThresholdRelationDataElementsType struct { + ConditionId *ElementTagType `json:"conditionId,omitempty"` + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` +} + +type SupplyConditionThresholdRelationListDataType struct { + SupplyConditionThresholdRelationData []SupplyConditionThresholdRelationDataType `json:"SupplyConditionThresholdRelationDataType,omitempty"` +} + +type SupplyConditionThresholdRelationListDataSelectorsType struct { + ConditionId *ConditionIdType `json:"conditionId,omitempty"` + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/supplyconditions_additions.go b/src/eebus-bridge/third_party/spine-go/model/supplyconditions_additions.go new file mode 100644 index 0000000..6c5e9b0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/supplyconditions_additions.go @@ -0,0 +1,58 @@ +package model + +// SupplyConditionListDataType + +var _ Updater = (*SupplyConditionListDataType)(nil) + +func (r *SupplyConditionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SupplyConditionDataType + if newList != nil { + newData = newList.(*SupplyConditionListDataType).SupplyConditionData + } + + data, success := UpdateList(remoteWrite, r.SupplyConditionData, newData, filterPartial, filterDelete) + + if success && persist { + r.SupplyConditionData = data + } + + return data, success +} + +// SupplyConditionDescriptionListDataType + +var _ Updater = (*SupplyConditionDescriptionListDataType)(nil) + +func (r *SupplyConditionDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SupplyConditionDescriptionDataType + if newList != nil { + newData = newList.(*SupplyConditionDescriptionListDataType).SupplyConditionDescriptionData + } + + data, success := UpdateList(remoteWrite, r.SupplyConditionDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.SupplyConditionDescriptionData = data + } + + return data, success +} + +// SupplyConditionThresholdRelationListDataType + +var _ Updater = (*SupplyConditionThresholdRelationListDataType)(nil) + +func (r *SupplyConditionThresholdRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SupplyConditionThresholdRelationDataType + if newList != nil { + newData = newList.(*SupplyConditionThresholdRelationListDataType).SupplyConditionThresholdRelationData + } + + data, success := UpdateList(remoteWrite, r.SupplyConditionThresholdRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.SupplyConditionThresholdRelationData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/tariffinformation.go b/src/eebus-bridge/third_party/spine-go/model/tariffinformation.go new file mode 100644 index 0000000..9e2155a --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/tariffinformation.go @@ -0,0 +1,370 @@ +package model + +type TariffIdType uint + +type TariffCountType TariffIdType + +type TierBoundaryIdType uint + +type TierBoundaryCountType TierBoundaryIdType + +type TierBoundaryTypeType string + +const ( + TierBoundaryTypeTypePowerBoundary TierBoundaryTypeType = "powerBoundary" + TierBoundaryTypeTypeEnergyBoundary TierBoundaryTypeType = "energyBoundary" + TierBoundaryTypeTypeCountBoundary TierBoundaryTypeType = "countBoundary" +) + +type CommodityIdType uint + +type TierIdType uint + +type TierCountType TierIdType + +type TierTypeType string + +const ( + TierTypeTypeFixedCost TierTypeType = "fixedCost" + TierTypeTypeDynamicCost TierTypeType = "dynamicCost" +) + +type IncentiveIdType uint + +type IncentiveCountType IncentiveIdType + +type IncentiveTypeType string + +const ( + IncentiveTypeTypeAbsoluteCost IncentiveTypeType = "absoluteCost" + IncentiveTypeTypeRelativeCost IncentiveTypeType = "relativeCost" + IncentiveTypeTypeRenewableEnergyPercentage IncentiveTypeType = "renewableEnergyPercentage" + IncentiveTypeTypeCo2Emission IncentiveTypeType = "co2Emission" +) + +type IncentivePriorityType uint + +type IncentiveValueTypeType string + +const ( + IncentiveValueTypeTypeValue IncentiveValueTypeType = "value" + IncentiveValueTypeTypeAverageValue IncentiveValueTypeType = "averageValue" + IncentiveValueTypeTypeMinvalue IncentiveValueTypeType = "minValue" + IncentiveValueTypeTypeMaxvalue IncentiveValueTypeType = "maxValue" +) + +type TariffOverallConstraintsDataType struct { + MaxTariffCount *TariffCountType `json:"maxTariffCount,omitempty"` + MaxBoundaryCount *TierBoundaryCountType `json:"maxBoundaryCount,omitempty"` + MaxTierCount *TierCountType `json:"maxTierCount,omitempty"` + MaxIncentiveCount *IncentiveCountType `json:"maxIncentiveCount,omitempty"` + MaxBoundariesPerTariff *TierBoundaryCountType `json:"maxBoundariesPerTariff,omitempty"` + MaxTiersPerTariff *TierCountType `json:"maxTiersPerTariff,omitempty"` + MaxBoundariesPerTier *TierBoundaryCountType `json:"maxBoundariesPerTier,omitempty"` + MaxIncentivesPerTier *IncentiveCountType `json:"maxIncentivesPerTier,omitempty"` +} + +type TariffOverallConstraintsDataElementsType struct { + MaxTariffCount *ElementTagType `json:"maxTariffCount,omitempty"` + MaxBoundaryCount *ElementTagType `json:"maxBoundaryCount,omitempty"` + MaxTierCount *ElementTagType `json:"maxTierCount,omitempty"` + MaxIncentiveCount *ElementTagType `json:"maxIncentiveCount,omitempty"` + MaxBoundariesPerTariff *ElementTagType `json:"maxBoundariesPerTariff,omitempty"` + MaxTiersPerTariff *ElementTagType `json:"maxTiersPerTariff,omitempty"` + MaxBoundariesPerTier *ElementTagType `json:"maxBoundariesPerTier,omitempty"` + MaxIncentivesPerTier *ElementTagType `json:"maxIncentivesPerTier,omitempty"` +} + +type TariffDataType struct { + TariffId *TariffIdType `json:"tariffId,omitempty" eebus:"key"` + ActiveTierId []TierIdType `json:"activeTierId,omitempty"` +} + +type TariffDataElementsType struct { + TariffId *ElementTagType `json:"tariffId,omitempty"` + ActiveTierId *ElementTagType `json:"activeTierId,omitempty"` +} + +type TariffListDataType struct { + TariffData []TariffDataType `json:"tariffData,omitempty"` +} + +type TariffListDataSelectorsType struct { + TariffId *TariffIdType `json:"tariffId,omitempty"` + ActiveTierId *TierIdType `json:"activeTierId,omitempty"` +} + +type TariffTierRelationDataType struct { + TariffId *TariffIdType `json:"tariffId,omitempty" eebus:"key"` + TierId []TierIdType `json:"tierId,omitempty"` +} + +type TariffTierRelationDataElementsType struct { + TariffId *ElementTagType `json:"tariffId,omitempty"` + TierId *ElementTagType `json:"tierId,omitempty"` +} + +type TariffTierRelationListDataType struct { + TariffTierRelationData []TariffTierRelationDataType `json:"tariffTierRelationData,omitempty"` +} + +type TariffTierRelationListDataSelectorsType struct { + TariffId *TariffIdType `json:"tariffId,omitempty"` + TierId *TierIdType `json:"tierId,omitempty"` +} + +type TariffBoundaryRelationDataType struct { + TariffId *TariffIdType `json:"tariffId,omitempty" eebus:"key"` + BoundaryId []TierBoundaryIdType `json:"boundaryId,omitempty"` +} + +type TariffBoundaryRelationDataElementsType struct { + TariffId *ElementTagType `json:"tariffId,omitempty"` + BoundaryId *ElementTagType `json:"boundaryId,omitempty"` +} + +type TariffBoundaryRelationListDataType struct { + TariffBoundaryRelationData []TariffBoundaryRelationDataType `json:"tariffBoundaryRelationData,omitempty"` +} + +type TariffBoundaryRelationListDataSelectorsType struct { + TariffId *TariffIdType `json:"tariffId,omitempty"` + BoundaryId *TierBoundaryIdType `json:"boundaryId,omitempty"` +} + +type TariffDescriptionDataType struct { + TariffId *TariffIdType `json:"tariffId,omitempty" eebus:"key"` + CommodityId *CommodityIdType `json:"commodityId,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + TariffWriteable *bool `json:"tariffWriteable,omitempty"` + UpdateRequired *bool `json:"updateRequired,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` + SlotIdSupport *bool `json:"slotIdSupport,omitempty"` +} + +type TariffDescriptionDataElementsType struct { + TariffId *ElementTagType `json:"tariffId,omitempty"` + CommodityId *ElementTagType `json:"commodityId,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + TariffWriteable *ElementTagType `json:"tariffWriteable,omitempty"` + UpdateRequired *ElementTagType `json:"updateRequired,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + SlotIdSupport *ElementTagType `json:"slotIdSupport,omitempty"` +} + +type TariffDescriptionListDataType struct { + TariffDescriptionData []TariffDescriptionDataType `json:"tariffDescriptionData,omitempty"` +} + +type TariffDescriptionListDataSelectorsType struct { + TariffId *TariffIdType `json:"tariffId,omitempty"` + CommodityId *CommodityIdType `json:"commodityId,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type TierBoundaryDataType struct { + BoundaryId *TierBoundaryIdType `json:"boundaryId,omitempty" eebus:"key"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` + LowerBoundaryValue *ScaledNumberType `json:"lowerBoundaryValue,omitempty"` + UpperBoundaryValue *ScaledNumberType `json:"upperBoundaryValue,omitempty"` +} + +type TierBoundaryDataElementsType struct { + BoundaryId *ElementTagType `json:"boundaryId,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + LowerBoundaryValue *ScaledNumberElementsType `json:"lowerBoundaryValue,omitempty"` + UpperBoundaryValue *ScaledNumberElementsType `json:"upperBoundaryValue,omitempty"` +} + +type TierBoundaryListDataType struct { + TierBoundaryData []TierBoundaryDataType `json:"tierBoundaryData,omitempty"` +} + +type TierBoundaryListDataSelectorsType struct { + BoundaryId *TierBoundaryIdType `json:"boundaryId,omitempty"` +} + +type TierBoundaryDescriptionDataType struct { + BoundaryId *TierBoundaryIdType `json:"boundaryId,omitempty" eebus:"key"` + BoundaryType *TierBoundaryTypeType `json:"boundaryType,omitempty"` + ValidForTierId *TierIdType `json:"validForTierId,omitempty"` + SwitchToTierIdWhenLower *TierIdType `json:"switchToTierIdWhenLower,omitempty"` + SwitchToTierIdWhenHigher *TierIdType `json:"switchToTierIdWhenHigher,omitempty"` + BoundaryUnit *UnitOfMeasurementType `json:"boundaryUnit,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type TierBoundaryDescriptionDataElementsType struct { + BoundaryId *ElementTagType `json:"boundaryId,omitempty"` + BoundaryType *ElementTagType `json:"boundaryType,omitempty"` + ValidForTierId *ElementTagType `json:"validForTierId,omitempty"` + SwitchToTierIdWhenLower *ElementTagType `json:"switchToTierIdWhenLower,omitempty"` + SwitchToTierIdWhenHigher *ElementTagType `json:"switchToTierIdWhenHigher,omitempty"` + BoundaryUnit *ElementTagType `json:"boundaryUnit,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type TierBoundaryDescriptionListDataType struct { + TierBoundaryDescriptionData []TierBoundaryDescriptionDataType `json:"tierBoundaryDescriptionData,omitempty"` +} + +type TierBoundaryDescriptionListDataSelectorsType struct { + BoundaryId *TierBoundaryIdType `json:"boundaryId,omitempty"` + BoundaryType *TierBoundaryTypeType `json:"boundaryType,omitempty"` +} + +type CommodityDataType struct { + CommodityId *CommodityIdType `json:"commodityId,omitempty" eebus:"key"` + CommodityType *CommodityTypeType `json:"commodityType,omitempty"` + PositiveEnergyDirection *EnergyDirectionType `json:"positiveEnergyDirection,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type CommodityDataElementsType struct { + CommodityId *ElementTagType `json:"commodityId,omitempty"` + CommodityType *ElementTagType `json:"commodityType,omitempty"` + PositiveEnergyDirection *ElementTagType `json:"positiveEnergyDirection,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type CommodityListDataType struct { + CommodityData []CommodityDataType `json:"commodityData,omitempty"` +} + +type CommodityListDataSelectorsType struct { + CommodityId *CommodityIdType `json:"commodityId,omitempty"` + CommodityType *CommodityTypeType `json:"commodityType,omitempty"` +} + +type TierDataType struct { + TierId *TierIdType `json:"tierId,omitempty" eebus:"key"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` + ActiveIncentiveId []IncentiveIdType `json:"activeIncentiveId,omitempty"` +} + +type TierDataElementsType struct { + TierId *ElementTagType `json:"tierId,omitempty"` + TimePeriod *ElementTagType `json:"timePeriod,omitempty"` + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + ActiveIncentiveId *ElementTagType `json:"activeIncentiveId,omitempty"` +} + +type TierListDataType struct { + TierData []TierDataType `json:"tierData,omitempty"` +} + +type TierListDataSelectorsType struct { + TierId *TierIdType `json:"tierId,omitempty"` + ActiveIncentiveId *IncentiveIdType `json:"activeIncentiveId,omitempty"` +} + +type TierIncentiveRelationDataType struct { + TierId *TierIdType `json:"tierId,omitempty" eebus:"key"` + IncentiveId []IncentiveIdType `json:"incentiveId,omitempty"` +} + +type TierIncentiveRelationDataElementsType struct { + TierId *ElementTagType `json:"tierId,omitempty"` + IncentiveId *ElementTagType `json:"incentiveId,omitempty"` +} + +type TierIncentiveRelationListDataType struct { + TierIncentiveRelationData []TierIncentiveRelationDataType `json:"tierIncentiveRelationData,omitempty"` +} + +type TierIncentiveRelationListDataSelectorsType struct { + TierId *TierIdType `json:"tierId,omitempty"` + IncentiveId *IncentiveIdType `json:"incentiveId,omitempty"` +} + +type TierDescriptionDataType struct { + TierId *TierIdType `json:"tierId,omitempty" eebus:"key"` + TierType *TierTypeType `json:"tierType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type TierDescriptionDataElementsType struct { + TierId *ElementTagType `json:"tierId,omitempty"` + TierType *ElementTagType `json:"tierType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type TierDescriptionListDataType struct { + TierDescriptionData []TierDescriptionDataType `json:"tierDescriptionData,omitempty"` +} + +type TierDescriptionListDataSelectorsType struct { + TierId *TierIdType `json:"tierId,omitempty"` + TierType *TierTypeType `json:"tierType,omitempty"` +} + +type IncentiveDataType struct { + IncentiveId *IncentiveIdType `json:"incentiveId,omitempty" eebus:"key"` + ValueType *IncentiveValueTypeType `json:"valueType,omitempty"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` +} + +type IncentiveDataElementsType struct { + IncentiveId *ElementTagType `json:"incentiveId,omitempty"` + ValueType *ElementTagType `json:"valueType,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` +} + +type IncentiveListDataType struct { + IncentiveData []IncentiveDataType `json:"incentiveData,omitempty"` +} + +type IncentiveListDataSelectorsType struct { + IncentiveId *IncentiveIdType `json:"incentiveId,omitempty"` + ValueType *IncentiveValueTypeType `json:"valueType,omitempty"` + TimestampInterval *TimestampIntervalType `json:"timestampInterval,omitempty"` +} + +type IncentiveDescriptionDataType struct { + IncentiveId *IncentiveIdType `json:"incentiveId,omitempty" eebus:"key"` + IncentiveType *IncentiveTypeType `json:"incentiveType,omitempty"` + IncentivePriority *IncentivePriorityType `json:"incentivePriority,omitempty"` + Currency *CurrencyType `json:"currency,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type IncentiveDescriptionDataElementsType struct { + IncentiveId *ElementTagType `json:"incentiveId,omitempty"` + IncentiveType *ElementTagType `json:"incentiveType,omitempty"` + IncentivePriority *ElementTagType `json:"incentivePriority,omitempty"` + Currency *ElementTagType `json:"currency,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type IncentiveDescriptionListDataType struct { + IncentiveDescriptionData []IncentiveDescriptionDataType `json:"incentiveDescriptionData,omitempty"` +} + +type IncentiveDescriptionListDataSelectorsType struct { + IncentiveId *IncentiveIdType `json:"incentiveId,omitempty"` + IncentiveType *IncentiveTypeType `json:"incentiveType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/tariffinformation_additions.go b/src/eebus-bridge/third_party/spine-go/model/tariffinformation_additions.go new file mode 100644 index 0000000..0e55e46 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/tariffinformation_additions.go @@ -0,0 +1,229 @@ +package model + +// TariffListDataType + +var _ Updater = (*TariffListDataType)(nil) + +func (r *TariffListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TariffDataType + if newList != nil { + newData = newList.(*TariffListDataType).TariffData + } + + data, success := UpdateList(remoteWrite, r.TariffData, newData, filterPartial, filterDelete) + + if success && persist { + r.TariffData = data + } + + return data, success +} + +// TariffTierRelationListDataType + +var _ Updater = (*TariffTierRelationListDataType)(nil) + +func (r *TariffTierRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TariffTierRelationDataType + if newList != nil { + newData = newList.(*TariffTierRelationListDataType).TariffTierRelationData + } + + data, success := UpdateList(remoteWrite, r.TariffTierRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.TariffTierRelationData = data + } + + return data, success +} + +// TariffBoundaryRelationListDataType + +var _ Updater = (*TariffBoundaryRelationListDataType)(nil) + +func (r *TariffBoundaryRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TariffBoundaryRelationDataType + if newList != nil { + newData = newList.(*TariffBoundaryRelationListDataType).TariffBoundaryRelationData + } + + data, success := UpdateList(remoteWrite, r.TariffBoundaryRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.TariffBoundaryRelationData = data + } + + return data, success +} + +// TariffDescriptionListDataType + +var _ Updater = (*TariffDescriptionListDataType)(nil) + +func (r *TariffDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TariffDescriptionDataType + if newList != nil { + newData = newList.(*TariffDescriptionListDataType).TariffDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TariffDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TariffDescriptionData = data + } + + return data, success +} + +// TierBoundaryListDataType + +var _ Updater = (*TierBoundaryListDataType)(nil) + +func (r *TierBoundaryListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TierBoundaryDataType + if newList != nil { + newData = newList.(*TierBoundaryListDataType).TierBoundaryData + } + + data, success := UpdateList(remoteWrite, r.TierBoundaryData, newData, filterPartial, filterDelete) + + if success && persist { + r.TierBoundaryData = data + } + + return data, success +} + +// TierBoundaryDescriptionListDataType + +var _ Updater = (*TierBoundaryDescriptionListDataType)(nil) + +func (r *TierBoundaryDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TierBoundaryDescriptionDataType + if newList != nil { + newData = newList.(*TierBoundaryDescriptionListDataType).TierBoundaryDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TierBoundaryDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TierBoundaryDescriptionData = data + } + + return data, success +} + +// CommodityListDataType + +var _ Updater = (*CommodityListDataType)(nil) + +func (r *CommodityListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []CommodityDataType + if newList != nil { + newData = newList.(*CommodityListDataType).CommodityData + } + + data, success := UpdateList(remoteWrite, r.CommodityData, newData, filterPartial, filterDelete) + + if success && persist { + r.CommodityData = data + } + + return data, success +} + +// TierListDataType + +var _ Updater = (*TierListDataType)(nil) + +func (r *TierListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TierDataType + if newList != nil { + newData = newList.(*TierListDataType).TierData + } + + data, success := UpdateList(remoteWrite, r.TierData, newData, filterPartial, filterDelete) + + if success && persist { + r.TierData = data + } + + return data, success +} + +// TierIncentiveRelationListDataType + +var _ Updater = (*TierIncentiveRelationListDataType)(nil) + +func (r *TierIncentiveRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TierIncentiveRelationDataType + if newList != nil { + newData = newList.(*TierIncentiveRelationListDataType).TierIncentiveRelationData + } + + data, success := UpdateList(remoteWrite, r.TierIncentiveRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.TierIncentiveRelationData = data + } + + return data, success +} + +// TierDescriptionListDataType + +var _ Updater = (*TierDescriptionListDataType)(nil) + +func (r *TierDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TierDescriptionDataType + if newList != nil { + newData = newList.(*TierDescriptionListDataType).TierDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TierDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TierDescriptionData = data + } + + return data, success +} + +// IncentiveListDataType + +var _ Updater = (*IncentiveListDataType)(nil) + +func (r *IncentiveListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []IncentiveDataType + if newList != nil { + newData = newList.(*IncentiveListDataType).IncentiveData + } + + data, success := UpdateList(remoteWrite, r.IncentiveData, newData, filterPartial, filterDelete) + + if success && persist { + r.IncentiveData = data + } + + return data, success +} + +// IncentiveDescriptionListDataType + +var _ Updater = (*IncentiveDescriptionListDataType)(nil) + +func (r *IncentiveDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []IncentiveDescriptionDataType + if newList != nil { + newData = newList.(*IncentiveDescriptionListDataType).IncentiveDescriptionData + } + + data, success := UpdateList(remoteWrite, r.IncentiveDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.IncentiveDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/taskmanagement.go b/src/eebus-bridge/third_party/spine-go/model/taskmanagement.go new file mode 100644 index 0000000..73886d3 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/taskmanagement.go @@ -0,0 +1,159 @@ +package model + +type TaskManagementJobIdType uint + +type TaskManagementJobStateType string + +const ( + // DirectControlActivityStateType + TaskManagementJobStateTypeRunning TaskManagementJobStateType = "Running" + TaskManagementJobStateTypePaused TaskManagementJobStateType = "paused" + TaskManagementJobStateTypeInactive TaskManagementJobStateType = "inactive" + + // HvacOverrunStatusType + TaskManagementJobStateTypeActive TaskManagementJobStateType = "active" + TaskManagementJobStateTypeFinished TaskManagementJobStateType = "finished" + + // LoadControlEventStateType + TaskManagementJobStateTypeEventAccepted TaskManagementJobStateType = "eventAccepted" + TaskManagementJobStateTypeEventStarted TaskManagementJobStateType = "eventStarted" + TaskManagementJobStateTypeEventStopped TaskManagementJobStateType = "eventStopped" + TaskManagementJobStateTypeEventRejected TaskManagementJobStateType = "eventRejected" + TaskManagementJobStateTypeEventCancelled TaskManagementJobStateType = "eventCancelled" + TaskManagementJobStateTypeEventError TaskManagementJobStateType = "eventError" + + // PowerSequenceStateType + TaskManagementJobStateTypeScheduled TaskManagementJobStateType = "scheduled" + TaskManagementJobStateTypeScheduledPaused TaskManagementJobStateType = "scheduledPaused" + TaskManagementJobStateTypePending TaskManagementJobStateType = "pending" + TaskManagementJobStateTypeCompleted TaskManagementJobStateType = "completed" + TaskManagementJobStateTypeInvalid TaskManagementJobStateType = "invalid" +) + +type TaskManagementJobSourceType string + +const ( + TaskManagementJobSourceTypeInternalMechanism TaskManagementJobSourceType = "InternalMechanism" + TaskManagementJobSourceTypeUserInteraction TaskManagementJobSourceType = "UserInteraction" + TaskManagementJobSourceTypeExternalConfiguration TaskManagementJobSourceType = "ExternalConfiguration" +) + +type TaskManagementDirectControlRelatedType struct{} + +type TaskManagementDirectControlRelatedElementsType struct{} + +type TaskManagementHvacRelatedType struct { + OverrunId *HvacOverrunIdType `json:"overrunId,omitempty"` +} + +type TaskManagementHvacRelatedElementsType struct { + OverrunId *ElementTagType `json:"overrunId,omitempty"` +} + +type TaskManagementLoadControlReleatedType struct { + EventId *LoadControlEventIdType `json:"eventId,omitempty"` +} + +type TaskManagementLoadControlReleatedElementsType struct { + EventId *ElementTagType `json:"eventId,omitempty"` +} + +type TaskManagementPowerSequencesRelatedType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type TaskManagementPowerSequencesRelatedElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type TaskManagementSmartEnergyManagementPsRelatedType struct { + SequenceId *PowerSequenceIdType `json:"sequenceId,omitempty"` +} + +type TaskManagementSmartEnergyManagementPsRelatedElementsType struct { + SequenceId *ElementTagType `json:"sequenceId,omitempty"` +} + +type TaskManagementJobDataType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty" eebus:"key"` + Timestamp *AbsoluteOrRelativeTimeType `json:"timestamp,omitempty"` + JobState *TaskManagementJobStateType `json:"jobState,omitempty"` + ElapsedTime *DurationType `json:"elapsedTime,omitempty"` + RemainingTime *DurationType `json:"remainingTime,omitempty"` +} + +type TaskManagementJobDataElementsType struct { + JobId *ElementTagType `json:"jobId,omitempty"` + Timestamp *ElementTagType `json:"timestamp,omitempty"` + JobState *ElementTagType `json:"jobState,omitempty"` + ElapsedTime *ElementTagType `json:"elapsedTime,omitempty"` + RemainingTime *ElementTagType `json:"remainingTime,omitempty"` +} + +type TaskManagementJobListDataType struct { + TaskManagementJobData []TaskManagementJobDataType `json:"taskManagementJobData,omitempty"` +} + +type TaskManagementJobListDataSelectorsType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty"` + JobState *TaskManagementJobStateType `json:"jobState,omitempty"` +} + +type TaskManagementJobRelationDataType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty" eebus:"key"` + DirectControlRelated *TaskManagementDirectControlRelatedType `json:"directControlRelated,omitempty"` + HvacRelated *TaskManagementHvacRelatedType `json:"hvacRelated,omitempty"` + LoadControlReleated *TaskManagementLoadControlReleatedType `json:"loadControlReleated,omitempty"` + PowerSequencesRelated *TaskManagementPowerSequencesRelatedType `json:"powerSequencesRelated,omitempty"` + SmartEnergyManagementPsRelated *TaskManagementSmartEnergyManagementPsRelatedType `json:"smartEnergyManagementPsRelated,omitempty"` +} + +type TaskManagementJobRelationDataElementsType struct { + JobId *ElementTagType `json:"jobId,omitempty"` + DirectControlRelated *TaskManagementDirectControlRelatedElementsType `json:"directControlRelated,omitempty"` + HvacRelated *TaskManagementHvacRelatedElementsType `json:"hvacRelated,omitempty"` + LoadControlReleated *TaskManagementLoadControlReleatedElementsType `json:"loadControlReleated,omitempty"` + PowerSequencesRelated *TaskManagementPowerSequencesRelatedElementsType `json:"powerSequencesRelated,omitempty"` + SmartEnergyManagementPsRelated *TaskManagementSmartEnergyManagementPsRelatedElementsType `json:"smartEnergyManagementPsRelated,omitempty"` +} + +type TaskManagementJobRelationListDataType struct { + TaskManagementJobRelationData []TaskManagementJobRelationDataType `json:"taskManagementJobRelationData,omitempty"` +} + +type TaskManagementJobRelationListDataSelectorsType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty"` +} + +type TaskManagementJobDescriptionDataType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty" eebus:"key"` + JobSource *TaskManagementJobSourceType `json:"jobSource,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type TaskManagementJobDescriptionDataElementsType struct { + JobId *ElementTagType `json:"jobId,omitempty"` + JobSource *ElementTagType `json:"jobSource,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type TaskManagementJobDescriptionListDataType struct { + TaskManagementJobDescriptionData []TaskManagementJobDescriptionDataType `json:"taskManagementJobDescriptionData,omitempty"` +} + +type TaskManagementJobDescriptionListDataSelectorsType struct { + JobId *TaskManagementJobIdType `json:"jobId,omitempty"` + JobSource *TaskManagementJobSourceType `json:"jobSource,omitempty"` +} + +type TaskManagementOverviewDataType struct { + RemoteControllable *bool `json:"remoteControllable,omitempty"` + JobsActive *bool `json:"jobsActive,omitempty"` +} + +type TaskManagementOverviewDataElementsType struct { + RemoteControllable *ElementTagType `json:"remoteControllable,omitempty"` + JobsActive *ElementTagType `json:"jobsActive,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/taskmanagement_additions.go b/src/eebus-bridge/third_party/spine-go/model/taskmanagement_additions.go new file mode 100644 index 0000000..c3e0d7b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/taskmanagement_additions.go @@ -0,0 +1,58 @@ +package model + +// TaskManagementJobListDataType + +var _ Updater = (*TaskManagementJobListDataType)(nil) + +func (r *TaskManagementJobListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TaskManagementJobDataType + if newList != nil { + newData = newList.(*TaskManagementJobListDataType).TaskManagementJobData + } + + data, success := UpdateList(remoteWrite, r.TaskManagementJobData, newData, filterPartial, filterDelete) + + if success && persist { + r.TaskManagementJobData = data + } + + return data, success +} + +// TaskManagementJobRelationListDataType + +var _ Updater = (*TaskManagementJobRelationListDataType)(nil) + +func (r *TaskManagementJobRelationListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TaskManagementJobRelationDataType + if newList != nil { + newData = newList.(*TaskManagementJobRelationListDataType).TaskManagementJobRelationData + } + + data, success := UpdateList(remoteWrite, r.TaskManagementJobRelationData, newData, filterPartial, filterDelete) + + if success && persist { + r.TaskManagementJobRelationData = data + } + + return data, success +} + +// TaskManagementJobDescriptionListDataType + +var _ Updater = (*TaskManagementJobDescriptionListDataType)(nil) + +func (r *TaskManagementJobDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TaskManagementJobDescriptionDataType + if newList != nil { + newData = newList.(*TaskManagementJobDescriptionListDataType).TaskManagementJobDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TaskManagementJobDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TaskManagementJobDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/threshold.go b/src/eebus-bridge/third_party/spine-go/model/threshold.go new file mode 100644 index 0000000..574bbf5 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/threshold.go @@ -0,0 +1,85 @@ +package model + +type ThresholdIdType uint + +type ThresholdTypeType string + +const ( + ThresholdTypeTypeGoodAbove ThresholdTypeType = "goodAbove" + ThresholdTypeTypeBadAbove ThresholdTypeType = "badAbove" + ThresholdTypeTypeGoodBelow ThresholdTypeType = "goodBelow" + ThresholdTypeTypeBadBelow ThresholdTypeType = "badBelow" + ThresholdTypeTypeMinValueThreshold ThresholdTypeType = "minValueThreshold" + ThresholdTypeTypeMaxValueThreshold ThresholdTypeType = "maxValueThreshold" + ThresholdTypeTypeMinValueThresholdExtreme ThresholdTypeType = "minValueThresholdExtreme" + ThresholdTypeTypeMaxValueThresholdExtreme ThresholdTypeType = "maxValueThresholdExtreme" + ThresholdTypeTypeSagThreshold ThresholdTypeType = "sagThreshold" + ThresholdTypeTypeSwellThreshold ThresholdTypeType = "swellThreshold" +) + +type ThresholdDataType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty" eebus:"key"` + ThresholdValue *ScaledNumberType `json:"thresholdValue,omitempty"` +} + +type ThresholdDataElementsType struct { + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` + ThresholdValue *ScaledNumberElementsType `json:"thresholdValue,omitempty"` +} + +type ThresholdListDataType struct { + ThresholdData []ThresholdDataType `json:"thresholdData,omitempty"` +} + +type ThresholdListDataSelectorsType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` +} + +type ThresholdConstraintsDataType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty" eebus:"key"` + ThresholdRangeMin *ScaledNumberType `json:"thresholdRangeMin,omitempty"` + ThresholdRangeMax *ScaledNumberType `json:"thresholdRangeMax,omitempty"` + ThresholdStepSize *ScaledNumberType `json:"thresholdStepSize,omitempty"` +} + +type ThresholdConstraintsDataElementsType struct { + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` + ThresholdRangeMin *ScaledNumberElementsType `json:"thresholdRangeMin,omitempty"` + ThresholdRangeMax *ScaledNumberElementsType `json:"thresholdRangeMax,omitempty"` + ThresholdStepSize *ScaledNumberElementsType `json:"thresholdStepSize,omitempty"` +} + +type ThresholdConstraintsListDataType struct { + ThresholdConstraintsData []ThresholdConstraintsDataType `json:"thresholdConstraintsData,omitempty"` +} + +type ThresholdConstraintsListDataSelectorsType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` +} + +type ThresholdDescriptionDataType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty" eebus:"key"` + ThresholdType *ThresholdTypeType `json:"thresholdType,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type ThresholdDescriptionDataElementsType struct { + ThresholdId *ElementTagType `json:"thresholdId,omitempty"` + ThresholdType *ElementTagType `json:"thresholdType,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type ThresholdDescriptionListDataType struct { + ThresholdDescriptionData []ThresholdDescriptionDataType `json:"thresholdDescriptionData,omitempty"` +} + +type ThresholdDescriptionListDataSelectorsType struct { + ThresholdId *ThresholdIdType `json:"thresholdId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/threshold_additions.go b/src/eebus-bridge/third_party/spine-go/model/threshold_additions.go new file mode 100644 index 0000000..bae9378 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/threshold_additions.go @@ -0,0 +1,58 @@ +package model + +// ThresholdListDataType + +var _ Updater = (*ThresholdListDataType)(nil) + +func (r *ThresholdListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ThresholdDataType + if newList != nil { + newData = newList.(*ThresholdListDataType).ThresholdData + } + + data, success := UpdateList(remoteWrite, r.ThresholdData, newData, filterPartial, filterDelete) + + if success && persist { + r.ThresholdData = data + } + + return data, success +} + +// ThresholdConstraintsListDataType + +var _ Updater = (*ThresholdConstraintsListDataType)(nil) + +func (r *ThresholdConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ThresholdConstraintsDataType + if newList != nil { + newData = newList.(*ThresholdConstraintsListDataType).ThresholdConstraintsData + } + + data, success := UpdateList(remoteWrite, r.ThresholdConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.ThresholdConstraintsData = data + } + + return data, success +} + +// ThresholdDescriptionListDataType + +var _ Updater = (*ThresholdDescriptionListDataType)(nil) + +func (r *ThresholdDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []ThresholdDescriptionDataType + if newList != nil { + newData = newList.(*ThresholdDescriptionListDataType).ThresholdDescriptionData + } + + data, success := UpdateList(remoteWrite, r.ThresholdDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.ThresholdDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/timeinformation.go b/src/eebus-bridge/third_party/spine-go/model/timeinformation.go new file mode 100644 index 0000000..1d8e606 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/timeinformation.go @@ -0,0 +1,41 @@ +package model + +type TimeInformationDataType struct { + Utc *DateTimeType `json:"utc,omitempty"` + UtcOffset *DurationType `json:"utcOffset,omitempty"` + DayOfWeek *DayOfWeekType `json:"dayOfWeek,omitempty"` + CalendarWeek *CalendarWeekType `json:"calendarWeek,omitempty"` +} + +type TimeInformationDataElementsType struct { + Utc *ElementTagType `json:"utc,omitempty"` + UtcOffset *ElementTagType `json:"utcOffset,omitempty"` + DayOfWeek *ElementTagType `json:"dayOfWeek,omitempty"` + CalendarWeek *ElementTagType `json:"calendarWeek,omitempty"` +} + +type TimeDistributorDataType struct { + IsTimeDistributor *bool `json:"isTimeDistributor,omitempty"` + DistributorPriority *uint `json:"distributorPriority,omitempty"` +} + +type TimeDistributorDataElementsType struct { + IsTimeDistributor *ElementTagType `json:"isTimeDistributor,omitempty"` + DistributorPriority *ElementTagType `json:"distributorPriority,omitempty"` +} + +type TimePrecisionDataType struct { + IsSynchronised *bool `json:"isSynchronised,omitempty"` + LastSyncAt *DateTimeType `json:"lastSyncAt,omitempty"` + ClockDrift *int `json:"clockDrift,omitempty"` +} + +type TimePrecisionDataElementsType struct { + IsSynchronised *ElementTagType `json:"isSynchronised,omitempty"` + LastSyncAt *ElementTagType `json:"lastSyncAt,omitempty"` + ClockDrift *ElementTagType `json:"clockDrift,omitempty"` +} + +type TimeDistributorEnquiryCallType struct{} + +type TimeDistributorEnquiryCallElementsType struct{} diff --git a/src/eebus-bridge/third_party/spine-go/model/timeseries.go b/src/eebus-bridge/third_party/spine-go/model/timeseries.go new file mode 100644 index 0000000..91cae18 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/timeseries.go @@ -0,0 +1,133 @@ +package model + +type TimeSeriesIdType uint + +type TimeSeriesSlotIdType uint + +type TimeSeriesSlotCountType TimeSeriesSlotIdType + +type TimeSeriesTypeType string + +const ( + TimeSeriesTypeTypePlan TimeSeriesTypeType = "plan" + TimeSeriesTypeTypeSingleDemand TimeSeriesTypeType = "singleDemand" + TimeSeriesTypeTypeConstraints TimeSeriesTypeType = "constraints" + TimeSeriesTypeTypeEnergyRequest TimeSeriesTypeType = "energyRequest" + TimeSeriesTypeTypeDischargingEnergyRequest TimeSeriesTypeType = "dischargingEnergyRequest" + TimeSeriesTypeTypeConsumptionLimitCurve TimeSeriesTypeType = "consumptionLimitCurve" + TimeSeriesTypeTypeProductionLimitCurve TimeSeriesTypeType = "productionLimitCurve" +) + +type TimeSeriesSlotType struct { + TimeSeriesSlotId *TimeSeriesSlotIdType `json:"timeSeriesSlotId,omitempty"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + Duration *DurationType `json:"duration,omitempty"` + RecurrenceInformation *AbsoluteOrRecurringTimeType `json:"recurrenceInformation,omitempty"` + Value *ScaledNumberType `json:"value,omitempty"` + MinValue *ScaledNumberType `json:"minValue,omitempty"` + MaxValue *ScaledNumberType `json:"maxValue,omitempty"` +} + +type TimeSeriesSlotElementsType struct { + TimeSeriesSlotId *ElementTagType `json:"timeSeriesSlotId,omitempty"` + TimePeriod *ElementTagType `json:"timePeriod,omitempty"` + Duration *ElementTagType `json:"duration,omitempty"` + RecurrenceInformation *AbsoluteOrRecurringTimeElementsType `json:"recurrenceInformation,omitempty"` + Value *ScaledNumberElementsType `json:"value,omitempty"` + MinValue *ScaledNumberElementsType `json:"minValue,omitempty"` + MaxValue *ScaledNumberElementsType `json:"maxValue,omitempty"` +} + +type TimeSeriesDataType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty" eebus:"key"` + TimePeriod *TimePeriodType `json:"timePeriod,omitempty"` + TimeSeriesSlot []TimeSeriesSlotType `json:"timeSeriesSlot"` +} + +type TimeSeriesDataElementsType struct { + TimeSeriesId *ElementTagType `json:"timeSeriesId,omitempty"` + TimePeriod *TimePeriodElementsType `json:"timePeriod,omitempty"` + TimeSeriesSlot *TimeSeriesSlotElementsType `json:"timeSeriesSlot"` +} + +type TimeSeriesListDataType struct { + TimeSeriesData []TimeSeriesDataType `json:"timeSeriesData,omitempty"` +} + +type TimeSeriesListDataSelectorsType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty"` + TimeSeriesSlotId *TimeSeriesSlotIdType `json:"timeSeriesSlotId,omitempty"` +} + +type TimeSeriesDescriptionDataType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty" eebus:"key"` + TimeSeriesType *TimeSeriesTypeType `json:"timeSeriesType,omitempty"` + TimeSeriesWriteable *bool `json:"timeSeriesWriteable,omitempty"` + UpdateRequired *bool `json:"updateRequired,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + Currency *CurrencyType `json:"currency,omitempty"` + Unit *UnitOfMeasurementType `json:"unit,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type TimeSeriesDescriptionDataElementsType struct { + TimeSeriesId *ElementTagType `json:"timeSeriesId,omitempty"` + TimeSeriesType *ElementTagType `json:"timeSeriesType,omitempty"` + TimeSeriesWriteable *ElementTagType `json:"timeSeriesWriteable,omitempty"` + UpdateRequired *ElementTagType `json:"updateRequired,omitempty"` + MeasurementId *ElementTagType `json:"measurementId,omitempty"` + Currency *ElementTagType `json:"currency,omitempty"` + Unit *ElementTagType `json:"unit,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` + ScopeType *ElementTagType `json:"scopeType,omitempty"` +} + +type TimeSeriesDescriptionListDataType struct { + TimeSeriesDescriptionData []TimeSeriesDescriptionDataType `json:"timeSeriesDescriptionData,omitempty"` +} + +type TimeSeriesDescriptionListDataSelectorsType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty"` + TimeSeriesType *TimeSeriesTypeType `json:"timeSeriesType,omitempty"` + MeasurementId *MeasurementIdType `json:"measurementId,omitempty"` + ScopeType *ScopeTypeType `json:"scopeType,omitempty"` +} + +type TimeSeriesConstraintsDataType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty" eebus:"key"` + SlotCountMin *TimeSeriesSlotCountType `json:"slotCountMin,omitempty"` + SlotCountMax *TimeSeriesSlotCountType `json:"slotCountMax,omitempty"` + SlotDurationMin *DurationType `json:"slotDurationMin,omitempty"` + SlotDurationMax *DurationType `json:"slotDurationMax,omitempty"` + SlotDurationStepSize *DurationType `json:"slotDurationStepSize,omitempty"` + EarliestTimeSeriesStartTime *AbsoluteOrRelativeTimeType `json:"earliestTimeSeriesStartTime,omitempty"` + LatestTimeSeriesEndTime *AbsoluteOrRelativeTimeType `json:"latestTimeSeriesEndTime,omitempty"` + SlotValueMin *ScaledNumberType `json:"slotValueMin,omitempty"` + SlotValueMax *ScaledNumberType `json:"slotValueMax,omitempty"` + SlotValueStepSize *ScaledNumberType `json:"slotValueStepSize,omitempty"` +} + +type TimeSeriesConstraintsDataElementsType struct { + TimeSeriesId *ElementTagType `json:"timeSeriesId,omitempty"` + SlotCountMin *ElementTagType `json:"slotCountMin,omitempty"` + SlotCountMax *ElementTagType `json:"slotCountMax,omitempty"` + SlotDurationMin *ElementTagType `json:"slotDurationMin,omitempty"` + SlotDurationMax *ElementTagType `json:"slotDurationMax,omitempty"` + SlotDurationStepSize *ElementTagType `json:"slotDurationStepSize,omitempty"` + EarliestTimeSeriesStartTime *ElementTagType `json:"earliestTimeSeriesStartTime,omitempty"` + LatestTimeSeriesEndTime *ElementTagType `json:"latestTimeSeriesEndTime,omitempty"` + SlotValueMin *ElementTagType `json:"slotValueMin,omitempty"` + SlotValueMax *ElementTagType `json:"slotValueMax,omitempty"` + SlotValueStepSize *ElementTagType `json:"slotValueStepSize,omitempty"` +} + +type TimeSeriesConstraintsListDataType struct { + TimeSeriesConstraintsData []TimeSeriesConstraintsDataType `json:"timeSeriesConstraintsData,omitempty"` +} + +type TimeSeriesConstraintsListDataSelectorsType struct { + TimeSeriesId *TimeSeriesIdType `json:"timeSeriesId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/timeseries_additions.go b/src/eebus-bridge/third_party/spine-go/model/timeseries_additions.go new file mode 100644 index 0000000..9d80407 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/timeseries_additions.go @@ -0,0 +1,58 @@ +package model + +// TimeSeriesListDataType + +var _ Updater = (*TimeSeriesListDataType)(nil) + +func (r *TimeSeriesListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeSeriesDataType + if newList != nil { + newData = newList.(*TimeSeriesListDataType).TimeSeriesData + } + + data, success := UpdateList(remoteWrite, r.TimeSeriesData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeSeriesData = data + } + + return data, success +} + +// TimeSeriesDescriptionListDataType + +var _ Updater = (*TimeSeriesDescriptionListDataType)(nil) + +func (r *TimeSeriesDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeSeriesDescriptionDataType + if newList != nil { + newData = newList.(*TimeSeriesDescriptionListDataType).TimeSeriesDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TimeSeriesDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeSeriesDescriptionData = data + } + + return data, success +} + +// TimeSeriesConstraintsListDataType + +var _ Updater = (*TimeSeriesConstraintsListDataType)(nil) + +func (r *TimeSeriesConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeSeriesConstraintsDataType + if newList != nil { + newData = newList.(*TimeSeriesConstraintsListDataType).TimeSeriesConstraintsData + } + + data, success := UpdateList(remoteWrite, r.TimeSeriesConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeSeriesConstraintsData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/timetable.go b/src/eebus-bridge/third_party/spine-go/model/timetable.go new file mode 100644 index 0000000..2a0dbfd --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/timetable.go @@ -0,0 +1,96 @@ +package model + +type TimeTableIdType uint + +type TimeSlotIdType uint + +type TimeSlotCountType TimeSlotIdType + +type TimeSlotTimeModeType string + +const ( + TimeSlotTimeModeTypeAbsolute TimeSlotTimeModeType = "absolute" + TimeSlotTimeModeTypeRecurring TimeSlotTimeModeType = "recurring" + TimeSlotTimeModeTypeBoth TimeSlotTimeModeType = "both" +) + +type TimeTableDataType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty" eebus:"key"` + TimeSlotId *TimeSlotIdType `json:"timeSlotId,omitempty"` + RecurrenceInformation *RecurrenceInformationType `json:"recurrenceInformation,omitempty"` + StartTime *AbsoluteOrRecurringTimeType `json:"startTime,omitempty"` + EndTime *AbsoluteOrRecurringTimeType `json:"endTime,omitempty"` +} + +type TimeTableDataElementsType struct { + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + TimeSlotId *ElementTagType `json:"timeSlotId,omitempty"` + RecurrenceInformation *RecurrenceInformationElementsType `json:"recurrenceInformation,omitempty"` + StartTime *AbsoluteOrRecurringTimeElementsType `json:"startTime,omitempty"` + EndTime *AbsoluteOrRecurringTimeElementsType `json:"endTime,omitempty"` +} + +type TimeTableListDataType struct { + TimeTableData []TimeTableDataType `json:"timeTableData,omitempty"` +} + +type TimeTableListDataSelectorsType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` + TimeSlotId *TimeSlotIdType `json:"timeSlotId,omitempty"` +} + +type TimeTableConstraintsDataType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty" eebus:"key"` + SlotCountMin *TimeSlotCountType `json:"slotCountMin,omitempty"` + SlotCountMax *TimeSlotCountType `json:"slotCountMax,omitempty"` + SlotDurationMin *DurationType `json:"slotDurationMin,omitempty"` + SlotDurationMax *DurationType `json:"slotDurationMax,omitempty"` + SlotDurationStepSize *DurationType `json:"slotDurationStepSize,omitempty"` + SlotShiftStepSize *DurationType `json:"slotShiftStepSize,omitempty"` + FirstSlotBeginsAt *TimeType `json:"firstSlotBeginsAt,omitempty"` +} + +type TimeTableConstraintsDataElementsType struct { + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + SlotCountMin *ElementTagType `json:"slotCountMin,omitempty"` + SlotCountMax *ElementTagType `json:"slotCountMax,omitempty"` + SlotDurationMin *ElementTagType `json:"slotDurationMin,omitempty"` + SlotDurationMax *ElementTagType `json:"slotDurationMax,omitempty"` + SlotDurationStepSize *ElementTagType `json:"slotDurationStepSize,omitempty"` + SlotShiftStepSize *ElementTagType `json:"slotShiftStepSize,omitempty"` + FirstSlotBeginsAt *ElementTagType `json:"firstSlotBeginsAt,omitempty"` +} + +type TimeTableConstraintsListDataType struct { + TimeTableConstraintsData []TimeTableConstraintsDataType `json:"timeTableConstraintsData,omitempty"` +} + +type TimeTableConstraintsListDataSelectorsType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` +} + +type TimeTableDescriptionDataType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty" eebus:"key"` + TimeSlotCountChangeable *bool `json:"timeSlotCountChangeable,omitempty"` + TimeSlotTimesChangeable *bool `json:"timeSlotTimesChangeable,omitempty"` + TimeSlotTimeMode *TimeSlotTimeModeType `json:"timeSlotTimeMode,omitempty"` + Label *LabelType `json:"label,omitempty"` + Description *DescriptionType `json:"description,omitempty"` +} + +type TimeTableDescriptionDataElementsType struct { + TimeTableId *ElementTagType `json:"timeTableId,omitempty"` + TimeSlotCountChangeable *ElementTagType `json:"timeSlotCountChangeable,omitempty"` + TimeSlotTimesChangeable *ElementTagType `json:"timeSlotTimesChangeable,omitempty"` + TimeSlotTimeMode *ElementTagType `json:"timeSlotTimeMode,omitempty"` + Label *ElementTagType `json:"label,omitempty"` + Description *ElementTagType `json:"description,omitempty"` +} + +type TimeTableDescriptionListDataType struct { + TimeTableDescriptionData []TimeTableDescriptionDataType `json:"timeTableDescriptionData,omitempty"` +} + +type TimeTableDescriptionListDataSelectorsType struct { + TimeTableId *TimeTableIdType `json:"timeTableId,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/timetable_additions.go b/src/eebus-bridge/third_party/spine-go/model/timetable_additions.go new file mode 100644 index 0000000..c030a18 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/timetable_additions.go @@ -0,0 +1,58 @@ +package model + +// TimeTableListDataType + +var _ Updater = (*TimeTableListDataType)(nil) + +func (r *TimeTableListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeTableDataType + if newList != nil { + newData = newList.(*TimeTableListDataType).TimeTableData + } + + data, success := UpdateList(remoteWrite, r.TimeTableData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeTableData = data + } + + return data, success +} + +// TimeTableConstraintsListDataType + +var _ Updater = (*TimeTableConstraintsListDataType)(nil) + +func (r *TimeTableConstraintsListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeTableConstraintsDataType + if newList != nil { + newData = newList.(*TimeTableConstraintsListDataType).TimeTableConstraintsData + } + + data, success := UpdateList(remoteWrite, r.TimeTableConstraintsData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeTableConstraintsData = data + } + + return data, success +} + +// TimeTableDescriptionListDataType + +var _ Updater = (*TimeTableDescriptionListDataType)(nil) + +func (r *TimeTableDescriptionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []TimeTableDescriptionDataType + if newList != nil { + newData = newList.(*TimeTableDescriptionListDataType).TimeTableDescriptionData + } + + data, success := UpdateList(remoteWrite, r.TimeTableDescriptionData, newData, filterPartial, filterDelete) + + if success && persist { + r.TimeTableDescriptionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/model/update.go b/src/eebus-bridge/third_party/spine-go/model/update.go new file mode 100644 index 0000000..b20ab76 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/update.go @@ -0,0 +1,391 @@ +package model + +import ( + "reflect" + "sort" + + "github.com/enbility/spine-go/util" +) + +type Updater interface { + // data model specific update function + // + // parameters: + // - remoteWrite defines if this data came on from a remote service, as that is then to + // ignore the "writecheck" tagges fields and should only be allowed to write if the "writecheck" tagged field + // boolean is set to true + // - persist defines if the data should be persisted, false used for creating full write datasets + // - newList is the new data + // - filterPartial is the partial filter + // - filterDelete is the delete filter + // + // returns: + // - the merged data + // - true if everything was successful, false if not + UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) +} + +// Generates a new list of function items by applying the rules mentioned in the spec +// (EEBus_SPINE_TS_ProtocolSpecification.pdf; chapter "5.3.4 Restricted function exchange with cmdOptions"). +// The given data provider is used the get the current items and the items and the filters in the payload. +// +// returns: +// - the new data set +// - true if everything was successful, false if not +func UpdateList[T any](remoteWrite bool, existingData []T, newData []T, filterPartial, filterDelete *FilterType) ([]T, bool) { + success := true + + // process delete filter (with selectors and elements) + if filterDelete != nil { + if filterData, err := filterDelete.Data(); err == nil { + updatedData, noErrors := deleteFilteredData(remoteWrite, existingData, filterData) + if noErrors { + existingData = updatedData + } else { + success = false + } + } + } + + // process update filter (with selectors and elements) + if filterPartial != nil { + if filterData, err := filterPartial.Data(); err == nil { + newData, noErrors := copyToSelectedData(remoteWrite, existingData, filterData, &newData[0]) + if !noErrors { + success = false + } + return newData, success + } + } + + // check if items have no identifiers + // Currently all fields marked as key are required + // TODO: check how to handle if only one identifier is provided + if len(newData) > 0 && !HasIdentifiers(newData[0]) { + // no identifiers specified --> copy data to all existing items + // (see EEBus_SPINE_TS_ProtocolSpecification.pdf, Table 7: Considered cmdOptions combinations for classifier "notify") + newData, noErrors := copyToAllData(remoteWrite, existingData, &newData[0]) + if !noErrors { + success = false + } + return newData, success + } + + result, noErrors := Merge(remoteWrite, existingData, newData) + if !noErrors { + success = false + } + + result = SortData(result) + + return result, success +} + +// return a list of field names that have the eebus tag +func fieldNamesWithEEBusTag(tag EEBusTag, item any) []string { + var result []string + + v := reflect.ValueOf(item) + t := reflect.TypeOf(item) + + if v.Kind() != reflect.Struct { + return result + } + + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + if f.Kind() != reflect.Ptr { + continue + } + + sf := v.Type().Field(i) + eebusTags := EEBusTags(sf) + _, exists := eebusTags[tag] + if !exists { + continue + } + + fieldName := t.Field(i).Name + result = append(result, fieldName) + } + + return result +} + +func HasIdentifiers(data any) bool { + keys := fieldNamesWithEEBusTag(EEBusTagKey, data) + + v := reflect.ValueOf(data) + + for _, fieldName := range keys { + f := v.FieldByName(fieldName) + + if f.IsNil() || !f.IsValid() { + return false + } + } + + return true +} + +// sort slices by fields that have eebus tag "key" +func SortData[T any](data []T) []T { + if len(data) == 0 { + return data + } + + keys := fieldNamesWithEEBusTag(EEBusTagKey, data[0]) + + if len(keys) == 0 { + return data + } + + sort.Slice(data, func(i, j int) bool { + item1 := data[i] + item2 := data[j] + + item1V := reflect.ValueOf(item1) + item2V := reflect.ValueOf(item2) + + // if the fields don't match, don't do anything + if item1V.NumField() != item2V.NumField() { + return false + } + + for _, fieldName := range keys { + f1 := item1V.FieldByName(fieldName) + f2 := item2V.FieldByName(fieldName) + if f1.Type().Kind() != reflect.Ptr || f2.Type().Kind() != reflect.Ptr { + return false + } + + if f1.IsNil() || f2.IsNil() || !f1.IsValid() || !f2.IsValid() { + return false + } + + if f1.Elem().Kind() != reflect.Uint || f2.Elem().Kind() != reflect.Uint { + return false + } + + value1 := f1.Elem().Uint() + value2 := f2.Elem().Uint() + + if value1 != value2 { + return value1 < value2 + } + } + + return false + }) + + return data +} + +// Copy data t elements matching the selected items +// +// Parameter remoteWrite defines if this data came on from a remote service, as that is then to +// ignore the "writecheck" tagges fields and should only be allowed to write if the "writecheck" tagged field +// boolean is set to true +// +// returns: +// - the new data set +// - true if everything was successful, false if not +func copyToSelectedData[T any](remoteWrite bool, existingData []T, filterData *FilterData, newData *T) ([]T, bool) { + if filterData.Selector == nil { + return existingData, true + } + + success := true + + for i := range existingData { + if filterData.SelectorMatch(util.Ptr(existingData[i])) { + writeAllowed := writeAllowed(existingData[i]) + if !writeAllowed && remoteWrite { + success = false + continue + } + + CopyNonNilDataFromItemToItem(newData, &existingData[i]) + break + } + } + return existingData, success +} + +// Copy data to all elements +// +// Parameter remoteWrite defines if this data came on from a remote service, as that is then to +// ignore the "writecheck" tagges fields and should only be allowed to write if the "writecheck" tagged field +// boolean is set to true +// +// returns: +// - the new data set +// - true if everything was successful, false if not +func copyToAllData[T any](remoteWrite bool, existingData []T, newData *T) ([]T, bool) { + success := true + + for i := range existingData { + writeAllowed := writeAllowed(existingData[i]) + if !writeAllowed && remoteWrite { + success = false + continue + } + + CopyNonNilDataFromItemToItem(newData, &existingData[i]) + } + + return existingData, success +} + +// Execute a partial delete filter +// +// Parameter remoteWrite defines if this data came on from a remote service, as that is then to +// ignore the "writecheck" tagges fields and should only be allowed to write if the "writecheck" tagged field +// boolean is set to true +// +// returns: +// - the new data set +// - true if everything was successful, false if not +func deleteFilteredData[T any](remoteWrite bool, existingData []T, filterData *FilterData) ([]T, bool) { + success := true + + if filterData.Elements == nil && filterData.Selector == nil { + return existingData, true + } + + var result []T + for i := range existingData { + writeAllowed := writeAllowed(existingData[i]) + if !writeAllowed && remoteWrite { + success = false + continue + } + + if filterData.Selector != nil && filterData.Elements != nil { + // selector and elements filter + + // remove the fields defined in element if the item matches + if filterData.SelectorMatch(util.Ptr(existingData[i])) { + RemoveElementFromItem(&existingData[i], filterData.Elements) + result = append(result, existingData[i]) + } else { + result = append(result, existingData[i]) + } + } else if filterData.Selector != nil { + // only selector filter + + // remove the whole item if the item matches + if !filterData.SelectorMatch(util.Ptr(existingData[i])) { + result = append(result, existingData[i]) + } + } else { + // only elements filter + + // remove the fields defined in element + RemoveElementFromItem(&existingData[i], filterData.Elements) + result = append(result, existingData[i]) + } + } + + return result, success +} + +func isFieldValueNil(field interface{}) bool { + if field == nil { + return true + } + + switch reflect.TypeOf(field).Kind() { + case reflect.Ptr, reflect.Map, reflect.Array, reflect.Chan, reflect.Slice: + return reflect.ValueOf(field).IsNil() + default: + return false + } +} + +func nonNilElementNames(element any) []string { + var result []string + + v := reflect.ValueOf(element).Elem() + t := reflect.TypeOf(element).Elem() + for i := 0; i < v.NumField(); i++ { + isNil := isFieldValueNil(v.Field(i).Interface()) + if !isNil { + name := t.Field(i).Name + result = append(result, name) + } + } + + return result +} + +func isStringValueInSlice(value string, list []string) bool { + for _, item := range list { + if item == value { + return true + } + } + return false +} + +func RemoveElementFromItem[T any, E any](item *T, element E) { + fieldNamesToBeRemoved := nonNilElementNames(element) + + eV := reflect.ValueOf(element).Elem() + eT := reflect.TypeOf(element).Elem() + iV := reflect.ValueOf(item).Elem() + + // if the fields don't match, don't do anything + if eV.NumField() != iV.NumField() { + return + } + + for i := 0; i < eV.NumField(); i++ { + fieldName := eT.Field(i).Name + if isStringValueInSlice(fieldName, fieldNamesToBeRemoved) { + f := iV.FieldByName(fieldName) + if !f.IsValid() { + continue + } + if !f.CanSet() { + continue + } + + f.Set(reflect.Zero(f.Type())) + } + } +} + +func CopyNonNilDataFromItemToItem[T any](source *T, destination *T) { + if source == nil || destination == nil { + return + } + + sV := reflect.ValueOf(source).Elem() + sT := reflect.TypeOf(source).Elem() + dV := reflect.ValueOf(destination).Elem() + + // if the fields don't match, don't do anything + if sV.NumField() != dV.NumField() { + return + } + + for i := 0; i < sV.NumField(); i++ { + value := sV.Field(i) + if value.IsNil() { + continue + } + + fieldName := sT.Field(i).Name + f := dV.FieldByName(fieldName) + + if !f.IsValid() { + continue + } + if !f.CanSet() { + continue + } + + f.Set(value) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/model/usecaseinformation.go b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation.go new file mode 100644 index 0000000..00fca49 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation.go @@ -0,0 +1,122 @@ +package model + +type UseCaseActorType string + +const ( + UseCaseActorTypeBattery UseCaseActorType = "Battery" + UseCaseActorTypeBatterySystem UseCaseActorType = "BatterySystem" + UseCaseActorTypeCEM UseCaseActorType = "CEM" + UseCaseActorTypeConfigurationAppliance UseCaseActorType = "ConfigurationAppliance" + UseCaseActorTypeCompressor UseCaseActorType = "Compressor" + UseCaseActorTypeControllableSystem UseCaseActorType = "ControllableSystem" + UseCaseActorTypeDHWCircuit UseCaseActorType = "DHWCircuit" + UseCaseActorTypeEnergyBroker UseCaseActorType = "EnergyBroker" + UseCaseActorTypeEnergyConsumer UseCaseActorType = "EnergyConsumer" + UseCaseActorTypeEnergyGuard UseCaseActorType = "EnergyGuard" + UseCaseActorTypeEVSE UseCaseActorType = "EVSE" + UseCaseActorTypeEV UseCaseActorType = "EV" + UseCaseActorTypeGridConnectionPoint UseCaseActorType = "GridConnectionPoint" + UseCaseActorTypeHeatPump UseCaseActorType = "HeatPump" + UseCaseActorTypeHeatingCircuit UseCaseActorType = "HeatingCircuit" + UseCaseActorTypeHeatingZone UseCaseActorType = "HeatingZone" + UseCaseActorTypeHVACRoom UseCaseActorType = "HVACRoom" + UseCaseActorTypeInverter UseCaseActorType = "Inverter" + UseCaseActorTypeMonitoredUnit UseCaseActorType = "MonitoredUnit" + UseCaseActorTypeMonitoringAppliance UseCaseActorType = "MonitoringAppliance" + UseCaseActorTypeOutdoorTemperatureSensor UseCaseActorType = "OutdoorTemperatureSensor" + UseCaseActorTypePVString UseCaseActorType = "PVString" + UseCaseActorTypePVSystem UseCaseActorType = "PVSystem" + UseCaseActorTypeSmartAppliance UseCaseActorType = "SmartAppliance" + UseCaseActorTypeVisualizationAppliance UseCaseActorType = "VisualizationAppliance" +) + +type UseCaseNameType string + +const ( + UseCaseNameTypeConfigurationOfDhwSystemFunction UseCaseNameType = "configurationOfDhwSystemFunction" + UseCaseNameTypeConfigurationOfDhwTemperature UseCaseNameType = "configurationOfDhwTemperature" + UseCaseNameTypeConfigurationOfRoomCoolingSystemFunction UseCaseNameType = "configurationOfRoomCoolingSystemFunction" + UseCaseNameTypeConfigurationOfRoomCoolingTemperature UseCaseNameType = "configurationOfRoomCoolingTemperature" + UseCaseNameTypeConfigurationOfRoomHeatingSystemFunction UseCaseNameType = "configurationOfRoomHeatingSystemFunction" + UseCaseNameTypeConfigurationOfRoomHeatingTemperature UseCaseNameType = "configurationOfRoomHeatingTemperature" + UseCaseNameTypeControlOfBattery UseCaseNameType = "controlOfBattery" + UseCaseNameTypeCoordinatedEVCharging UseCaseNameType = "coordinatedEvCharging" + UseCaseNameTypeEVChargingSummary UseCaseNameType = "evChargingSummary" + UseCaseNameTypeEVCommissioningAndConfiguration UseCaseNameType = "evCommissioningAndConfiguration" + UseCaseNameTypeEVSECommissioningAndConfiguration UseCaseNameType = "evseCommissioningAndConfiguration" + UseCaseNameTypeEVStateOfCharge UseCaseNameType = "evStateOfCharge" + UseCaseNameTypeFlexibleLoad UseCaseNameType = "flexibleLoad" + UseCaseNameTypeFlexibleStartForWhiteGoods UseCaseNameType = "flexibleStartForWhiteGoods" + UseCaseNameTypeLimitationOfPowerConsumption UseCaseNameType = "limitationOfPowerConsumption" + UseCaseNameTypeLimitationOfPowerProduction UseCaseNameType = "limitationOfPowerProduction" + UseCaseNameTypeIncentiveTableBasedPowerConsumptionManagement UseCaseNameType = "incentiveTableBasedPowerConsumptionManagement" + UseCaseNameTypeMeasurementOfElectricityDuringEVCharging UseCaseNameType = "measurementOfElectricityDuringEvCharging" + UseCaseNameTypeMonitoringAndControlOfSmartGridReadyConditions UseCaseNameType = "monitoringAndControlOfSmartGridReadyConditions" + UseCaseNameTypeMonitoringOfBattery UseCaseNameType = "monitoringOfBattery" + UseCaseNameTypeMonitoringOfDhwSystemFunction UseCaseNameType = "monitoringOfDhwSystemFunction" + UseCaseNameTypeMonitoringOfDhwTemperature UseCaseNameType = "monitoringOfDhwTemperature" + UseCaseNameTypeMonitoringOfGridConnectionPoint UseCaseNameType = "monitoringOfGridConnectionPoint" + UseCaseNameTypeMonitoringOfInverter UseCaseNameType = "monitoringOfInverter" + UseCaseNameTypeMonitoringOfOutdoorTemperature UseCaseNameType = "monitoringOfOutdoorTemperature" + UseCaseNameTypeMonitoringOfPowerConsumption UseCaseNameType = "monitoringOfPowerConsumption" + UseCaseNameTypeMonitoringOfPvString UseCaseNameType = "monitoringOfPvString" + UseCaseNameTypeMonitoringOfRoomCoolingSystemFunction UseCaseNameType = "monitoringOfRoomCoolingSystemFunction" + UseCaseNameTypeMonitoringOfRoomHeatingSystemFunction UseCaseNameType = "monitoringOfRoomHeatingSystemFunction" + UseCaseNameTypeMonitoringOfRoomTemperature UseCaseNameType = "monitoringOfRoomTemperature" + UseCaseNameTypeOptimizationOfSelfConsumptionByHeatPumpCompressorFlexibility UseCaseNameType = "optimizationOfSelfConsumptionByHeatPumpCompressorFlexibility" + UseCaseNameTypeOptimizationOfSelfConsumptionDuringEVCharging UseCaseNameType = "optimizationOfSelfConsumptionDuringEvCharging" + UseCaseNameTypeOverloadProtectionByEVChargingCurrentCurtailment UseCaseNameType = "overloadProtectionByEvChargingCurrentCurtailment" + UseCaseNameTypeVisualizationOfAggregatedBatteryData UseCaseNameType = "visualizationOfAggregatedBatteryData" + UseCaseNameTypeVisualizationOfAggregatedPhotovoltaicData UseCaseNameType = "visualizationOfAggregatedPhotovoltaicData" + UseCaseNameTypeVisualizationOfHeatingAreaName UseCaseNameType = "visualizationOfHeatingAreaName" +) + +type UseCaseScenarioSupportType uint + +const ( + UseCaseDocumentSubRevisionRelease string = "release" +) + +type UseCaseSupportType struct { + UseCaseName *UseCaseNameType `json:"useCaseName,omitempty"` + UseCaseVersion *SpecificationVersionType `json:"useCaseVersion,omitempty"` + UseCaseAvailable *bool `json:"useCaseAvailable,omitempty"` + ScenarioSupport []UseCaseScenarioSupportType `json:"scenarioSupport,omitempty"` + UseCaseDocumentSubRevision *string `json:"useCaseDocumentSubRevision,omitempty"` +} + +type UseCaseSupportElementsType struct { + UseCaseName *ElementTagType `json:"useCaseName,omitempty"` + UseCaseVersion *ElementTagType `json:"useCaseVersion,omitempty"` + UseCaseAvailable *ElementTagType `json:"useCaseAvailable,omitempty"` + ScenarioSupport *ElementTagType `json:"scenarioSupport,omitempty"` + UseCaseDocumentSubRevision *ElementTagType `json:"useCaseDocumentSubRevision,omitempty"` +} + +type UseCaseSupportSelectorsType struct { + UseCaseName *UseCaseNameType `json:"useCaseName,omitempty"` + UseCaseVersion *SpecificationVersionType `json:"useCaseVersion,omitempty"` + ScenarioSupport *UseCaseScenarioSupportType `json:"scenarioSupport,omitempty"` +} + +type UseCaseInformationDataType struct { + Address *FeatureAddressType `json:"address,omitempty"` + Actor *UseCaseActorType `json:"actor,omitempty"` + UseCaseSupport []UseCaseSupportType `json:"useCaseSupport,omitempty"` +} + +type UseCaseInformationDataElementsType struct { + Address *ElementTagType `json:"address,omitempty"` + Actor *ElementTagType `json:"actor,omitempty"` + UseCaseSupport *ElementTagType `json:"useCaseSupport,omitempty"` +} + +type UseCaseInformationListDataType struct { + UseCaseInformationData []UseCaseInformationDataType `json:"useCaseInformationData,omitempty"` +} + +type UseCaseInformationListDataSelectorsType struct { + Address *FeatureAddressType `json:"address,omitempty"` + Actor *UseCaseActorType `json:"actor,omitempty"` + UseCaseSupport *UseCaseSupportSelectorsType `json:"useCaseSupport,omitempty"` +} diff --git a/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions.go b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions.go new file mode 100644 index 0000000..8f846c5 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions.go @@ -0,0 +1,54 @@ +package model + +import "sync" + +var uciMux sync.Mutex + +// UseCaseInformationDataType + +// find the matching UseCaseSupport index for a UseCaseNameType +func (u *UseCaseInformationDataType) useCaseSupportIndex(useCaseName UseCaseNameType) (int, bool) { + // get the element with the same entity + for index, item := range u.UseCaseSupport { + if item.UseCaseName != nil && *item.UseCaseName == useCaseName { + return index, true + } + } + + return -1, false +} + +// add a new UseCaseSupportType +func (u *UseCaseInformationDataType) Add(useCase UseCaseSupportType) { + uciMux.Lock() + defer uciMux.Unlock() + + if useCase.UseCaseName == nil { + return + } + + // only add it if it does not exist yet + if index, ok := u.useCaseSupportIndex(*useCase.UseCaseName); ok { + // overwrite it instead + u.UseCaseSupport[index] = useCase + return + } + + u.UseCaseSupport = append(u.UseCaseSupport, useCase) +} + +// remove a UseCaseSupportType with a given UseCaseNameType +func (u *UseCaseInformationDataType) Remove(useCaseName UseCaseNameType) { + uciMux.Lock() + defer uciMux.Unlock() + + var usecases []UseCaseSupportType + + for _, item := range u.UseCaseSupport { + if item.UseCaseName != nil && *item.UseCaseName != useCaseName { + usecases = append(usecases, item) + } + } + + u.UseCaseSupport = usecases +} diff --git a/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions_test.go_temp b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions_test.go_temp new file mode 100644 index 0000000..5de8e27 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/usecaseinformation_additions_test.go_temp @@ -0,0 +1,81 @@ +package model + +import ( + "testing" + + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +func TestUsecaseInformationSuite(t *testing.T) { + suite.Run(t, new(UsecaseInformationSuite)) +} + +type UsecaseInformationSuite struct { + suite.Suite +} + +func (s *UsecaseInformationSuite) Test_UpdateList() { + sut := UseCaseInformationListDataType{ + UseCaseInformationData: []UseCaseInformationDataType{ + { + Actor: util.Ptr(UseCaseActorTypeEVSE), + UseCaseSupport: []UseCaseSupportType{ + { + UseCaseName: util.Ptr(UseCaseNameTypeEVSECommissioningAndConfiguration), + UseCaseVersion: util.Ptr(SpecificationVersionType("1.0.0")), + UseCaseAvailable: util.Ptr(true), + ScenarioSupport: []UseCaseScenarioSupportType{ + 1, 2, 3, 4, 5, + }, + }, + }, + }, + }, + } + + newData := UseCaseInformationListDataType{ + UseCaseInformationData: []UseCaseInformationDataType{ + { + Actor: util.Ptr(UseCaseActorTypeEVSE), + UseCaseSupport: []UseCaseSupportType{ + { + UseCaseName: util.Ptr(UseCaseNameTypeEVSECommissioningAndConfiguration), + UseCaseVersion: util.Ptr(SpecificationVersionType("1.0.1")), + UseCaseAvailable: util.Ptr(true), + ScenarioSupport: []UseCaseScenarioSupportType{ + 1, 2, 3, 4, 5, + }, + }, + }, + }, + { + Actor: util.Ptr(UseCaseActorTypeEV), + UseCaseSupport: []UseCaseSupportType{ + { + UseCaseName: util.Ptr(UseCaseNameTypeEVCommissioningAndConfiguration), + UseCaseVersion: util.Ptr(SpecificationVersionType("1.0.0")), + UseCaseAvailable: util.Ptr(true), + ScenarioSupport: []UseCaseScenarioSupportType{ + 1, 2, 3, 4, 5, + }, + }, + }, + }, + }, + } + + data := sut.UseCaseInformationData + // check properties of updated item + item1 := data[0] + assert.NotNil(s.T(), item1) + + // Act + sut.UpdateList(false, &newData, NewFilterTypePartial(), nil) + + data = sut.UseCaseInformationData + // check properties of updated item + item1 = data[0] + assert.NotNil(s.T(), item1) +} diff --git a/src/eebus-bridge/third_party/spine-go/model/version.go b/src/eebus-bridge/third_party/spine-go/model/version.go new file mode 100644 index 0000000..f592077 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/version.go @@ -0,0 +1,11 @@ +package model + +type SpecificationVersionDataType SpecificationVersionType + +type SpecificationVersionDataElementsType struct{} + +type SpecificationVersionListDataType struct { + SpecificationVersionData []SpecificationVersionDataType `json:"specificationVersionData,omitempty"` +} + +type SpecificationVersionListDataSelectorsType struct{} diff --git a/src/eebus-bridge/third_party/spine-go/model/version_additions.go b/src/eebus-bridge/third_party/spine-go/model/version_additions.go new file mode 100644 index 0000000..51b02fc --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/model/version_additions.go @@ -0,0 +1,20 @@ +package model + +// SpecificationVersionListDataType + +var _ Updater = (*SpecificationVersionListDataType)(nil) + +func (r *SpecificationVersionListDataType) UpdateList(remoteWrite, persist bool, newList any, filterPartial, filterDelete *FilterType) (any, bool) { + var newData []SpecificationVersionDataType + if newList != nil { + newData = newList.(*SpecificationVersionListDataType).SpecificationVersionData + } + + data, success := UpdateList(remoteWrite, r.SpecificationVersionData, newData, filterPartial, filterDelete) + + if success && persist { + r.SpecificationVersionData = data + } + + return data, success +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/binding_manager.go b/src/eebus-bridge/third_party/spine-go/spine/binding_manager.go new file mode 100644 index 0000000..c071086 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/binding_manager.go @@ -0,0 +1,252 @@ +package spine + +import ( + "errors" + "fmt" + "reflect" + "sync" + "sync/atomic" + + "github.com/ahmetb/go-linq/v3" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type BindingManager struct { + localDevice api.DeviceLocalInterface + + bindingNum uint64 + bindingEntries []*api.BindingEntry + + mux sync.Mutex + // TODO: add persistence +} + +func NewBindingManager(localDevice api.DeviceLocalInterface) *BindingManager { + c := &BindingManager{ + bindingNum: 0, + localDevice: localDevice, + } + + return c +} + +// is sent from the client (remote device) to the server (local device) +func (c *BindingManager) AddBinding(remoteDevice api.DeviceRemoteInterface, data model.BindingManagementRequestCallType) error { + serverFeature := c.localDevice.FeatureByAddress(data.ServerAddress) + if serverFeature == nil { + return fmt.Errorf("server feature '%s' in local device '%s' not found", data.ServerAddress, *c.localDevice.Address()) + } + if data.ServerFeatureType == nil { + return errors.New("serverFeatureType is missing but required") + } + if err := c.checkRoleAndType(serverFeature, model.RoleTypeServer, *data.ServerFeatureType); err != nil { + return err + } + + // a local feature can only have one remote binding + bindings := c.BindingsOnFeature(*serverFeature.Address()) + if len(bindings) > 0 { + return errors.New("the server feature already has a binding") + } + + clientFeature := remoteDevice.FeatureByAddress(data.ClientAddress) + if clientFeature == nil { + return fmt.Errorf("client feature '%s' in remote device '%s' not found", data.ClientAddress, *remoteDevice.Address()) + } + if err := c.checkRoleAndType(clientFeature, model.RoleTypeClient, *data.ServerFeatureType); err != nil { + return err + } + + bindingEntry := &api.BindingEntry{ + Id: c.bindingId(), + ServerFeature: serverFeature, + ClientFeature: clientFeature, + } + + c.mux.Lock() + defer c.mux.Unlock() + + c.bindingEntries = append(c.bindingEntries, bindingEntry) + + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeBindingChange, + ChangeType: api.ElementChangeAdd, + Data: data, + Device: remoteDevice, + Entity: clientFeature.Entity(), + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + + return nil +} + +func (c *BindingManager) RemoveBinding(data model.BindingManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface) error { + var newBindingEntries []*api.BindingEntry + + // according to the spec 7.4.4 + // a. The absence of "bindingDelete. clientAddress. device" SHALL be treated as if it was + // present and set to the sender's "device" address part. + // b. The absence of "bindingDelete. serverAddress. device" SHALL be treated as if it was + // present and set to the recipient's "device" address part. + + var clientAddress model.FeatureAddressType + util.DeepCopy(data.ClientAddress, &clientAddress) + if data.ClientAddress.Device == nil { + clientAddress.Device = remoteDevice.Address() + } + + clientFeature := remoteDevice.FeatureByAddress(data.ClientAddress) + if clientFeature == nil { + return fmt.Errorf("client feature '%s' in remote device '%s' not found", data.ClientAddress, *remoteDevice.Address()) + } + + serverFeature := c.localDevice.FeatureByAddress(data.ServerAddress) + if serverFeature == nil { + return fmt.Errorf("server feature '%s' in local device '%s' not found", data.ServerAddress, *c.localDevice.Address()) + } + + if err := c.checkRoleAndType(serverFeature, model.RoleTypeServer, serverFeature.Type()); err != nil { + return err + } + + if !c.HasLocalFeatureRemoteBinding(serverFeature.Address(), clientFeature.Address()) { + return fmt.Errorf("the feature '%s' address has no binding", data.ClientAddress) + } + + c.mux.Lock() + defer c.mux.Unlock() + + for _, item := range c.bindingEntries { + itemAddress := item.ClientFeature.Address() + + if !reflect.DeepEqual(*itemAddress, clientAddress) && + !reflect.DeepEqual(item.ServerFeature, serverFeature) { + newBindingEntries = append(newBindingEntries, item) + } + } + + if len(newBindingEntries) == len(c.bindingEntries) { + return errors.New("could not find requested binding to be removed") + } + + c.bindingEntries = newBindingEntries + + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeBindingChange, + ChangeType: api.ElementChangeRemove, + Data: data, + Device: remoteDevice, + Entity: clientFeature.Entity(), + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + + return nil +} + +// Remove all existing bindings for a given remote device +func (c *BindingManager) RemoveBindingsForDevice(remoteDevice api.DeviceRemoteInterface) { + if remoteDevice == nil { + return + } + + for _, entity := range remoteDevice.Entities() { + c.RemoveBindingsForEntity(entity) + } +} + +// Remove all existing bindings for a given remote device entity +func (c *BindingManager) RemoveBindingsForEntity(remoteEntity api.EntityRemoteInterface) { + if remoteEntity == nil { + return + } + + c.mux.Lock() + defer c.mux.Unlock() + + var newBindingEntries []*api.BindingEntry + for _, item := range c.bindingEntries { + if !reflect.DeepEqual(item.ClientFeature.Address().Entity, remoteEntity.Address().Entity) { + newBindingEntries = append(newBindingEntries, item) + continue + } + + serverFeature := c.localDevice.FeatureByAddress(item.ServerFeature.Address()) + clientFeature := remoteEntity.FeatureOfAddress(item.ClientFeature.Address().Feature) + payload := api.EventPayload{ + Ski: remoteEntity.Device().Ski(), + EventType: api.EventTypeBindingChange, + ChangeType: api.ElementChangeRemove, + Device: remoteEntity.Device(), + Entity: remoteEntity, + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + } + + c.bindingEntries = newBindingEntries +} + +func (c *BindingManager) Bindings(remoteDevice api.DeviceRemoteInterface) []*api.BindingEntry { + var result []*api.BindingEntry + + c.mux.Lock() + defer c.mux.Unlock() + + linq.From(c.bindingEntries).WhereT(func(s *api.BindingEntry) bool { + return s.ClientFeature.Device().Ski() == remoteDevice.Ski() + }).ToSlice(&result) + + return result +} + +// checks if a remote address has a binding on the local feature +func (c *BindingManager) HasLocalFeatureRemoteBinding(localAddress, remoteAddress *model.FeatureAddressType) bool { + bindings := c.BindingsOnFeature(*localAddress) + + for _, item := range bindings { + if reflect.DeepEqual(item.ClientFeature.Address(), remoteAddress) { + return true + } + } + + return false +} + +func (c *BindingManager) BindingsOnFeature(featureAddress model.FeatureAddressType) []*api.BindingEntry { + var result []*api.BindingEntry + + c.mux.Lock() + defer c.mux.Unlock() + + linq.From(c.bindingEntries).WhereT(func(s *api.BindingEntry) bool { + return reflect.DeepEqual(*s.ServerFeature.Address(), featureAddress) + }).ToSlice(&result) + + return result +} + +func (c *BindingManager) bindingId() uint64 { + i := atomic.AddUint64(&c.bindingNum, 1) + return i +} + +func (c *BindingManager) checkRoleAndType(feature api.FeatureInterface, role model.RoleType, featureType model.FeatureTypeType) error { + if feature.Role() != model.RoleTypeSpecial && feature.Role() != role { + return fmt.Errorf("found feature %s is not matching required role %s", feature.Type(), role) + } + + if feature.Type() != featureType && feature.Type() != model.FeatureTypeTypeGeneric { + return fmt.Errorf("found feature %s is not matching required type %s", feature.Type(), featureType) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/const.go b/src/eebus-bridge/third_party/spine-go/spine/const.go new file mode 100644 index 0000000..9f527e3 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/const.go @@ -0,0 +1,5 @@ +package spine + +import "github.com/enbility/spine-go/model" + +var SpecificationVersion model.SpecificationVersionType = "1.3.0" diff --git a/src/eebus-bridge/third_party/spine-go/spine/device.go b/src/eebus-bridge/third_party/spine-go/spine/device.go new file mode 100644 index 0000000..e3b4b75 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/device.go @@ -0,0 +1,75 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: the description fields under a lock (a remote device's are set +// by its detailed discovery while other connections look devices up by +// address). + +package spine + +import ( + "sync" + + "github.com/enbility/spine-go/model" +) + +type Device struct { + address *model.AddressDeviceType + dType *model.DeviceTypeType + featureSet *model.NetworkManagementFeatureSetType + + muxDescription sync.RWMutex +} + +// Initialize a new device +// Both values are required for a local device but provided as empty strings for a remote device +// as the address is only provided via detailed discovery response +func NewDevice(address *model.AddressDeviceType, dType *model.DeviceTypeType, featureSet *model.NetworkManagementFeatureSetType) *Device { + device := &Device{} + + if dType != nil { + device.dType = dType + } + + if address != nil { + device.address = address + } + + if featureSet != nil { + device.featureSet = featureSet + } + + return device +} + +func (r *Device) Address() *model.AddressDeviceType { + r.muxDescription.RLock() + defer r.muxDescription.RUnlock() + + return r.address +} + +func (r *Device) DeviceType() *model.DeviceTypeType { + r.muxDescription.RLock() + defer r.muxDescription.RUnlock() + + return r.dType +} + +func (r *Device) FeatureSet() *model.NetworkManagementFeatureSetType { + r.muxDescription.RLock() + defer r.muxDescription.RUnlock() + + return r.featureSet +} + +func (r *Device) DestinationData() model.NodeManagementDestinationDataType { + return model.NodeManagementDestinationDataType{ + DeviceDescription: &model.NetworkManagementDeviceDescriptionDataType{ + DeviceAddress: &model.DeviceAddressType{ + Device: r.Address(), + }, + DeviceType: r.DeviceType(), + NetworkFeatureSet: r.FeatureSet(), + }, + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/device_local.go b/src/eebus-bridge/third_party/spine-go/spine/device_local.go new file mode 100644 index 0000000..6c07c78 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/device_local.go @@ -0,0 +1,507 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: RemoveRemoteDevice changes the remote devices' map under its lock. + +package spine + +import ( + "errors" + "fmt" + "reflect" + "slices" + "sync" + + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type DeviceLocal struct { + *Device + entities []api.EntityLocalInterface + subscriptionManager api.SubscriptionManagerInterface + bindingManager api.BindingManagerInterface + nodeManagement *NodeManagement + + remoteDevices map[string]api.DeviceRemoteInterface + + brandName string + deviceModel string + deviceCode string + serialNumber string + + mux sync.Mutex +} + +// BrandName is the brand +// DeviceModel is the model +// SerialNumber is the serial number +// DeviceCode is the SHIP id (accessMethods.id) +// DeviceAddress is the SPINE device address +func NewDeviceLocal( + brandName, deviceModel, serialNumber, deviceCode, deviceAddress string, + deviceType model.DeviceTypeType, + featureSet model.NetworkManagementFeatureSetType) *DeviceLocal { + address := model.AddressDeviceType(deviceAddress) + + var fSet *model.NetworkManagementFeatureSetType + if len(featureSet) != 0 { + fSet = &featureSet + } + + res := &DeviceLocal{ + Device: NewDevice(&address, &deviceType, fSet), + remoteDevices: make(map[string]api.DeviceRemoteInterface), + brandName: brandName, + deviceModel: deviceModel, + serialNumber: serialNumber, + deviceCode: deviceCode, + } + + res.subscriptionManager = NewSubscriptionManager(res) + res.bindingManager = NewBindingManager(res) + + res.addDeviceInformation() + return res +} + +var _ api.EventHandlerInterface = (*DeviceLocal)(nil) + +/* EventHandlerInterface */ + +// React to some specific events +func (r *DeviceLocal) HandleEvent(payload api.EventPayload) { + // Subscribe to NodeManagement after DetailedDiscovery is received + if payload.EventType != api.EventTypeDeviceChange || payload.ChangeType != api.ElementChangeAdd { + return + } + + if payload.Data == nil { + return + } + + if len(payload.Ski) == 0 { + return + } + + remoteDevice := r.RemoteDeviceForSki(payload.Ski) + if remoteDevice == nil { + return + } + + // the codefactor warning is invalid, as .(type) check can not be replaced with if then + //revive:disable-next-line + switch payload.Data.(type) { + case *model.NodeManagementDetailedDiscoveryDataType: + address := payload.Feature.Address() + if address.Device == nil { + address.Device = remoteDevice.Address() + } + _, _ = r.nodeManagement.SubscribeToRemote(address) + + // Request Use Case Data + _, _ = r.nodeManagement.RequestUseCaseData(payload.Device.Ski(), remoteDevice.Address(), payload.Device.Sender()) + } +} + +var _ api.DeviceLocalInterface = (*DeviceLocal)(nil) + +/* DeviceLocalInterface */ + +// Setup a new remote device with a given SKI and triggers SPINE requesting device details +func (r *DeviceLocal) SetupRemoteDevice(ski string, writeI shipapi.ShipConnectionDataWriterInterface) shipapi.ShipConnectionDataReaderInterface { + sender := NewSender(writeI) + rDevice := NewDeviceRemote(r, ski, sender) + + r.AddRemoteDeviceForSki(ski, rDevice) + + // always add subscription, as it checks if it already exists + _ = Events.subscribe(api.EventHandlerLevelCore, r) + + // Request Detailed Discovery Data + _, _ = r.RequestRemoteDetailedDiscoveryData(rDevice) + + // TODO: Add error handling + // If the request returned an error, it should be retried until it does not + + return rDevice +} + +func (r *DeviceLocal) RequestRemoteDetailedDiscoveryData(rDevice api.DeviceRemoteInterface) (*model.MsgCounterType, *model.ErrorType) { + // Request Detailed Discovery Data + return r.nodeManagement.RequestDetailedDiscovery(rDevice.Ski(), rDevice.Address(), rDevice.Sender()) +} + +// Helper method used by tests and AddRemoteDevice +func (r *DeviceLocal) AddRemoteDeviceForSki(ski string, rDevice api.DeviceRemoteInterface) { + r.mux.Lock() + defer r.mux.Unlock() + + r.remoteDevices[ski] = rDevice +} + +func (r *DeviceLocal) RemoveRemoteDeviceConnection(ski string) { + remoteDevice := r.RemoteDeviceForSki(ski) + + r.RemoveRemoteDevice(ski) + + // inform about the disconnection + payload := api.EventPayload{ + Ski: ski, + EventType: api.EventTypeDeviceChange, + ChangeType: api.ElementChangeRemove, + Device: remoteDevice, + } + Events.Publish(payload) +} + +func (r *DeviceLocal) RemoveRemoteDevice(ski string) { + remoteDevice := r.RemoteDeviceForSki(ski) + if remoteDevice == nil { + return + } + + // remove all subscriptions for this device + subscriptionMgr := r.SubscriptionManager() + subscriptionMgr.RemoveSubscriptionsForDevice(remoteDevice) + + // remove all bindings for this device + bindingMgr := r.BindingManager() + bindingMgr.RemoveBindingsForDevice(remoteDevice) + + // the map under its lock (before: deleted and counted without it, while + // other connections added or looked up their devices) + r.mux.Lock() + delete(r.remoteDevices, ski) + remaining := len(r.remoteDevices) + r.mux.Unlock() + + // only unsubscribe if we don't have any remote devices left + if remaining == 0 { + _ = Events.unsubscribe(api.EventHandlerLevelCore, r) + } + + remoteDeviceAddress := &model.DeviceAddressType{ + Device: remoteDevice.Address(), + } + // remove all data caches for this device + for _, entity := range r.entities { + for _, feature := range entity.Features() { + feature.CleanWriteApprovalCaches(ski) + feature.CleanRemoteDeviceCaches(remoteDeviceAddress) + } + } +} + +func (r *DeviceLocal) RemoteDevices() []api.DeviceRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + res := make([]api.DeviceRemoteInterface, 0) + for _, rDevice := range r.remoteDevices { + res = append(res, rDevice) + } + + return res +} + +func (r *DeviceLocal) RemoteDeviceForAddress(address model.AddressDeviceType) api.DeviceRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range r.remoteDevices { + if item.Address() != nil && *item.Address() == address { + return item + } + } + + return nil +} + +func (r *DeviceLocal) RemoteDeviceForSki(ski string) api.DeviceRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + return r.remoteDevices[ski] +} + +func (r *DeviceLocal) AddEntity(entity api.EntityLocalInterface) { + r.mux.Lock() + + r.entities = append(r.entities, entity) + + r.mux.Unlock() + + r.notifySubscribersOfEntity(entity, model.NetworkManagementStateChangeTypeAdded) +} + +func (r *DeviceLocal) RemoveEntity(entity api.EntityLocalInterface) { + entity.RemoveAllUseCaseSupports() + entity.RemoveAllSubscriptions() + entity.RemoveAllBindings() + + if heartbeatMgr := entity.HeartbeatManager(); heartbeatMgr != nil { + heartbeatMgr.StopHeartbeat() + } + + r.mux.Lock() + + var entities []api.EntityLocalInterface + for _, e := range r.entities { + if e != entity { + entities = append(entities, e) + } + } + + r.entities = entities + + r.mux.Unlock() + + r.notifySubscribersOfEntity(entity, model.NetworkManagementStateChangeTypeRemoved) +} + +func (r *DeviceLocal) Entities() []api.EntityLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + return r.entities +} + +func (r *DeviceLocal) Entity(id []model.AddressEntityType) api.EntityLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, e := range r.entities { + if reflect.DeepEqual(id, e.Address().Entity) { + return e + } + } + return nil +} + +func (r *DeviceLocal) EntityForType(entityType model.EntityTypeType) api.EntityLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, e := range r.entities { + if e.EntityType() == entityType { + return e + } + } + return nil +} + +func (r *DeviceLocal) FeatureByAddress(address *model.FeatureAddressType) api.FeatureLocalInterface { + entity := r.Entity(address.Entity) + if entity != nil { + return entity.FeatureOfAddress(address.Feature) + } + return nil +} + +func (r *DeviceLocal) CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) { + for _, entity := range r.entities { + for _, feature := range entity.Features() { + feature.CleanRemoteEntityCaches(remoteAddress) + } + } +} + +func (r *DeviceLocal) ProcessCmd(datagram model.DatagramType, remoteDevice api.DeviceRemoteInterface) error { + destAddr := datagram.Header.AddressDestination + localFeature := r.FeatureByAddress(destAddr) + + cmdClassifier := datagram.Header.CmdClassifier + if len(datagram.Payload.Cmd) == 0 { + return errors.New("no payload cmd content available") + } + cmd := datagram.Payload.Cmd[0] + + // TODO check if cmd.Function is the same as the provided cmd value + filterPartial, filterDelete := cmd.ExtractFilter() + + remoteEntity := remoteDevice.Entity(datagram.Header.AddressSource.Entity) + remoteFeature := remoteDevice.FeatureByAddress(datagram.Header.AddressSource) + if remoteFeature == nil { + return fmt.Errorf("invalid remote feature address: '%s'", datagram.Header.AddressSource) + } + + message := &api.Message{ + RequestHeader: &datagram.Header, + Cmd: cmd, + FilterPartial: filterPartial, + FilterDelete: filterDelete, + FeatureRemote: remoteFeature, + EntityRemote: remoteEntity, + DeviceRemote: remoteDevice, + } + + if cmdClassifier != nil { + message.CmdClassifier = *cmdClassifier + } else { + errorMessage := "cmdClassifier may not be empty" + + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, destAddr, model.NewErrorType(model.ErrorNumberTypeDestinationUnknown, errorMessage)) + + return errors.New(errorMessage) + } + + if localFeature == nil { + errorMessage := "invalid feature address" + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, destAddr, model.NewErrorType(model.ErrorNumberTypeDestinationUnknown, errorMessage)) + + return errors.New(errorMessage) + } + + lfType := string(localFeature.Type()) + rfType := string(remoteFeature.Type()) + + logging.Log().Debug(datagram.PrintMessageOverview(false, lfType, rfType)) + + // check if this is a write with an existing binding and if write is allowed on this feature + if message.CmdClassifier == model.CmdClassifierTypeWrite { + cmdData, err := cmd.Data() + if err != nil || cmdData.Function == nil { + err := model.NewErrorTypeFromString("no function found for cmd data") + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, localFeature.Address(), err) + return errors.New(err.String()) + } + + if operations, ok := localFeature.Operations()[*cmdData.Function]; !ok || !operations.Write() { + err := model.NewErrorTypeFromString("write is not allowed on this function") + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, localFeature.Address(), err) + return errors.New(err.String()) + } + + if !r.BindingManager().HasLocalFeatureRemoteBinding(localFeature.Address(), remoteFeature.Address()) { + err := model.NewErrorTypeFromString("write denied due to missing binding") + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, localFeature.Address(), err) + return errors.New(err.String()) + } + } + + err := localFeature.HandleMessage(message) + if err != nil { + // TODO: add error description in a useful format + + // Don't send error responses for incoming resulterror messages + if message.CmdClassifier != model.CmdClassifierTypeResult { + _ = remoteFeature.Device().Sender().ResultError(message.RequestHeader, localFeature.Address(), err) + } + + // if this is an error for a notify message, automatically trigger a read request for the same + if message.CmdClassifier == model.CmdClassifierTypeNotify { + // set the command function to empty + + if cmdData, err := message.Cmd.Data(); err == nil { + _, _ = localFeature.RequestRemoteData(*cmdData.Function, nil, nil, remoteFeature) + } + } + + return errors.New(err.String()) + } + + ackRequest := message.RequestHeader.AckRequest + ackClassifiers := []model.CmdClassifierType{ + model.CmdClassifierTypeCall, + model.CmdClassifierTypeReply, + model.CmdClassifierTypeNotify} + + if ackRequest != nil && *ackRequest && slices.Contains(ackClassifiers, message.CmdClassifier) { + // return success as defined in SPINE chapter 5.2.4 + _ = remoteFeature.Device().Sender().ResultSuccess(message.RequestHeader, localFeature.Address()) + } + + return nil +} + +func (r *DeviceLocal) NodeManagement() api.NodeManagementInterface { + return r.nodeManagement +} + +func (r *DeviceLocal) SubscriptionManager() api.SubscriptionManagerInterface { + return r.subscriptionManager +} + +func (r *DeviceLocal) BindingManager() api.BindingManagerInterface { + return r.bindingManager +} + +func (r *DeviceLocal) Information() *model.NodeManagementDetailedDiscoveryDeviceInformationType { + res := model.NodeManagementDetailedDiscoveryDeviceInformationType{ + Description: &model.NetworkManagementDeviceDescriptionDataType{ + DeviceAddress: &model.DeviceAddressType{ + Device: r.address, + }, + DeviceType: r.dType, + NetworkFeatureSet: r.featureSet, + }, + } + return &res +} + +func (r *DeviceLocal) NotifySubscribers(featureAddress *model.FeatureAddressType, cmd model.CmdType) { + subscriptions := r.SubscriptionManager().SubscriptionsOnFeature(*featureAddress) + for _, subscription := range subscriptions { + // TODO: error handling + _, _ = subscription.ClientFeature.Device().Sender().Notify(subscription.ServerFeature.Address(), subscription.ClientFeature.Address(), cmd) + } +} + +func (r *DeviceLocal) notifySubscribersOfEntity(entity api.EntityLocalInterface, state model.NetworkManagementStateChangeType) { + deviceInformation := r.Information() + entityInformation := *entity.Information() + entityInformation.Description.LastStateChange = &state + + var featureInformation []model.NodeManagementDetailedDiscoveryFeatureInformationType + if state == model.NetworkManagementStateChangeTypeAdded { + for _, f := range entity.Features() { + featureInformation = append(featureInformation, *f.Information()) + } + } + + cmd := model.CmdType{ + Function: util.Ptr(model.FunctionTypeNodeManagementDetailedDiscoveryData), + Filter: filterEmptyPartial(), + NodeManagementDetailedDiscoveryData: &model.NodeManagementDetailedDiscoveryDataType{ + SpecificationVersionList: &model.NodeManagementSpecificationVersionListType{ + SpecificationVersion: []model.SpecificationVersionDataType{model.SpecificationVersionDataType(SpecificationVersion)}, + }, + DeviceInformation: deviceInformation, + EntityInformation: []model.NodeManagementDetailedDiscoveryEntityInformationType{entityInformation}, + FeatureInformation: featureInformation, + }, + } + + r.NotifySubscribers(r.nodeManagement.Address(), cmd) +} + +func (r *DeviceLocal) addDeviceInformation() { + entityType := model.EntityTypeTypeDeviceInformation + entity := NewEntityLocal(r, entityType, []model.AddressEntityType{model.AddressEntityType(DeviceInformationEntityId)}, 0) + + { + r.nodeManagement = NewNodeManagement(entity.NextFeatureId(), entity) + entity.AddFeature(r.nodeManagement) + } + { + f := NewFeatureLocal(entity.NextFeatureId(), entity, model.FeatureTypeTypeDeviceClassification, model.RoleTypeServer) + + f.AddFunctionType(model.FunctionTypeDeviceClassificationManufacturerData, true, false) + + manufacturerData := &model.DeviceClassificationManufacturerDataType{ + BrandName: util.Ptr(model.DeviceClassificationStringType(r.brandName)), + VendorName: util.Ptr(model.DeviceClassificationStringType(r.brandName)), + DeviceName: util.Ptr(model.DeviceClassificationStringType(r.deviceModel)), + DeviceCode: util.Ptr(model.DeviceClassificationStringType(r.deviceCode)), + SerialNumber: util.Ptr(model.DeviceClassificationStringType(r.serialNumber)), + } + f.SetData(model.FunctionTypeDeviceClassificationManufacturerData, manufacturerData) + + entity.AddFeature(f) + } + + r.entities = append(r.entities, entity) +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/device_remote.go b/src/eebus-bridge/third_party/spine-go/spine/device_remote.go new file mode 100644 index 0000000..dd316d3 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/device_remote.go @@ -0,0 +1,297 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: UpdateDevice sets the description under the device's lock. + +package spine + +import ( + "encoding/json" + "errors" + "reflect" + "sync" + + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type DeviceRemote struct { + *Device + + ski string + + entities []api.EntityRemoteInterface + entitiesMutex sync.Mutex + + sender api.SenderInterface + + localDevice api.DeviceLocalInterface +} + +func NewDeviceRemote(localDevice api.DeviceLocalInterface, ski string, sender api.SenderInterface) *DeviceRemote { + res := DeviceRemote{ + Device: NewDevice(nil, nil, nil), + ski: ski, + localDevice: localDevice, + sender: sender, + } + res.addNodeManagement() + + return &res +} + +func (d *DeviceRemote) addNodeManagement() { + deviceInformation := d.addNewEntity(model.EntityTypeTypeDeviceInformation, NewAddressEntityType([]uint{DeviceInformationEntityId})) + nodeManagement := NewFeatureRemote(deviceInformation.NextFeatureId(), deviceInformation, model.FeatureTypeTypeNodeManagement, model.RoleTypeSpecial) + deviceInformation.AddFeature(nodeManagement) +} + +var _ shipapi.ShipConnectionDataReaderInterface = (*DeviceRemote)(nil) + +/* ShipConnectionDataReaderInterface */ + +// processing incoming SPINE message from the associated SHIP connection +func (d *DeviceRemote) HandleShipPayloadMessage(message []byte) { + if _, err := d.HandleSpineMesssage(message); err != nil { + logging.Log().Errorf("error handling spine message", err) + } +} + +var _ api.DeviceRemoteInterface = (*DeviceRemote)(nil) + +/* DeviceRemoteInterface */ + +// return the device SKI +func (d *DeviceRemote) Ski() string { + return d.ski +} + +func (d *DeviceRemote) AddEntity(entity api.EntityRemoteInterface) { + d.entitiesMutex.Lock() + defer d.entitiesMutex.Unlock() + + d.entities = append(d.entities, entity) +} + +func (d *DeviceRemote) addNewEntity(eType model.EntityTypeType, address []model.AddressEntityType) api.EntityRemoteInterface { + newEntity := NewEntityRemote(d, eType, address) + d.AddEntity(newEntity) + return newEntity +} + +// Remove an entity with a given address from this device +func (d *DeviceRemote) RemoveEntityByAddress(addr []model.AddressEntityType) api.EntityRemoteInterface { + entityForRemoval := d.Entity(addr) + if entityForRemoval == nil { + return nil + } + + d.entitiesMutex.Lock() + defer d.entitiesMutex.Unlock() + + var newEntities []api.EntityRemoteInterface + for _, item := range d.entities { + if !reflect.DeepEqual(item, entityForRemoval) { + newEntities = append(newEntities, item) + } + } + d.entities = newEntities + + return entityForRemoval +} + +// Return an entity with a given address +func (d *DeviceRemote) Entity(id []model.AddressEntityType) api.EntityRemoteInterface { + d.entitiesMutex.Lock() + defer d.entitiesMutex.Unlock() + + for _, e := range d.entities { + if reflect.DeepEqual(id, e.Address().Entity) { + return e + } + } + return nil +} + +// Return all entities of this device +func (d *DeviceRemote) Entities() []api.EntityRemoteInterface { + d.entitiesMutex.Lock() + defer d.entitiesMutex.Unlock() + + return d.entities +} + +// Return the feature for a given address +func (d *DeviceRemote) FeatureByAddress(address *model.FeatureAddressType) api.FeatureRemoteInterface { + entity := d.Entity(address.Entity) + if entity != nil { + return entity.FeatureOfAddress(address.Feature) + } + return nil +} + +// Get the feature for a given entity, feature type and feature role +func (r *DeviceRemote) FeatureByEntityTypeAndRole(entity api.EntityRemoteInterface, featureType model.FeatureTypeType, role model.RoleType) api.FeatureRemoteInterface { + if len(r.entities) < 1 { + return nil + } + + r.entitiesMutex.Lock() + defer r.entitiesMutex.Unlock() + + for _, e := range r.entities { + if entity != e { + continue + } + for _, feature := range entity.Features() { + if feature.Type() == featureType && feature.Role() == role { + return feature + } + } + } + + return nil +} + +func (d *DeviceRemote) HandleSpineMesssage(message []byte) (*model.MsgCounterType, error) { + datagram := model.Datagram{} + if err := json.Unmarshal([]byte(message), &datagram); err != nil { + return nil, err + } + + if datagram.Datagram.Header.MsgCounterReference != nil { + d.sender.ProcessResponseForMsgCounterReference(datagram.Datagram.Header.MsgCounterReference) + } + + err := d.localDevice.ProcessCmd(datagram.Datagram, d) + if err != nil { + logging.Log().Trace(err) + } + + return datagram.Datagram.Header.MsgCounter, nil +} + +func (d *DeviceRemote) Sender() api.SenderInterface { + return d.sender +} + +func (d *DeviceRemote) UseCases() []model.UseCaseInformationDataType { + entity := d.Entity(DeviceInformationAddressEntity) + + nodemgmt := d.FeatureByEntityTypeAndRole(entity, model.FeatureTypeTypeNodeManagement, model.RoleTypeSpecial) + + data, ok := nodemgmt.DataCopy(model.FunctionTypeNodeManagementUseCaseData).(*model.NodeManagementUseCaseDataType) + if ok && data != nil { + return data.UseCaseInformation + } + + return nil +} + +func (d *DeviceRemote) UpdateDevice(description *model.NetworkManagementDeviceDescriptionDataType) { + if description != nil { + d.muxDescription.Lock() + defer d.muxDescription.Unlock() + + if description.DeviceAddress != nil && description.DeviceAddress.Device != nil { + d.address = description.DeviceAddress.Device + } + if description.DeviceType != nil { + d.dType = description.DeviceType + } + if description.NetworkFeatureSet != nil { + d.featureSet = description.NetworkFeatureSet + } + } +} + +func (d *DeviceRemote) AddEntityAndFeatures(initialData bool, data *model.NodeManagementDetailedDiscoveryDataType) ([]api.EntityRemoteInterface, error) { + rEntites := make([]api.EntityRemoteInterface, 0) + + for _, ei := range data.EntityInformation { + if err := d.CheckEntityInformation(initialData, ei); err != nil { + return nil, err + } + + entityAddress := ei.Description.EntityAddress.Entity + + entity := d.Entity(entityAddress) + if entity == nil { + entity = d.addNewEntity(*ei.Description.EntityType, entityAddress) + rEntites = append(rEntites, entity) + } + + // make sure the device address is set, which is not on entity 0 on startup ! + if entity.Address().Device == nil || len(*entity.Address().Device) == 0 { + if data.DeviceInformation != nil && + data.DeviceInformation.Description != nil && + data.DeviceInformation.Description.DeviceAddress != nil && + data.DeviceInformation.Description.DeviceAddress.Device != nil { + entity.UpdateDeviceAddress(*data.DeviceInformation.Description.DeviceAddress.Device) + } + } + + entity.SetDescription(ei.Description.Description) + entity.RemoveAllFeatures() + + for _, fi := range data.FeatureInformation { + if reflect.DeepEqual(fi.Description.FeatureAddress.Entity, entityAddress) { + if f, ok := unmarshalFeature(entity, fi); ok { + entity.AddFeature(f) + } + } + } + } + + return rEntites, nil +} + +// check if the provided entity information is correct +// provide initialData to check if the entity is new and not an update +func (d *DeviceRemote) CheckEntityInformation(initialData bool, entity model.NodeManagementDetailedDiscoveryEntityInformationType) error { + description := entity.Description + if description == nil { + return errors.New("nodemanagement.replyDetailedDiscoveryData: invalid EntityInformation.Description") + } + + if description.EntityAddress == nil { + return errors.New("nodemanagement.replyDetailedDiscoveryData: invalid EntityInformation.Description.EntityAddress") + } + + if description.EntityAddress.Entity == nil { + return errors.New("nodemanagement.replyDetailedDiscoveryData: invalid EntityInformation.Description.EntityAddress.Entity") + } + + // Consider on initial NodeManagement Detailed Discovery, the device being empty as it is not yet known + if initialData { + return nil + } + + address := d.Address() + if description.EntityAddress.Device != nil && address != nil && *description.EntityAddress.Device != *address { + return errors.New("nodemanagement.replyDetailedDiscoveryData: device address mismatch") + } + + return nil +} + +func unmarshalFeature(entity api.EntityRemoteInterface, + featureData model.NodeManagementDetailedDiscoveryFeatureInformationType, +) (api.FeatureRemoteInterface, bool) { + var result api.FeatureRemoteInterface + + fid := featureData.Description + + if fid == nil { + return nil, false + } + + result = NewFeatureRemote(uint(*fid.FeatureAddress.Feature), entity, *fid.FeatureType, *fid.Role) + + result.SetDescription(fid.Description) + result.SetMaxResponseDelay(fid.MaxResponseDelay) + result.SetOperations(fid.SupportedFunction) + + return result, true +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/entity.go b/src/eebus-bridge/third_party/spine-go/spine/entity.go new file mode 100644 index 0000000..e4b41f1 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/entity.go @@ -0,0 +1,94 @@ +package spine + +import ( + "sync" + + "github.com/ahmetb/go-linq/v3" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +const DeviceInformationEntityId uint = 0 + +var DeviceInformationAddressEntity = []model.AddressEntityType{model.AddressEntityType(DeviceInformationEntityId)} + +type Entity struct { + eType model.EntityTypeType + address *model.EntityAddressType + description *model.DescriptionType + fIdGenerator func() uint + + muxGenerator sync.Mutex +} + +var _ api.EntityInterface = (*Entity)(nil) + +func NewEntity(eType model.EntityTypeType, deviceAddress *model.AddressDeviceType, entityAddress []model.AddressEntityType) *Entity { + entity := &Entity{ + eType: eType, + address: &model.EntityAddressType{ + Device: deviceAddress, + Entity: entityAddress, + }, + } + if entityAddress[0] == 0 { + // Entity 0 Feature addresses start with 0 + entity.fIdGenerator = newFeatureIdGenerator(0) + } else { + // Entity 1 and further Feature addresses start with 1 + entity.fIdGenerator = newFeatureIdGenerator(1) + } + + return entity +} + +func (r *Entity) Address() *model.EntityAddressType { + return r.address +} + +func (r *Entity) EntityType() model.EntityTypeType { + return r.eType +} + +func (r *Entity) Description() *model.DescriptionType { + return r.description +} + +func (r *Entity) SetDescription(d *model.DescriptionType) { + r.description = d +} + +func (r *Entity) NextFeatureId() uint { + r.muxGenerator.Lock() + defer r.muxGenerator.Unlock() + + return r.fIdGenerator() +} + +func EntityAddressType(deviceAddress *model.AddressDeviceType, entityAddress []model.AddressEntityType) *model.EntityAddressType { + return &model.EntityAddressType{ + Device: deviceAddress, + Entity: entityAddress, + } +} + +func NewEntityAddressType(deviceName string, entityIds []uint) *model.EntityAddressType { + return &model.EntityAddressType{ + Device: util.Ptr(model.AddressDeviceType(deviceName)), + Entity: NewAddressEntityType(entityIds), + } +} + +func NewAddressEntityType(entityIds []uint) []model.AddressEntityType { + var addressEntity []model.AddressEntityType + linq.From(entityIds).SelectT(func(i uint) model.AddressEntityType { return model.AddressEntityType(i) }).ToSlice(&addressEntity) + return addressEntity +} + +func newFeatureIdGenerator(id uint) func() uint { + return func() uint { + defer func() { id += 1 }() + return id + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/entity_local.go b/src/eebus-bridge/third_party/spine-go/spine/entity_local.go new file mode 100644 index 0000000..8eb0676 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/entity_local.go @@ -0,0 +1,255 @@ +package spine + +import ( + "sync" + "time" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type EntityLocal struct { + *Entity + device api.DeviceLocalInterface + features []api.FeatureLocalInterface + + heartbeatManager api.HeartbeatManagerInterface + + mux sync.Mutex +} + +func NewEntityLocal(device api.DeviceLocalInterface, + eType model.EntityTypeType, + entityAddress []model.AddressEntityType, + heartbeatTimeout time.Duration) *EntityLocal { + entity := &EntityLocal{ + Entity: NewEntity(eType, device.Address(), entityAddress), + device: device, + } + // only needed if the entity address is not DeviceInformationEntityId + if len(entityAddress) > 0 && entityAddress[0] != model.AddressEntityType(DeviceInformationEntityId) { + entity.heartbeatManager = NewHeartbeatManager(entity, heartbeatTimeout) + } + + return entity +} + +var _ api.EntityLocalInterface = (*EntityLocal)(nil) + +/* EntityLocalInterface */ + +func (r *EntityLocal) Device() api.DeviceLocalInterface { + return r.device +} + +func (r *EntityLocal) HeartbeatManager() api.HeartbeatManagerInterface { + return r.heartbeatManager +} + +// Add a feature to the entity if it is not already added +func (r *EntityLocal) AddFeature(f api.FeatureLocalInterface) { + r.mux.Lock() + defer r.mux.Unlock() + + // check if this feature is already added + for _, f2 := range r.features { + if f2.Type() == f.Type() && f2.Role() == f.Role() { + return + } + } + r.features = append(r.features, f) +} + +// either returns an existing feature or creates a new one +// for a given entity, featuretype and role +func (r *EntityLocal) GetOrAddFeature(featureType model.FeatureTypeType, role model.RoleType) api.FeatureLocalInterface { + if f := r.FeatureOfTypeAndRole(featureType, role); f != nil { + return f + } + + r.mux.Lock() + defer r.mux.Unlock() + + f := NewFeatureLocal(r.NextFeatureId(), r, featureType, role) + + description := string(featureType) + switch role { + case model.RoleTypeClient: + description += " Client" + case model.RoleTypeServer: + description += " Server" + } + f.SetDescriptionString(description) + r.features = append(r.features, f) + + return f +} + +func (r *EntityLocal) FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) api.FeatureLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, f := range r.features { + if f.Type() == featureType && f.Role() == role { + return f + } + } + + return nil +} + +func (r *EntityLocal) FeatureOfAddress(addressFeature *model.AddressFeatureType) api.FeatureLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + if addressFeature == nil { + return nil + } + for _, f := range r.features { + if f.Address().Feature != nil && + *f.Address().Feature == *addressFeature { + return f + } + } + + return nil +} + +func (r *EntityLocal) Features() []api.FeatureLocalInterface { + r.mux.Lock() + defer r.mux.Unlock() + + return r.features +} + +// add a new usecase +func (r *EntityLocal) AddUseCaseSupport( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType, + useCaseVersion model.SpecificationVersionType, + useCaseDocumemtSubRevision string, + useCaseAvailable bool, + scenarios []model.UseCaseScenarioSupportType, +) { + nodeMgmt := r.device.NodeManagement() + + data, err := LocalFeatureDataCopyOfType[*model.NodeManagementUseCaseDataType](nodeMgmt, model.FunctionTypeNodeManagementUseCaseData) + if err != nil { + data = &model.NodeManagementUseCaseDataType{} + } + + address := model.FeatureAddressType{ + Device: r.address.Device, + Entity: r.address.Entity, + } + + data.AddUseCaseSupport(address, actor, useCaseName, useCaseVersion, useCaseDocumemtSubRevision, useCaseAvailable, scenarios) + + nodeMgmt.SetData(model.FunctionTypeNodeManagementUseCaseData, data) +} + +// Check if a use case is already added +func (r *EntityLocal) HasUseCaseSupport(actor model.UseCaseActorType, useCaseName model.UseCaseNameType) bool { + nodeMgmt := r.device.NodeManagement() + + data, err := LocalFeatureDataCopyOfType[*model.NodeManagementUseCaseDataType](nodeMgmt, model.FunctionTypeNodeManagementUseCaseData) + if err != nil { + return false + } + + address := model.FeatureAddressType{ + Device: r.address.Device, + Entity: r.address.Entity, + } + + return data.HasUseCaseSupport(address, actor, useCaseName) +} + +// Set the availability of a usecase. This may only be used for usescases +// that act as a client within the usecase! +func (r *EntityLocal) SetUseCaseAvailability( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType, + available bool) { + nodeMgmt := r.device.NodeManagement() + + data, err := LocalFeatureDataCopyOfType[*model.NodeManagementUseCaseDataType](nodeMgmt, model.FunctionTypeNodeManagementUseCaseData) + if err != nil { + return + } + + address := model.FeatureAddressType{ + Device: r.address.Device, + Entity: r.address.Entity, + } + + data.SetAvailability(address, actor, useCaseName, available) + + nodeMgmt.SetData(model.FunctionTypeNodeManagementUseCaseData, data) +} + +// Remove a usecase with a given actor ans usecase name +func (r *EntityLocal) RemoveUseCaseSupport( + actor model.UseCaseActorType, + useCaseName model.UseCaseNameType, +) { + nodeMgmt := r.device.NodeManagement() + + data, err := LocalFeatureDataCopyOfType[*model.NodeManagementUseCaseDataType](nodeMgmt, model.FunctionTypeNodeManagementUseCaseData) + if err != nil { + return + } + + address := model.FeatureAddressType{ + Device: r.address.Device, + Entity: r.address.Entity, + } + + data.RemoveUseCaseSupport(address, actor, useCaseName) + + nodeMgmt.SetData(model.FunctionTypeNodeManagementUseCaseData, data) +} + +// Remove all usecases +func (r *EntityLocal) RemoveAllUseCaseSupports() { + nodeMgmt := r.device.NodeManagement() + + data, err := LocalFeatureDataCopyOfType[*model.NodeManagementUseCaseDataType](nodeMgmt, model.FunctionTypeNodeManagementUseCaseData) + if err != nil { + return + } + + address := model.FeatureAddressType{ + Device: r.address.Device, + Entity: r.address.Entity, + } + + data.RemoveUseCaseDataForAddress(address) + + nodeMgmt.SetData(model.FunctionTypeNodeManagementUseCaseData, data) +} + +// Remove all subscriptions +func (r *EntityLocal) RemoveAllSubscriptions() { + for _, item := range r.features { + item.RemoveAllRemoteSubscriptions() + } +} + +// Remove all bindings +func (r *EntityLocal) RemoveAllBindings() { + for _, item := range r.features { + item.RemoveAllRemoteBindings() + } +} + +func (r *EntityLocal) Information() *model.NodeManagementDetailedDiscoveryEntityInformationType { + res := &model.NodeManagementDetailedDiscoveryEntityInformationType{ + Description: &model.NetworkManagementEntityDescriptionDataType{ + EntityAddress: r.Address(), + EntityType: &r.eType, + }, + } + + return res +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/entity_remote.go b/src/eebus-bridge/third_party/spine-go/spine/entity_remote.go new file mode 100644 index 0000000..0655f40 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/entity_remote.go @@ -0,0 +1,83 @@ +package spine + +import ( + "sync" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type EntityRemote struct { + *Entity + device api.DeviceRemoteInterface + features []api.FeatureRemoteInterface + + mux sync.Mutex +} + +func NewEntityRemote(device api.DeviceRemoteInterface, eType model.EntityTypeType, entityAddress []model.AddressEntityType) *EntityRemote { + return &EntityRemote{ + Entity: NewEntity(eType, device.Address(), entityAddress), + device: device, + } +} + +var _ api.EntityRemoteInterface = (*EntityRemote)(nil) + +/* EntityRemoteInterface */ + +func (r *EntityRemote) Device() api.DeviceRemoteInterface { + return r.device +} + +func (r *EntityRemote) UpdateDeviceAddress(address model.AddressDeviceType) { + r.address.Device = &address +} + +func (r *EntityRemote) AddFeature(f api.FeatureRemoteInterface) { + r.mux.Lock() + defer r.mux.Unlock() + + r.features = append(r.features, f) +} + +func (r *EntityRemote) RemoveAllFeatures() { + r.mux.Lock() + defer r.mux.Unlock() + + r.features = nil +} + +func (r *EntityRemote) FeatureOfTypeAndRole(featureType model.FeatureTypeType, role model.RoleType) api.FeatureRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, f := range r.features { + if f.Type() == featureType && f.Role() == role { + return f + } + } + + return nil +} + +func (r *EntityRemote) FeatureOfAddress(addressFeature *model.AddressFeatureType) api.FeatureRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + for _, f := range r.features { + if addressFeature != nil && f.Address() != nil && + *f.Address().Feature == *addressFeature { + return f + } + } + + return nil +} + +func (r *EntityRemote) Features() []api.FeatureRemoteInterface { + r.mux.Lock() + defer r.mux.Unlock() + + return r.features +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/events.go b/src/eebus-bridge/third_party/spine-go/spine/events.go new file mode 100644 index 0000000..e8683a9 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/events.go @@ -0,0 +1,115 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: Publish ranges a copy of the handlers taken under the lock, and +// unlocks the handler lock deferred (a recovered panic in a handler left it +// locked). + +package spine + +import ( + "sync" + + "github.com/enbility/spine-go/api" +) + +var Events events + +type eventHandlerItem struct { + Level api.EventHandlerLevel + Handler api.EventHandlerInterface +} + +type events struct { + mu sync.Mutex + muHandle sync.Mutex + + handlers []eventHandlerItem // event handling outside of the core stack +} + +// will be used in EEBUS core directly to access the level EventHandlerLevelCore +func (r *events) subscribe(level api.EventHandlerLevel, handler api.EventHandlerInterface) error { + r.mu.Lock() + defer r.mu.Unlock() + + for _, item := range r.handlers { + if item.Level == level && item.Handler == handler { + return nil + } + } + + newHandlerItem := eventHandlerItem{ + Level: level, + Handler: handler, + } + r.handlers = append(r.handlers, newHandlerItem) + + return nil +} + +// Subscribe to message events and handle them in +// the Eventhandler interface implementation +// +// returns an error if EventHandlerLevelCore is used as +// that is only allowed for internal use +func (r *events) Subscribe(handler api.EventHandlerInterface) error { + return r.subscribe(api.EventHandlerLevelApplication, handler) +} + +// will be used in EEBUS core directly to access the level EventHandlerLevelCore +func (r *events) unsubscribe(level api.EventHandlerLevel, handler api.EventHandlerInterface) error { + r.mu.Lock() + defer r.mu.Unlock() + + var newHandlers []eventHandlerItem + for _, item := range r.handlers { + if item.Level != level || item.Handler != handler { + newHandlers = append(newHandlers, item) + } + } + + r.handlers = newHandlers + + return nil +} + +// Unsubscribe from getting events +func (r *events) Unsubscribe(handler api.EventHandlerInterface) error { + return r.unsubscribe(api.EventHandlerLevelApplication, handler) +} + +// Publish an event to all subscribers +func (r *events) Publish(payload api.EventPayload) { + // a copy taken under the lock (before: copy() in the wrong direction, + // and r.handlers ranged without the lock while devices subscribed) + r.mu.Lock() + handler := make([]eventHandlerItem, len(r.handlers)) + copy(handler, r.handlers) + r.mu.Unlock() + + // Use different locks, so unpublish is possible in the event handlers + r.muHandle.Lock() + // deferred: a panic in a handler that the caller recovers (a SHIP + // connection's read pump) must not leave the bus locked for ever + defer r.muHandle.Unlock() + // process subscribers by level + handlerLevels := []api.EventHandlerLevel{ + api.EventHandlerLevelCore, + api.EventHandlerLevelApplication, + } + + for _, level := range handlerLevels { + for _, item := range handler { + if item.Level != level { + continue + } + + if level == api.EventHandlerLevelCore { + // do not run this asynchronously, to make sure all required + // and expected actions are taken + item.Handler.HandleEvent(payload) + } else { + go item.Handler.HandleEvent(payload) + } + } + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/events_panic_test.go b/src/eebus-bridge/third_party/spine-go/spine/events_panic_test.go new file mode 100644 index 0000000..91d75e4 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/events_panic_test.go @@ -0,0 +1,46 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// spine-go (see LICENSE). + +package spine + +import ( + "testing" + "time" + + "github.com/enbility/spine-go/api" +) + +type panickyHandler struct{ panics bool } + +func (h *panickyHandler) HandleEvent(api.EventPayload) { + if h.panics { + panic("a handler's bug") + } +} + +// A core handler panics during Publish and the caller (a SHIP connection's +// read pump) recovers: the bus must not stay locked. Before, the handler +// lock was released only on a normal return, and every later Publish +// blocked for ever. +func TestPublishAfterARecoveredPanic(t *testing.T) { + var bus events + h := &panickyHandler{panics: true} + _ = bus.subscribe(api.EventHandlerLevelCore, h) + + func() { + defer func() { _ = recover() }() + bus.Publish(api.EventPayload{}) + }() + + h.panics = false + done := make(chan struct{}) + go func() { + bus.Publish(api.EventPayload{}) + close(done) + }() + select { + case <-done: + case <-time.After(5 * time.Second): + t.Fatal("Publish blocked after a recovered panic") + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/feature.go b/src/eebus-bridge/third_party/spine-go/spine/feature.go new file mode 100644 index 0000000..991a6bd --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/feature.go @@ -0,0 +1,74 @@ +package spine + +import ( + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type Feature struct { + address *model.FeatureAddressType + ftype model.FeatureTypeType + description *model.DescriptionType + role model.RoleType + operations map[model.FunctionType]api.OperationsInterface +} + +var _ api.FeatureInterface = (*Feature)(nil) + +func NewFeature(address *model.FeatureAddressType, ftype model.FeatureTypeType, role model.RoleType) *Feature { + res := &Feature{ + address: address, + ftype: ftype, + role: role, + } + + return res +} + +func (r *Feature) Address() *model.FeatureAddressType { + return r.address +} + +func (r *Feature) Type() model.FeatureTypeType { + return r.ftype +} + +func (r *Feature) Role() model.RoleType { + return r.role +} + +func (r *Feature) Operations() map[model.FunctionType]api.OperationsInterface { + return r.operations +} + +func (r *Feature) Description() *model.DescriptionType { + return r.description +} + +func (r *Feature) SetDescription(d *model.DescriptionType) { + r.description = d +} + +func (r *Feature) SetDescriptionString(s string) { + r.description = util.Ptr(model.DescriptionType(s)) +} + +func (r *Feature) String() string { + if r == nil { + return "" + } + return fmt.Sprintf("Id: %d (%s)", *r.Address().Feature, string(r.ftype)) +} + +func featureAddressType(id uint, entityAddress *model.EntityAddressType) *model.FeatureAddressType { + res := model.FeatureAddressType{ + Device: entityAddress.Device, + Entity: entityAddress.Entity, + Feature: util.Ptr(model.AddressFeatureType(id)), + } + + return &res +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/feature_local.go b/src/eebus-bridge/third_party/spine-go/spine/feature_local.go new file mode 100644 index 0000000..4c25403 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/feature_local.go @@ -0,0 +1,863 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: BindToRemote and SubscribeToRemote record a remote feature once +// (a request repeated after the remote lost it added a duplicate). + +package spine + +import ( + "errors" + "fmt" + "reflect" + "sync" + "time" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type FeatureLocal struct { + *Feature + + entity api.EntityLocalInterface + functionDataMap map[model.FunctionType]api.FunctionDataCmdInterface + muxResponseCB sync.Mutex + responseMsgCallback map[model.MsgCounterType][]func(result api.ResponseMessage) + resultCallbacks []func(result api.ResponseMessage) + + writeTimeout time.Duration + writeApprovalCallbacks []api.WriteApprovalCallbackFunc + muxWriteReceived sync.Mutex + writeApprovalReceived map[string]map[model.MsgCounterType]int + pendingWriteApprovals map[string]map[model.MsgCounterType]*time.Timer + + bindings []*model.FeatureAddressType // bindings to remote features + subscriptions []*model.FeatureAddressType // subscriptions to remote features + + mux sync.Mutex +} + +func NewFeatureLocal(id uint, entity api.EntityLocalInterface, ftype model.FeatureTypeType, role model.RoleType) *FeatureLocal { + res := &FeatureLocal{ + Feature: NewFeature( + featureAddressType(id, entity.Address()), + ftype, + role), + entity: entity, + functionDataMap: make(map[model.FunctionType]api.FunctionDataCmdInterface), + responseMsgCallback: make(map[model.MsgCounterType][]func(result api.ResponseMessage)), + writeApprovalReceived: make(map[string]map[model.MsgCounterType]int), + pendingWriteApprovals: make(map[string]map[model.MsgCounterType]*time.Timer), + writeTimeout: defaultMaxResponseDelay, + } + + for _, fd := range CreateFunctionData[api.FunctionDataCmdInterface](ftype) { + res.functionDataMap[fd.FunctionType()] = fd + } + res.operations = make(map[model.FunctionType]api.OperationsInterface) + + return res +} + +var _ api.FeatureLocalInterface = (*FeatureLocal)(nil) + +/* FeatureLocalInterface */ + +func (r *FeatureLocal) Device() api.DeviceLocalInterface { + return r.entity.Device() +} + +func (r *FeatureLocal) Entity() api.EntityLocalInterface { + return r.entity +} + +// Add supported function to the feature if its role is Server or Special +func (r *FeatureLocal) AddFunctionType(function model.FunctionType, read, write bool) { + if r.role != model.RoleTypeServer && r.role != model.RoleTypeSpecial { + return + } + if r.operations[function] != nil { + return + } + writePartial := false + if write { + // partials are not supported on all features and functions, so check if this function supports it + if fctData := r.functionData(function); fctData != nil { + writePartial = fctData.SupportsPartialWrite() + } + } + // partial reads are currently not supported! + r.operations[function] = NewOperations(read, false, write, writePartial) + + if r.role == model.RoleTypeServer && + r.ftype == model.FeatureTypeTypeDeviceDiagnosis && + function == model.FunctionTypeDeviceDiagnosisHeartbeatData { + // Update HeartbeatManager + r.Entity().HeartbeatManager().SetLocalFeature(r.Entity(), r) + } +} + +func (r *FeatureLocal) Functions() []model.FunctionType { + var fcts []model.FunctionType + + for key := range r.operations { + fcts = append(fcts, key) + } + + return fcts +} + +// Add a callback function to be invoked when SPINE message comes in with a given msgCounterReference value +// +// Returns an error if there is already a callback for the msgCounter set +func (r *FeatureLocal) AddResponseCallback(msgCounterReference model.MsgCounterType, function func(msg api.ResponseMessage)) error { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + if _, ok := r.responseMsgCallback[msgCounterReference]; ok { + for _, cb := range r.responseMsgCallback[msgCounterReference] { + if reflect.ValueOf(cb).Pointer() == reflect.ValueOf(function).Pointer() { + return errors.New("callback already set") + } + } + } + + r.responseMsgCallback[msgCounterReference] = append(r.responseMsgCallback[msgCounterReference], function) + + return nil +} + +func (r *FeatureLocal) processResponseMsgCallbacks(msgCounterReference model.MsgCounterType, msg api.ResponseMessage) { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + cbs, ok := r.responseMsgCallback[msgCounterReference] + if !ok { + return + } + + for _, cb := range cbs { + go cb(msg) + } + + delete(r.responseMsgCallback, msgCounterReference) +} + +// Add a callback function to be invoked when a result message comes in for this feature +func (r *FeatureLocal) AddResultCallback(function func(msg api.ResponseMessage)) { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + r.resultCallbacks = append(r.resultCallbacks, function) +} + +func (r *FeatureLocal) processResultCallbacks(msg api.ResponseMessage) { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + for _, cb := range r.resultCallbacks { + go cb(msg) + } +} + +func (r *FeatureLocal) AddWriteApprovalCallback(function api.WriteApprovalCallbackFunc) error { + if r.Role() != model.RoleTypeServer { + return errors.New("only allowed on a server feature") + } + + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + r.writeApprovalCallbacks = append(r.writeApprovalCallbacks, function) + + return nil +} + +func (r *FeatureLocal) processWriteApprovalCallbacks(msg *api.Message) { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + for _, cb := range r.writeApprovalCallbacks { + go cb(msg) + } +} + +func (r *FeatureLocal) addPendingApproval(msg *api.Message) { + if r.Role() != model.RoleTypeServer || + msg.DeviceRemote == nil || + msg.RequestHeader == nil || + msg.RequestHeader.MsgCounter == nil { + return + } + + ski := msg.DeviceRemote.Ski() + + newTimer := time.AfterFunc(r.writeTimeout, func() { + r.muxResponseCB.Lock() + delete(r.pendingWriteApprovals[ski], *msg.RequestHeader.MsgCounter) + r.muxResponseCB.Unlock() + + err := model.NewErrorTypeFromString("write not approved in time by application") + _ = msg.FeatureRemote.Device().Sender().ResultError(msg.RequestHeader, r.Address(), err) + }) + + r.muxResponseCB.Lock() + if _, ok := r.pendingWriteApprovals[ski]; !ok { + r.pendingWriteApprovals[ski] = make(map[model.MsgCounterType]*time.Timer) + } + r.pendingWriteApprovals[ski][*msg.RequestHeader.MsgCounter] = newTimer + r.muxResponseCB.Unlock() +} + +func (r *FeatureLocal) ApproveOrDenyWrite(msg *api.Message, err model.ErrorType) { + if r.Role() != model.RoleTypeServer || + msg.DeviceRemote == nil { + return + } + + ski := msg.DeviceRemote.Ski() + + r.muxResponseCB.Lock() + timer, ok := r.pendingWriteApprovals[ski][*msg.RequestHeader.MsgCounter] + count := len(r.writeApprovalCallbacks) + r.muxResponseCB.Unlock() + + // if there is no timer running, we are too late and error has already been sent + if !ok || timer == nil { + return + } + + // do we have enough approvals? + r.muxWriteReceived.Lock() + defer r.muxWriteReceived.Unlock() + if count > 1 && err.ErrorNumber == 0 { + amount, ok := r.writeApprovalReceived[ski][*msg.RequestHeader.MsgCounter] + if ok { + r.writeApprovalReceived[ski][*msg.RequestHeader.MsgCounter] = amount + 1 + } else { + r.writeApprovalReceived[ski] = make(map[model.MsgCounterType]int) + r.writeApprovalReceived[ski][*msg.RequestHeader.MsgCounter] = 1 + } + // do we have enough approve messages, if not exit + if r.writeApprovalReceived[ski][*msg.RequestHeader.MsgCounter] < count { + return + } + } + + timer.Stop() + + delete(r.writeApprovalReceived[ski], *msg.RequestHeader.MsgCounter) + + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + delete(r.pendingWriteApprovals[ski], *msg.RequestHeader.MsgCounter) + + if err.ErrorNumber == 0 { + r.processWrite(msg) + return + } + + _ = msg.FeatureRemote.Device().Sender().ResultError(msg.RequestHeader, r.Address(), &err) +} + +func (r *FeatureLocal) SetWriteApprovalTimeout(duration time.Duration) { + r.writeTimeout = duration +} + +func (r *FeatureLocal) CleanWriteApprovalCaches(ski string) { + r.muxResponseCB.Lock() + defer r.muxResponseCB.Unlock() + + delete(r.pendingWriteApprovals, ski) + delete(r.writeApprovalReceived, ski) +} + +// Remove subscriptions and bindings from local cache for a remote device +// used if a remote device is getting disconnected +func (r *FeatureLocal) CleanRemoteDeviceCaches(remoteAddress *model.DeviceAddressType) { + if remoteAddress == nil || + remoteAddress.Device == nil { + return + } + + r.mux.Lock() + defer r.mux.Unlock() + + var subscriptions []*model.FeatureAddressType + + for _, item := range r.subscriptions { + if item.Device == nil || + *item.Device != *remoteAddress.Device { + subscriptions = append(subscriptions, item) + } + } + + r.subscriptions = subscriptions + + var bindings []*model.FeatureAddressType + + for _, item := range r.bindings { + if item.Device == nil || + *item.Device != *remoteAddress.Device { + bindings = append(bindings, item) + } + } + + r.bindings = bindings +} + +// Remove subscriptions and bindings from local cache for a remote entity +// used if a remote entity is removed +func (r *FeatureLocal) CleanRemoteEntityCaches(remoteAddress *model.EntityAddressType) { + if remoteAddress == nil || + remoteAddress.Device == nil || + remoteAddress.Entity == nil { + return + } + + r.mux.Lock() + defer r.mux.Unlock() + + var subscriptions []*model.FeatureAddressType + + for _, item := range r.subscriptions { + if item.Device == nil || item.Entity == nil || + *item.Device != *remoteAddress.Device || + !reflect.DeepEqual(item.Entity, remoteAddress.Entity) { + subscriptions = append(subscriptions, item) + } + } + + r.subscriptions = subscriptions + + var bindings []*model.FeatureAddressType + + for _, item := range r.bindings { + if item.Device == nil || item.Entity == nil || + *item.Device != *remoteAddress.Device || + !reflect.DeepEqual(item.Entity, remoteAddress.Entity) { + bindings = append(bindings, item) + } + } + + r.bindings = bindings +} + +func (r *FeatureLocal) DataCopy(function model.FunctionType) any { + r.mux.Lock() + defer r.mux.Unlock() + + fctData := r.functionData(function) + if fctData == nil { + return nil + } + + return fctData.DataCopyAny() +} + +func (r *FeatureLocal) SetData(function model.FunctionType, data any) { + fctData, err := r.updateData(false, function, data, nil, nil) + + if err != nil { + logging.Log().Debug(err.String()) + } + + if fctData != nil && err == nil { + r.Device().NotifySubscribers(r.Address(), fctData.NotifyOrWriteCmdType(nil, nil, false, nil)) + } +} + +func (r *FeatureLocal) UpdateData(function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) *model.ErrorType { + fctData, err := r.updateData(false, function, data, filterPartial, filterDelete) + + if err != nil { + logging.Log().Debug(err.String()) + } + + if fctData != nil && err == nil { + var deleteSelector, deleteElements, partialSelector any + + if filterDelete != nil { + if fDelete, err := filterDelete.Data(); err == nil { + if fDelete.Selector != nil { + deleteSelector = fDelete.Selector + } + if fDelete.Elements != nil { + deleteElements = fDelete.Elements + } + } + } + + if filterPartial != nil { + if fPartial, err := filterPartial.Data(); err == nil && fPartial.Selector != nil { + partialSelector = fPartial.Selector + } + } + + r.Device().NotifySubscribers(r.Address(), fctData.NotifyOrWriteCmdType(deleteSelector, partialSelector, partialSelector == nil, deleteElements)) + } + + return err +} + +func (r *FeatureLocal) updateData(remoteWrite bool, function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) (api.FunctionDataCmdInterface, *model.ErrorType) { + r.mux.Lock() + defer r.mux.Unlock() + + fctData := r.functionData(function) + if fctData == nil { + return nil, model.NewErrorTypeFromString("data not found") + } + + _, err := fctData.UpdateDataAny(remoteWrite, true, data, filterPartial, filterDelete) + + return fctData, err +} + +func (r *FeatureLocal) RequestRemoteData( + function model.FunctionType, + selector any, + elements any, + destination api.FeatureRemoteInterface) (*model.MsgCounterType, *model.ErrorType) { + fd := r.functionData(function) + if fd == nil { + return nil, model.NewErrorTypeFromString("function data not found") + } + + cmd := fd.ReadCmdType(selector, elements) + + return r.RequestRemoteDataBySenderAddress(cmd, destination.Device().Sender(), destination.Device().Ski(), destination.Address(), destination.MaxResponseDelayDuration()) +} + +func (r *FeatureLocal) RequestRemoteDataBySenderAddress( + cmd model.CmdType, + sender api.SenderInterface, + deviceSki string, + destinationAddress *model.FeatureAddressType, + maxDelay time.Duration) (*model.MsgCounterType, *model.ErrorType) { + msgCounter, err := sender.Request(model.CmdClassifierTypeRead, r.Address(), destinationAddress, false, []model.CmdType{cmd}) + if err == nil { + return msgCounter, nil + } + + return msgCounter, model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) +} + +// check if there already is a subscription to a remote feature +func (r *FeatureLocal) HasSubscriptionToRemote(remoteAddress *model.FeatureAddressType) bool { + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range r.subscriptions { + if reflect.DeepEqual(*remoteAddress, *item) { + return true + } + } + + return false +} + +// SubscribeToRemote to a remote feature +func (r *FeatureLocal) SubscribeToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + if remoteAddress.Device == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + remoteDevice := r.entity.Device().RemoteDeviceForAddress(*remoteAddress.Device) + if remoteDevice == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + + if r.Role() == model.RoleTypeServer { + return nil, model.NewErrorTypeFromString(fmt.Sprintf("the server feature '%s' cannot request a subscription", r.Feature.String())) + } + + msgCounter, err := remoteDevice.Sender().Subscribe(r.Address(), remoteAddress, r.ftype) + if err != nil { + return nil, model.NewErrorTypeFromString(err.Error()) + } + + r.addOnce(&r.subscriptions, remoteAddress) + + return msgCounter, nil +} + +// Remove a subscriptions to a remote feature +func (r *FeatureLocal) RemoveRemoteSubscription(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + if remoteAddress.Device == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + remoteDevice := r.entity.Device().RemoteDeviceForAddress(*remoteAddress.Device) + if remoteDevice == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + + msgCounter, err := remoteDevice.Sender().Unsubscribe(r.Address(), remoteAddress) + if err != nil { + return nil, model.NewErrorTypeFromString("device not found") + } + + var subscriptions []*model.FeatureAddressType + + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range r.subscriptions { + if reflect.DeepEqual(item, remoteAddress) { + continue + } + + subscriptions = append(subscriptions, item) + } + + r.subscriptions = subscriptions + + return msgCounter, nil +} + +// Remove all subscriptions to remote features +func (r *FeatureLocal) RemoveAllRemoteSubscriptions() { + for _, item := range r.subscriptions { + _, _ = r.RemoveRemoteSubscription(item) + } +} + +// check if there already is a binding to a remote feature +func (r *FeatureLocal) HasBindingToRemote(remoteAddress *model.FeatureAddressType) bool { + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range r.bindings { + if reflect.DeepEqual(*remoteAddress, *item) { + return true + } + } + + return false +} + +// BindToRemote to a remote feature +func (r *FeatureLocal) BindToRemote(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + if remoteAddress.Device == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + remoteDevice := r.entity.Device().RemoteDeviceForAddress(*remoteAddress.Device) + if remoteDevice == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + + if r.Role() == model.RoleTypeServer { + return nil, model.NewErrorTypeFromString(fmt.Sprintf("the server feature '%s' cannot request a binding", r.Feature.String())) + } + + msgCounter, err := remoteDevice.Sender().Bind(r.Address(), remoteAddress, r.ftype) + if err != nil { + return nil, model.NewErrorTypeFromString(err.Error()) + } + + // recorded once: a binding requested again (the remote lost it) must + // not add a duplicate + r.addOnce(&r.bindings, remoteAddress) + + return msgCounter, nil +} + +// addOnce: the remote feature added to a list of this feature (bindings, +// subscriptions) unless it is in it, as one check and append under the lock. +func (r *FeatureLocal) addOnce(list *[]*model.FeatureAddressType, remoteAddress *model.FeatureAddressType) { + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range *list { + if reflect.DeepEqual(*remoteAddress, *item) { + return + } + } + *list = append(*list, remoteAddress) +} + +// Remove a binding to a remote feature +func (r *FeatureLocal) RemoveRemoteBinding(remoteAddress *model.FeatureAddressType) (*model.MsgCounterType, *model.ErrorType) { + if remoteAddress.Device == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + remoteDevice := r.entity.Device().RemoteDeviceForAddress(*remoteAddress.Device) + if remoteDevice == nil { + return nil, model.NewErrorTypeFromString("device not found") + } + + msgCounter, err := remoteDevice.Sender().Unbind(r.Address(), remoteAddress) + if err != nil { + return nil, model.NewErrorTypeFromString(err.Error()) + } + + var bindings []*model.FeatureAddressType + + r.mux.Lock() + defer r.mux.Unlock() + + for _, item := range r.bindings { + if reflect.DeepEqual(item, remoteAddress) { + continue + } + + bindings = append(bindings, item) + } + + r.bindings = bindings + + return msgCounter, nil +} + +// Remove all subscriptions to remote features +func (r *FeatureLocal) RemoveAllRemoteBindings() { + for _, item := range r.bindings { + _, _ = r.RemoveRemoteBinding(item) + } +} + +func (r *FeatureLocal) HandleMessage(message *api.Message) *model.ErrorType { + cmdData, err := message.Cmd.Data() + if err != nil { + return model.NewErrorType(model.ErrorNumberTypeCommandNotSupported, err.Error()) + } + if cmdData.Function == nil { + return model.NewErrorType(model.ErrorNumberTypeCommandNotSupported, "No function found for cmd data") + } + + switch message.CmdClassifier { + case model.CmdClassifierTypeResult: + if err := r.processResult(message); err != nil { + return err + } + case model.CmdClassifierTypeRead: + if err := r.processRead(*cmdData.Function, message.RequestHeader, message.FeatureRemote); err != nil { + return err + } + case model.CmdClassifierTypeReply: + if err := r.processReply(message); err != nil { + return err + } + case model.CmdClassifierTypeNotify: + if err := r.processNotify(*cmdData.Function, cmdData.Value, message.FilterPartial, message.FilterDelete, message.FeatureRemote); err != nil { + return err + } + case model.CmdClassifierTypeWrite: + // if there is a write permission check callback set, invoke this instead of directly allowing the write + if len(r.writeApprovalCallbacks) > 0 { + r.addPendingApproval(message) + r.processWriteApprovalCallbacks(message) + } else { + // this method handles ack and error results, so no need to return an error + r.processWrite(message) + } + default: + return model.NewErrorTypeFromString(fmt.Sprintf("CmdClassifier not implemented: %s", message.CmdClassifier)) + } + + return nil +} + +func (r *FeatureLocal) processResult(message *api.Message) *model.ErrorType { + if message.Cmd.ResultData == nil || message.Cmd.ResultData.ErrorNumber == nil { + return model.NewErrorType( + model.ErrorNumberTypeGeneralError, + fmt.Sprintf("ResultData CmdClassifierType %s not implemented", message.CmdClassifier)) + } + + if *message.Cmd.ResultData.ErrorNumber != model.ErrorNumberTypeNoError { + // error numbers explained in Resource Spec 3.11 + errorString := fmt.Sprintf("Error Result received %d", *message.Cmd.ResultData.ErrorNumber) + if message.Cmd.ResultData.Description != nil { + errorString += fmt.Sprintf(": %s", *message.Cmd.ResultData.Description) + } + logging.Log().Debug(errorString) + } + + // we don't need to populate this message if there is no MsgCounterReference + if message.RequestHeader == nil || message.RequestHeader.MsgCounterReference == nil { + return nil + } + + responseMsg := api.ResponseMessage{ + MsgCounterReference: *message.RequestHeader.MsgCounterReference, + Data: message.Cmd.ResultData, + FeatureLocal: r, + FeatureRemote: message.FeatureRemote, + EntityRemote: message.EntityRemote, + DeviceRemote: message.DeviceRemote, + } + + r.processResponseMsgCallbacks(*message.RequestHeader.MsgCounterReference, responseMsg) + r.processResultCallbacks(responseMsg) + + return nil +} + +func (r *FeatureLocal) processRead(function model.FunctionType, requestHeader *model.HeaderType, featureRemote api.FeatureRemoteInterface) *model.ErrorType { + // is this a read request to a local server/special feature? + if r.role == model.RoleTypeClient { + // Read requests to a client feature are not allowed + return model.NewErrorTypeFromNumber(model.ErrorNumberTypeCommandRejected) + } + + fd := r.functionData(function) + if fd == nil { + return model.NewErrorTypeFromString("function data not found") + } + + cmd := fd.ReplyCmdType(false) + if err := featureRemote.Device().Sender().Reply(requestHeader, r.Address(), cmd); err != nil { + return model.NewErrorTypeFromString(err.Error()) + } + + return nil +} + +func (r *FeatureLocal) processReply(message *api.Message) *model.ErrorType { + // function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType, featureRemote api.FeatureRemoteInterface) + + // the error is handled already in the caller + cmdData, _ := message.Cmd.Data() + featureRemote := message.FeatureRemote + + if _, err := featureRemote.UpdateData(true, *cmdData.Function, cmdData.Value, message.FilterPartial, message.FilterDelete); err != nil { + return err + } + + // the data was updated, so send an event, other event handlers may watch out for this as well + payload := api.EventPayload{ + Ski: featureRemote.Device().Ski(), + EventType: api.EventTypeDataChange, + ChangeType: api.ElementChangeUpdate, + Feature: featureRemote, + Device: featureRemote.Device(), + Entity: featureRemote.Entity(), + LocalFeature: r, + Function: *cmdData.Function, + CmdClassifier: util.Ptr(model.CmdClassifierTypeReply), + Data: cmdData.Value, + } + Events.Publish(payload) + + // we don't need to populate this message if there is no MsgCounterReference + if message.RequestHeader == nil || message.RequestHeader.MsgCounterReference == nil { + return nil + } + + responseMsg := api.ResponseMessage{ + MsgCounterReference: *message.RequestHeader.MsgCounterReference, + Data: cmdData.Value, + FeatureLocal: r, + FeatureRemote: message.FeatureRemote, + EntityRemote: message.EntityRemote, + DeviceRemote: message.DeviceRemote, + } + + r.processResponseMsgCallbacks(*message.RequestHeader.MsgCounterReference, responseMsg) + + return nil +} + +func (r *FeatureLocal) processNotify(function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType, featureRemote api.FeatureRemoteInterface) *model.ErrorType { + if _, err := featureRemote.UpdateData(true, function, data, filterPartial, filterDelete); err != nil { + return err + } + + payload := api.EventPayload{ + Ski: featureRemote.Device().Ski(), + EventType: api.EventTypeDataChange, + ChangeType: api.ElementChangeUpdate, + Feature: featureRemote, + Device: featureRemote.Device(), + Entity: featureRemote.Entity(), + LocalFeature: r, + Function: function, + CmdClassifier: util.Ptr(model.CmdClassifierTypeNotify), + Data: data, + } + Events.Publish(payload) + + return nil +} + +func (r *FeatureLocal) processWrite(msg *api.Message) { + if err := r.executeWrite(msg); err != nil { + _ = msg.FeatureRemote.Device().Sender().ResultError(msg.RequestHeader, r.Address(), err) + } else if msg.RequestHeader != nil { + ackRequest := msg.RequestHeader.AckRequest + if ackRequest != nil && *ackRequest { + _ = msg.FeatureRemote.Device().Sender().ResultSuccess(msg.RequestHeader, r.Address()) + } + } +} + +func (r *FeatureLocal) executeWrite(msg *api.Message) *model.ErrorType { + cmdData, err := msg.Cmd.Data() + if err != nil { + return model.NewErrorType(model.ErrorNumberTypeCommandNotSupported, err.Error()) + } + if cmdData.Function == nil { + return model.NewErrorType(model.ErrorNumberTypeCommandNotSupported, "No function found for cmd data") + } + + fctData, err1 := r.updateData(true, *cmdData.Function, cmdData.Value, msg.FilterPartial, msg.FilterDelete) + if err1 != nil { + return err1 + } else if fctData == nil { + return model.NewErrorTypeFromString("function not found") + } + + r.Device().NotifySubscribers(r.Address(), fctData.NotifyOrWriteCmdType(nil, nil, false, nil)) + + payload := api.EventPayload{ + Ski: msg.FeatureRemote.Device().Ski(), + EventType: api.EventTypeDataChange, + ChangeType: api.ElementChangeUpdate, + Feature: msg.FeatureRemote, + Device: msg.FeatureRemote.Device(), + Entity: msg.FeatureRemote.Entity(), + LocalFeature: r, + Function: *cmdData.Function, + CmdClassifier: util.Ptr(model.CmdClassifierTypeWrite), + Data: cmdData.Value, + } + Events.Publish(payload) + + return nil +} + +func (r *FeatureLocal) functionData(function model.FunctionType) api.FunctionDataCmdInterface { + fd, found := r.functionDataMap[function] + if !found { + logging.Log().Errorf("Data was not found for function '%s'", function) + return nil + } + return fd +} + +func (r *FeatureLocal) Information() *model.NodeManagementDetailedDiscoveryFeatureInformationType { + var funs []model.FunctionPropertyType + for fun, operations := range r.operations { + var functionType = model.FunctionType(fun) + sf := model.FunctionPropertyType{ + Function: &functionType, + PossibleOperations: operations.Information(), + } + + funs = append(funs, sf) + } + + res := model.NodeManagementDetailedDiscoveryFeatureInformationType{ + Description: &model.NetworkManagementFeatureDescriptionDataType{ + FeatureAddress: r.Address(), + FeatureType: &r.ftype, + Role: &r.role, + Description: r.description, + SupportedFunction: funs, + }, + } + + return &res +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/feature_local_bind_test.go b/src/eebus-bridge/third_party/spine-go/spine/feature_local_bind_test.go new file mode 100644 index 0000000..a0dbec7 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/feature_local_bind_test.go @@ -0,0 +1,55 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// spine-go (see LICENSE). + +package spine + +import ( + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type nopWriter struct{ n atomic.Int32 } + +func (w *nopWriter) WriteShipMessageWithPayload([]byte) { w.n.Add(1) } + +// A binding or subscription requested again (the remote lost it) is sent +// again but recorded once: before, each request added a duplicate. +func TestBindAndSubscribeRecordedOnce(t *testing.T) { + local := NewDeviceLocal("Vendor", "Name", "Serial", "Code", "Address", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart) + entity := NewEntityLocal(local, model.EntityTypeTypeCEM, []model.AddressEntityType{1}, 4*time.Second) + local.AddEntity(entity) + client := NewFeatureLocal(entity.NextFeatureId(), entity, model.FeatureTypeTypeLoadControl, model.RoleTypeClient) + entity.AddFeature(client) + + writer := &nopWriter{} + remote := NewDeviceRemote(local, "ski", NewSender(writer)) + remote.address = util.Ptr(model.AddressDeviceType("RemoteAddress")) + local.AddRemoteDeviceForSki("ski", remote) + remoteEntity := NewEntityRemote(remote, model.EntityTypeTypeHeatPumpAppliance, []model.AddressEntityType{1}) + remote.AddEntity(remoteEntity) + server := NewFeatureRemote(remoteEntity.NextFeatureId(), remoteEntity, model.FeatureTypeTypeLoadControl, model.RoleTypeServer) + remoteEntity.AddFeature(server) + + // at once, too: the check and the append are one critical section + var wg sync.WaitGroup + for i := 0; i < 8; i++ { + wg.Add(1) + go func() { + defer wg.Done() + _, _ = client.BindToRemote(server.Address()) + _, _ = client.SubscribeToRemote(server.Address()) + }() + } + wg.Wait() + if writer.n.Load() < 2 { // (the sender itself drops repeats of an unanswered request) + t.Fatalf("requests sent: %d", writer.n.Load()) + } + if len(client.bindings) != 1 || len(client.subscriptions) != 1 { + t.Fatalf("recorded: %d bindings, %d subscriptions", len(client.bindings), len(client.subscriptions)) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/feature_remote.go b/src/eebus-bridge/third_party/spine-go/spine/feature_remote.go new file mode 100644 index 0000000..78e90c0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/feature_remote.go @@ -0,0 +1,120 @@ +package spine + +import ( + "sync" + "time" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/rickb777/date/period" +) + +const defaultMaxResponseDelay = time.Duration(time.Second * 10) + +type FeatureRemote struct { + *Feature + + entity api.EntityRemoteInterface + functionDataMap map[model.FunctionType]api.FunctionDataInterface + maxResponseDelay *time.Duration + + mux sync.Mutex +} + +func NewFeatureRemote(id uint, entity api.EntityRemoteInterface, ftype model.FeatureTypeType, role model.RoleType) *FeatureRemote { + res := &FeatureRemote{ + Feature: NewFeature( + featureAddressType(id, entity.Address()), + ftype, + role), + entity: entity, + functionDataMap: make(map[model.FunctionType]api.FunctionDataInterface), + } + for _, fd := range CreateFunctionData[api.FunctionDataInterface](ftype) { + res.functionDataMap[fd.FunctionType()] = fd + } + + res.operations = make(map[model.FunctionType]api.OperationsInterface) + + return res +} + +var _ api.FeatureRemoteInterface = (*FeatureRemote)(nil) + +/* FeatureRemoteInterface */ + +func (r *FeatureRemote) Device() api.DeviceRemoteInterface { + return r.entity.Device() +} + +func (r *FeatureRemote) Entity() api.EntityRemoteInterface { + return r.entity +} +func (r *FeatureRemote) DataCopy(function model.FunctionType) any { + r.mux.Lock() + defer r.mux.Unlock() + + fd := r.functionData(function) + if fd == nil { + return nil + } + + return r.functionData(function).DataCopyAny() +} + +func (r *FeatureRemote) UpdateData(persist bool, function model.FunctionType, data any, filterPartial *model.FilterType, filterDelete *model.FilterType) (any, *model.ErrorType) { + r.mux.Lock() + defer r.mux.Unlock() + + fd := r.functionData(function) + if fd == nil { + return nil, model.NewErrorTypeFromString("function data not found") + } + + return fd.UpdateDataAny(false, persist, data, filterPartial, filterDelete) +} + +func (r *FeatureRemote) SetOperations(functions []model.FunctionPropertyType) { + r.operations = make(map[model.FunctionType]api.OperationsInterface) + for _, sf := range functions { + if sf.PossibleOperations == nil { + continue + } + r.operations[*sf.Function] = NewOperations( + sf.PossibleOperations.Read != nil, + sf.PossibleOperations.Read != nil && sf.PossibleOperations.Read.Partial != nil, + sf.PossibleOperations.Write != nil, + sf.PossibleOperations.Write != nil && sf.PossibleOperations.Write.Partial != nil, + ) + } +} + +func (r *FeatureRemote) SetMaxResponseDelay(delay *model.MaxResponseDelayType) { + if delay == nil { + return + } + p, err := period.Parse(string(*delay)) + if err != nil { + r.maxResponseDelay = util.Ptr(p.DurationApprox()) + } else { + logging.Log().Debug(err) + } +} + +func (r *FeatureRemote) MaxResponseDelayDuration() time.Duration { + if r.maxResponseDelay != nil { + return *r.maxResponseDelay + } + return defaultMaxResponseDelay +} + +func (r *FeatureRemote) functionData(function model.FunctionType) api.FunctionDataInterface { + fd, found := r.functionDataMap[function] + if !found { + logging.Log().Errorf("Data was not found for function '%s'", function) + return nil + } + return fd +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/function_data.go b/src/eebus-bridge/third_party/spine-go/spine/function_data.go new file mode 100644 index 0000000..d7dd4c0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/function_data.go @@ -0,0 +1,133 @@ +// Modified from spine-go v0.7.0 (MIT, see LICENSE). Modifications +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md, under the same MIT +// licence: a partial update works on a copy of what it writes (readers of +// DataCopy shared its lists' items with the update). + +package spine + +import ( + "fmt" + "reflect" + "sync" + + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type FunctionData[T any] struct { + functionType model.FunctionType + data *T + + mux sync.Mutex +} + +func NewFunctionData[T any](function model.FunctionType) *FunctionData[T] { + return &FunctionData[T]{ + functionType: function, + } +} + +var _ api.FunctionDataInterface = (*FunctionData[int])(nil) + +/* FunctionDataInterface */ + +func (r *FunctionData[T]) FunctionType() model.FunctionType { + return r.functionType +} + +func (r *FunctionData[T]) SupportsPartialWrite() bool { + return util.Implements[T, model.Updater]() +} + +func (r *FunctionData[T]) DataCopy() *T { + r.mux.Lock() + defer r.mux.Unlock() + + // copy the data and return it as the data can be updated + // and newly assigned at any time otherwise we run into panics + // because of invalid memory address or nil pointer dereference + var copiedData T + if r.data == nil { + return nil + } + + copiedData = *r.data + + return &copiedData +} + +func (r *FunctionData[T]) UpdateData(remoteWrite, persist bool, newData *T, filterPartial *model.FilterType, filterDelete *model.FilterType) (any, *model.ErrorType) { + r.mux.Lock() + defer r.mux.Unlock() + + if filterPartial == nil && filterDelete == nil && persist { + // just set the data + r.data = newData + return r.data, nil + } + + if !r.SupportsPartialWrite() { + return nil, model.NewErrorTypeFromString(fmt.Sprintf("partial updates are not supported for type '%s'", util.Type[T]().Name())) + } + + if r.data == nil { + r.data = new(T) + } else { + // update a copy: DataCopy hands out the same slices, which the + // update would otherwise change in place under their readers + r.data = copyForUpdate(r.data) + } + + updater := any(r.data).(model.Updater) + data, success := updater.UpdateList(remoteWrite, persist, newData, filterPartial, filterDelete) + if !success { + return nil, model.NewErrorTypeFromString("update failed, likely not allowed to write") + } + + return data, nil +} + +// copyForUpdate: what a partial update writes, copied (copy-on-write); the +// rest shared. The update (model.UpdateList: Merge, copyToSelectedData, +// copyToAllData, deleteFilteredData) changes only the items of the data's +// list fields, by setting their fields with reflection: a field set to a +// new pointer, a new nested slice or zero (updateFields, +// CopyNonNilDataFromItemToItem, RemoveElementFromItem); it never writes +// through an item's pointers into the values they point to, nor into a +// nested slice's array, and Merge builds a new list. So new arrays for the +// list fields, with the items copied by value, keep the update off what +// readers of DataCopy hold, without copying the values behind the pointers +// (BenchmarkPartialUpdate200: a full deep copy cost 160 µs per update of a +// 200-item list, this a few µs). +func copyForUpdate[T any](data *T) *T { + copied := *data + v := reflect.ValueOf(&copied).Elem() + if v.Kind() != reflect.Struct { + return &copied + } + for i := 0; i < v.NumField(); i++ { + f := v.Field(i) + if f.Kind() != reflect.Slice || f.IsNil() || !f.CanSet() { + continue + } + s := reflect.MakeSlice(f.Type(), f.Len(), f.Len()) + reflect.Copy(s, f) + f.Set(s) + } + return &copied +} + +func (r *FunctionData[T]) DataCopyAny() any { + return r.DataCopy() +} + +func (r *FunctionData[T]) UpdateDataAny(remoteWrite, persist bool, newData any, filterPartial *model.FilterType, filterDelete *model.FilterType) (any, *model.ErrorType) { + data, err := r.UpdateData(remoteWrite, persist, newData.(*T), filterPartial, filterDelete) + if err != nil { + logging.Log().Debug(err.String()) + } + + return data, err +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/function_data_bench_test.go b/src/eebus-bridge/third_party/spine-go/spine/function_data_bench_test.go new file mode 100644 index 0000000..dfa96b4 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/function_data_bench_test.go @@ -0,0 +1,47 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// spine-go (see LICENSE). + +package spine + +import ( + "testing" + + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +func limitList(n int) *model.LoadControlLimitListDataType { + l := &model.LoadControlLimitListDataType{} + for i := 0; i < n; i++ { + l.LoadControlLimitData = append(l.LoadControlLimitData, model.LoadControlLimitDataType{ + LimitId: util.Ptr(model.LoadControlLimitIdType(i)), IsLimitChangeable: util.Ptr(true), + IsLimitActive: util.Ptr(false), Value: model.NewScaledNumberType(float64(i)), + }) + } + return l +} + +// The copy a partial update makes (copyForUpdate), on a 200-item list. +func BenchmarkCopyForUpdate200(b *testing.B) { + l := limitList(200) + b.ReportAllocs() + for i := 0; i < b.N; i++ { + _ = copyForUpdate(l) + } +} + +// A partial update of one item of a 200-item list (copy and merge). +func BenchmarkPartialUpdate200(b *testing.B) { + fd := NewFunctionData[model.LoadControlLimitListDataType](model.FunctionTypeLoadControlLimitListData) + fd.UpdateData(false, true, limitList(200), nil, nil) + update := &model.LoadControlLimitListDataType{LoadControlLimitData: []model.LoadControlLimitDataType{ + {LimitId: util.Ptr(model.LoadControlLimitIdType(7)), IsLimitActive: util.Ptr(true), Value: model.NewScaledNumberType(4200)}, + }} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + if _, err := fd.UpdateData(false, false, update, nil, nil); err != nil { + b.Fatal(err) + } + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/function_data_cmd.go b/src/eebus-bridge/third_party/spine-go/spine/function_data_cmd.go new file mode 100644 index 0000000..c639dc0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/function_data_cmd.go @@ -0,0 +1,117 @@ +package spine + +import ( + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type FunctionDataCmd[T any] struct { + *FunctionData[T] +} + +func NewFunctionDataCmd[T any](function model.FunctionType) *FunctionDataCmd[T] { + return &FunctionDataCmd[T]{ + FunctionData: NewFunctionData[T](function), + } +} + +var _ api.FunctionDataCmdInterface = (*FunctionDataCmd[int])(nil) + +/* FunctionDataCmdInterface */ + +func (r *FunctionDataCmd[T]) ReadCmdType(partialSelector any, elements any) model.CmdType { + cmd := createCmd[T](r.functionType, nil) + + var filters []model.FilterType + filters = filtersForSelectorsElements(r.functionType, filters, nil, partialSelector, nil, elements) + if len(filters) > 0 { + cmd.Filter = filters + cmd.Function = util.Ptr(model.FunctionType("")) + } + + return cmd +} + +func (r *FunctionDataCmd[T]) ReplyCmdType(partial bool) model.CmdType { + data := r.DataCopy() + cmd := createCmd(r.functionType, data) + if partial { + cmd.Filter = filterEmptyPartial() + cmd.Function = util.Ptr(model.FunctionType("")) + } + return cmd +} + +func (r *FunctionDataCmd[T]) NotifyOrWriteCmdType(deleteSelector, partialSelector any, partialWithoutSelector bool, deleteElements any) model.CmdType { + data := r.DataCopy() + cmd := createCmd(r.functionType, data) + + if partialWithoutSelector { + cmd.Filter = filterEmptyPartial() + cmd.Function = util.Ptr(model.FunctionType(r.functionType)) + return cmd + } + var filters []model.FilterType + if filters := filtersForSelectorsElements(r.functionType, filters, deleteSelector, partialSelector, deleteElements, nil); len(filters) > 0 { + cmd.Filter = filters + cmd.Function = util.Ptr(model.FunctionType(r.functionType)) + } + + return cmd +} + +func filtersForSelectorsElements(functionType model.FunctionType, filters []model.FilterType, deleteSelector, partialSelector any, deleteElements, readElements any) []model.FilterType { + if !util.IsNil(deleteSelector) || !util.IsNil(deleteElements) { + filter := model.FilterType{CmdControl: &model.CmdControlType{Delete: &model.ElementTagType{}}} + if !util.IsNil(deleteSelector) { + filter = addSelectorToFilter(filter, functionType, &deleteSelector) + } + if !util.IsNil(deleteElements) { + filter = addElementToFilter(filter, functionType, &deleteElements) + } + filters = append(filters, filter) + } + + if !util.IsNil(partialSelector) || !util.IsNil(readElements) { + filter := model.FilterType{CmdControl: &model.CmdControlType{Partial: &model.ElementTagType{}}} + if !util.IsNil(partialSelector) { + filter = addSelectorToFilter(filter, functionType, partialSelector) + } + if !util.IsNil(readElements) { + filter = addElementToFilter(filter, functionType, readElements) + } + filters = append(filters, filter) + } + + return filters +} + +// simple helper for adding a single filterType without any selectors +func filterEmptyPartial() []model.FilterType { + return []model.FilterType{*model.NewFilterTypePartial()} +} + +func addSelectorToFilter(filter model.FilterType, function model.FunctionType, data any) model.FilterType { + result := filter + + result.SetDataForFunction(model.EEBusTagTypeTypeSelector, function, data) + + return result +} + +func addElementToFilter(filter model.FilterType, function model.FunctionType, data any) model.FilterType { + result := filter + + result.SetDataForFunction(model.EEbusTagTypeTypeElements, function, data) + + return result +} + +func createCmd[T any](function model.FunctionType, data *T) model.CmdType { + result := model.CmdType{} + + result.SetDataForFunction(function, data) + + return result +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/function_data_copy_test.go b/src/eebus-bridge/third_party/spine-go/spine/function_data_copy_test.go new file mode 100644 index 0000000..b2217f8 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/function_data_copy_test.go @@ -0,0 +1,102 @@ +// Copyright © 2026 Setti Solutions S.R.L, www.setti.md. MIT licence, as +// spine-go (see LICENSE). + +package spine + +import ( + "encoding/json" + "sync" + "testing" + + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +// Partial updates of a list with nested lists (a time series' slots): a +// copy taken before them keeps every value, nested ones included (the +// update writes item fields of a copied list, never through pointers or +// into nested arrays: copyForUpdate). +func TestUpdatesLeaveEarlierCopiesAlone(t *testing.T) { + fd := NewFunctionData[model.TimeSeriesListDataType](model.FunctionTypeTimeSeriesListData) + slots := func(v float64) []model.TimeSeriesSlotType { + return []model.TimeSeriesSlotType{ + {TimeSeriesSlotId: util.Ptr(model.TimeSeriesSlotIdType(0)), Value: model.NewScaledNumberType(v)}, + {TimeSeriesSlotId: util.Ptr(model.TimeSeriesSlotIdType(1)), Value: model.NewScaledNumberType(v + 1)}, + } + } + fd.UpdateData(false, true, &model.TimeSeriesListDataType{TimeSeriesData: []model.TimeSeriesDataType{ + {TimeSeriesId: util.Ptr(model.TimeSeriesIdType(1)), TimeSeriesSlot: slots(1)}, + {TimeSeriesId: util.Ptr(model.TimeSeriesIdType(2)), TimeSeriesSlot: slots(10)}, + }}, nil, nil) + before := fd.DataCopy() + snapshot, _ := json.Marshal(before) + + // merged by id (a new slots list for series 1) + fd.UpdateData(false, false, &model.TimeSeriesListDataType{TimeSeriesData: []model.TimeSeriesDataType{ + {TimeSeriesId: util.Ptr(model.TimeSeriesIdType(1)), TimeSeriesSlot: slots(100)}, + }}, nil, nil) + // without ids: copied into every item + fd.UpdateData(false, false, &model.TimeSeriesListDataType{TimeSeriesData: []model.TimeSeriesDataType{ + {TimeSeriesSlot: slots(1000)}, + }}, nil, nil) + + if after, _ := json.Marshal(before); string(after) != string(snapshot) { + t.Fatalf("an earlier copy changed:\nbefore %s\nafter %s", snapshot, after) + } + now := fd.DataCopy() + if v := now.TimeSeriesData[1].TimeSeriesSlot[0].Value.GetValue(); v != 1000 { + t.Fatalf("the updates themselves: %v", v) + } +} + +// A partial update while others read DataCopy: before, the update changed +// the items of the slice DataCopy had handed out (a data race, go test +// -race). Now it works on a copy; a copy taken before keeps its values. +func TestPartialUpdateLeavesCopiesAlone(t *testing.T) { + fd := NewFunctionData[model.LoadControlLimitListDataType](model.FunctionTypeLoadControlLimitListData) + initial := &model.LoadControlLimitListDataType{LoadControlLimitData: []model.LoadControlLimitDataType{ + {LimitId: util.Ptr(model.LoadControlLimitIdType(0)), IsLimitActive: util.Ptr(false), Value: model.NewScaledNumberType(9000)}, + {LimitId: util.Ptr(model.LoadControlLimitIdType(1)), IsLimitActive: util.Ptr(false), Value: model.NewScaledNumberType(9000)}, + }} + fd.UpdateData(false, true, initial, nil, nil) + before := fd.DataCopy() + + var wg sync.WaitGroup + stop := make(chan struct{}) + wg.Add(1) + go func() { + defer wg.Done() + for { + select { + case <-stop: + return + default: + } + if d := fd.DataCopy(); d != nil { + for _, item := range d.LoadControlLimitData { + _ = item.IsLimitActive + _ = item.Value + } + } + } + }() + for i := 0; i < 500; i++ { + // no identifiers: copied into every item (persist false: a partial update) + update := &model.LoadControlLimitListDataType{LoadControlLimitData: []model.LoadControlLimitDataType{ + {IsLimitActive: util.Ptr(i%2 == 0), Value: model.NewScaledNumberType(float64(4200 + i))}, + }} + if _, err := fd.UpdateData(false, false, update, nil, nil); err != nil { + t.Fatal(err) + } + } + close(stop) + wg.Wait() + + if *before.LoadControlLimitData[0].IsLimitActive || before.LoadControlLimitData[0].Value.GetValue() != 9000 { + t.Fatalf("a copy taken before the updates changed: %+v", before.LoadControlLimitData[0]) + } + after := fd.DataCopy() + if len(after.LoadControlLimitData) != 2 || after.LoadControlLimitData[1].Value.GetValue() != 4699 { + t.Fatalf("the updates: %+v", after.LoadControlLimitData) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/function_data_factory.go b/src/eebus-bridge/third_party/spine-go/spine/function_data_factory.go new file mode 100644 index 0000000..e6feb01 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/function_data_factory.go @@ -0,0 +1,319 @@ +package spine + +import ( + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +func CreateFunctionData[F any](featureType model.FeatureTypeType) []F { + // Some devices use generic for everything (e.g. Vaillant Arotherm heatpump) + // or for some things like the SMA HM 2.0 or Elli Wallbox, which uses Generic feature + // for Heartbeats, even though that should go into FeatureTypeTypeDeviceDiagnosis + // Hence we add everything to the Generic feature, as we don't know what might be needed + + var result []F + + if featureType == model.FeatureTypeTypeNodeManagement { + result = []F{ + createFunctionData[model.NodeManagementDestinationListDataType, F](model.FunctionTypeNodeManagementDestinationListData), + createFunctionData[model.NodeManagementDetailedDiscoveryDataType, F](model.FunctionTypeNodeManagementDetailedDiscoveryData), + createFunctionData[model.NodeManagementUseCaseDataType, F](model.FunctionTypeNodeManagementUseCaseData), + } + + return result + } + + if featureType == model.FeatureTypeTypeActuatorLevel || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.ActuatorLevelDataType, F](model.FunctionTypeActuatorLevelData), + createFunctionData[model.ActuatorLevelDescriptionDataType, F](model.FunctionTypeActuatorLevelDescriptionData), + }...) + } + + if featureType == model.FeatureTypeTypeActuatorSwitch || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.ActuatorSwitchDataType, F](model.FunctionTypeActuatorSwitchData), + createFunctionData[model.ActuatorSwitchDescriptionDataType, F](model.FunctionTypeActuatorSwitchDescriptionData), + }...) + } + + if featureType == model.FeatureTypeTypeAlarm || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.AlarmListDataType, F](model.FunctionTypeAlarmListData), + }...) + } + + if featureType == model.FeatureTypeTypeBill || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.BillDescriptionListDataType, F](model.FunctionTypeBillDescriptionListData), + createFunctionData[model.BillConstraintsListDataType, F](model.FunctionTypeBillConstraintsListData), + createFunctionData[model.BillListDataType, F](model.FunctionTypeBillListData), + }...) + } + + if featureType == model.FeatureTypeTypeDataTunneling || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.DataTunnelingCallType, F](model.FunctionTypeDataTunnelingCall), + }...) + } + + if featureType == model.FeatureTypeTypeDeviceClassification || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.DeviceClassificationManufacturerDataType, F](model.FunctionTypeDeviceClassificationManufacturerData), + createFunctionData[model.DeviceClassificationUserDataType, F](model.FunctionTypeDeviceClassificationUserData), + }...) + } + + if featureType == model.FeatureTypeTypeDeviceConfiguration || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.DeviceConfigurationKeyValueConstraintsListDataType, F](model.FunctionTypeDeviceConfigurationKeyValueConstraintsListData), + createFunctionData[model.DeviceConfigurationKeyValueDescriptionListDataType, F](model.FunctionTypeDeviceConfigurationKeyValueDescriptionListData), + createFunctionData[model.DeviceConfigurationKeyValueListDataType, F](model.FunctionTypeDeviceConfigurationKeyValueListData), + }...) + } + + if featureType == model.FeatureTypeTypeDeviceDiagnosis || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.DeviceDiagnosisStateDataType, F](model.FunctionTypeDeviceDiagnosisStateData), + createFunctionData[model.DeviceDiagnosisHeartbeatDataType, F](model.FunctionTypeDeviceDiagnosisHeartbeatData), + createFunctionData[model.DeviceDiagnosisServiceDataType, F](model.FunctionTypeDeviceDiagnosisServiceData), + }...) + } + + if featureType == model.FeatureTypeTypeDirectControl || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.DirectControlActivityListDataType, F](model.FunctionTypeDirectControlActivityListData), + createFunctionData[model.DirectControlDescriptionDataType, F](model.FunctionTypeDirectControlDescriptionData), + }...) + } + + if featureType == model.FeatureTypeTypeElectricalConnection || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.ElectricalConnectionDescriptionListDataType, F](model.FunctionTypeElectricalConnectionDescriptionListData), + createFunctionData[model.ElectricalConnectionParameterDescriptionListDataType, F](model.FunctionTypeElectricalConnectionParameterDescriptionListData), + createFunctionData[model.ElectricalConnectionPermittedValueSetListDataType, F](model.FunctionTypeElectricalConnectionPermittedValueSetListData), + createFunctionData[model.ElectricalConnectionStateListDataType, F](model.FunctionTypeElectricalConnectionStateListData), + createFunctionData[model.ElectricalConnectionCharacteristicDataType, F](model.FunctionTypeElectricalConnectionCharacteristicData), + createFunctionData[model.ElectricalConnectionCharacteristicListDataType, F](model.FunctionTypeElectricalConnectionCharacteristicListData), + }...) + } + + if featureType == model.FeatureTypeTypeHvac || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.HvacOperationModeDescriptionDataType, F](model.FunctionTypeHvacOperationModeDescriptionListData), + createFunctionData[model.HvacOverrunDescriptionListDataType, F](model.FunctionTypeHvacOverrunDescriptionListData), + createFunctionData[model.HvacOverrunListDataType, F](model.FunctionTypeHvacOverrunListData), + createFunctionData[model.HvacSystemFunctionDescriptionDataType, F](model.FunctionTypeHvacSystemFunctionDescriptionListData), + createFunctionData[model.HvacSystemFunctionListDataType, F](model.FunctionTypeHvacSystemFunctionListData), + createFunctionData[model.HvacSystemFunctionOperationModeRelationListDataType, F](model.FunctionTypeHvacSystemFunctionOperationModeRelationListData), + createFunctionData[model.HvacSystemFunctionPowerSequenceRelationListDataType, F](model.FunctionTypeHvacSystemFunctionPowerSequenceRelationListData), + createFunctionData[model.HvacSystemFunctionSetpointRelationListDataType, F](model.FunctionTypeHvacSystemFunctionSetPointRelationListData), + }...) + } + + if featureType == model.FeatureTypeTypeIdentification || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.IdentificationListDataType, F](model.FunctionTypeIdentificationListData), + createFunctionData[model.SessionIdentificationListDataType, F](model.FunctionTypeSessionIdentificationListData), + createFunctionData[model.SessionMeasurementRelationListDataType, F](model.FunctionTypeSessionMeasurementRelationListData), + }...) + } + + if featureType == model.FeatureTypeTypeIncentiveTable || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.IncentiveTableDescriptionDataType, F](model.FunctionTypeIncentiveTableDescriptionData), + createFunctionData[model.IncentiveTableConstraintsDataType, F](model.FunctionTypeIncentiveTableConstraintsData), + createFunctionData[model.IncentiveTableDataType, F](model.FunctionTypeIncentiveTableData), + }...) + } + + if featureType == model.FeatureTypeTypeLoadControl || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.LoadControlEventListDataType, F](model.FunctionTypeLoadControlEventListData), + createFunctionData[model.LoadControlLimitConstraintsListDataType, F](model.FunctionTypeLoadControlLimitConstraintsListData), + createFunctionData[model.LoadControlLimitDescriptionListDataType, F](model.FunctionTypeLoadControlLimitDescriptionListData), + createFunctionData[model.LoadControlLimitListDataType, F](model.FunctionTypeLoadControlLimitListData), + createFunctionData[model.LoadControlNodeDataType, F](model.FunctionTypeLoadControlNodeData), + createFunctionData[model.LoadControlStateListDataType, F](model.FunctionTypeLoadControlStateListData), + }...) + } + + if featureType == model.FeatureTypeTypeMeasurement || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.MeasurementListDataType, F](model.FunctionTypeMeasurementListData), + createFunctionData[model.MeasurementDescriptionListDataType, F](model.FunctionTypeMeasurementDescriptionListData), + createFunctionData[model.MeasurementConstraintsListDataType, F](model.FunctionTypeMeasurementConstraintsListData), + createFunctionData[model.MeasurementThresholdRelationListDataType, F](model.FunctionTypeMeasurementThresholdRelationListData), + createFunctionData[model.MeasurementSeriesListDataType, F](model.FunctionTypeMeasurementSeriesListData), + }...) + } + + if featureType == model.FeatureTypeTypeMessaging || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.MessagingListDataType, F](model.FunctionTypeMessagingListData), + }...) + } + + if featureType == model.FeatureTypeTypeNetworkManagement || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.NetworkManagementAbortCallType, F](model.FunctionTypeNetworkManagementAbortCall), + createFunctionData[model.NetworkManagementAddNodeCallType, F](model.FunctionTypeNetworkManagementAddNodeCall), + createFunctionData[model.NetworkManagementDeviceDescriptionListDataType, F](model.FunctionTypeNetworkManagementDeviceDescriptionListData), + createFunctionData[model.NetworkManagementDiscoverCallType, F](model.FunctionTypeNetworkManagementDiscoverCall), + createFunctionData[model.NetworkManagementEntityDescriptionListDataType, F](model.FunctionTypeNetworkManagementEntityDescriptionListData), + createFunctionData[model.NetworkManagementFeatureDescriptionListDataType, F](model.FunctionTypeNetworkManagementFeatureDescriptionListData), + createFunctionData[model.NetworkManagementJoiningModeDataType, F](model.FunctionTypeNetworkManagementJoiningModeData), + createFunctionData[model.NetworkManagementModifyNodeCallType, F](model.FunctionTypeNetworkManagementModifyNodeCall), + createFunctionData[model.NetworkManagementProcessStateDataType, F](model.FunctionTypeNetworkManagementProcessStateData), + createFunctionData[model.NetworkManagementRemoveNodeCallType, F](model.FunctionTypeNetworkManagementRemoveNodeCall), + createFunctionData[model.NetworkManagementReportCandidateDataType, F](model.FunctionTypeNetworkManagementReportCandidateData), + createFunctionData[model.NetworkManagementScanNetworkCallType, F](model.FunctionTypeNetworkManagementScanNetworkCall), + }...) + } + + if featureType == model.FeatureTypeTypeOperatingConstraints || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.OperatingConstraintsDurationListDataType, F](model.FunctionTypeOperatingConstraintsDurationListData), + createFunctionData[model.OperatingConstraintsInterruptListDataType, F](model.FunctionTypeOperatingConstraintsInterruptListData), + createFunctionData[model.OperatingConstraintsPowerDescriptionListDataType, F](model.FunctionTypeOperatingConstraintsPowerDescriptionListData), + createFunctionData[model.OperatingConstraintsPowerLevelListDataType, F](model.FunctionTypeOperatingConstraintsPowerLevelListData), + createFunctionData[model.OperatingConstraintsPowerRangeListDataType, F](model.FunctionTypeOperatingConstraintsPowerRangeListData), + createFunctionData[model.OperatingConstraintsResumeImplicationListDataType, F](model.FunctionTypeOperatingConstraintsResumeImplicationListData), + }...) + } + + if featureType == model.FeatureTypeTypePowerSequences || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.PowerSequenceAlternativesRelationListDataType, F](model.FunctionTypePowerSequenceAlternativesRelationListData), + createFunctionData[model.PowerSequenceDescriptionListDataType, F](model.FunctionTypePowerSequenceDescriptionListData), + createFunctionData[model.PowerSequenceNodeScheduleInformationDataType, F](model.FunctionTypePowerSequenceNodeScheduleInformationData), + createFunctionData[model.PowerSequencePriceCalculationRequestCallType, F](model.FunctionTypePowerSequencePriceCalculationRequestCall), + createFunctionData[model.PowerSequencePriceListDataType, F](model.FunctionTypePowerSequencePriceListData), + createFunctionData[model.PowerSequenceScheduleConfigurationRequestCallType, F](model.FunctionTypePowerSequenceScheduleConfigurationRequestCall), + createFunctionData[model.PowerSequenceScheduleConstraintsListDataType, F](model.FunctionTypePowerSequenceScheduleConstraintsListData), + createFunctionData[model.PowerSequenceScheduleListDataType, F](model.FunctionTypePowerSequenceScheduleListData), + createFunctionData[model.PowerSequenceSchedulePreferenceListDataType, F](model.FunctionTypePowerSequenceSchedulePreferenceListData), + createFunctionData[model.PowerSequenceStateListDataType, F](model.FunctionTypePowerSequenceStateListData), + createFunctionData[model.PowerTimeSlotScheduleConstraintsListDataType, F](model.FunctionTypePowerTimeSlotScheduleConstraintsListData), + createFunctionData[model.PowerTimeSlotScheduleListDataType, F](model.FunctionTypePowerTimeSlotScheduleListData), + createFunctionData[model.PowerTimeSlotValueListDataType, F](model.FunctionTypePowerTimeSlotValueListData), + }...) + } + + if featureType == model.FeatureTypeTypeSensing || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.SensingDescriptionDataType, F](model.FunctionTypeSensingDescriptionData), + createFunctionData[model.SensingListDataType, F](model.FunctionTypeSensingListData), + }...) + } + + if featureType == model.FeatureTypeTypeSetpoint || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.SetpointConstraintsListDataType, F](model.FunctionTypeSetpointConstraintsListData), + createFunctionData[model.SetpointDescriptionListDataType, F](model.FunctionTypeSetpointDescriptionListData), + createFunctionData[model.SetpointListDataType, F](model.FunctionTypeSetpointListData), + }...) + } + + if featureType == model.FeatureTypeTypeSmartEnergyManagementPs || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.SmartEnergyManagementPsConfigurationRequestCallType, F](model.FunctionTypeSmartEnergyManagementPsConfigurationRequestCall), + createFunctionData[model.SmartEnergyManagementPsDataType, F](model.FunctionTypeSmartEnergyManagementPsData), + createFunctionData[model.SmartEnergyManagementPsPriceCalculationRequestCallType, F](model.FunctionTypeSmartEnergyManagementPsPriceCalculationRequestCall), + createFunctionData[model.SmartEnergyManagementPsPriceDataType, F](model.FunctionTypeSmartEnergyManagementPsPriceData), + }...) + } + + if featureType == model.FeatureTypeTypeStateInformation || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.StateInformationListDataType, F](model.FunctionTypeStateInformationListData), + }...) + } + + if featureType == model.FeatureTypeTypeSupplyCondition || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.SupplyConditionDescriptionListDataType, F](model.FunctionTypeSupplyConditionDescriptionListData), + createFunctionData[model.SupplyConditionListDataType, F](model.FunctionTypeSupplyConditionListData), + createFunctionData[model.SupplyConditionThresholdRelationListDataType, F](model.FunctionTypeSupplyConditionThresholdRelationListData), + }...) + } + + if featureType == model.FeatureTypeTypeTariffInformation || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.IncentiveDescriptionListDataType, F](model.FunctionTypeIncentiveDescriptionListData), + createFunctionData[model.IncentiveListDataType, F](model.FunctionTypeIncentiveListData), + createFunctionData[model.TariffBoundaryRelationListDataType, F](model.FunctionTypeTariffBoundaryRelationListData), + createFunctionData[model.TariffDescriptionListDataType, F](model.FunctionTypeTariffDescriptionListData), + createFunctionData[model.TariffListDataType, F](model.FunctionTypeTariffListData), + createFunctionData[model.TariffOverallConstraintsDataType, F](model.FunctionTypeTariffOverallConstraintsData), + createFunctionData[model.TariffTierRelationListDataType, F](model.FunctionTypeTariffTierRelationListData), + createFunctionData[model.TierBoundaryDescriptionListDataType, F](model.FunctionTypeTierBoundaryDescriptionListData), + createFunctionData[model.TierBoundaryListDataType, F](model.FunctionTypeTierBoundaryListData), + createFunctionData[model.TierDescriptionListDataType, F](model.FunctionTypeTierDescriptionListData), + createFunctionData[model.TierIncentiveRelationListDataType, F](model.FunctionTypeTierIncentiveRelationListData), + createFunctionData[model.TierListDataType, F](model.FunctionTypeTierListData), + }...) + } + + if featureType == model.FeatureTypeTypeTaskManagement || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.TaskManagementJobDescriptionListDataType, F](model.FunctionTypeTaskManagementJobDescriptionListData), + createFunctionData[model.TaskManagementJobListDataType, F](model.FunctionTypeTaskManagementJobListData), + createFunctionData[model.TaskManagementJobRelationListDataType, F](model.FunctionTypeTaskManagementJobRelationListData), + createFunctionData[model.TaskManagementOverviewDataType, F](model.FunctionTypeTaskManagementOverviewData), + }...) + } + + if featureType == model.FeatureTypeTypeThreshold || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.ThresholdConstraintsListDataType, F](model.FunctionTypeThresholdConstraintsListData), + createFunctionData[model.ThresholdDescriptionListDataType, F](model.FunctionTypeThresholdDescriptionListData), + createFunctionData[model.ThresholdListDataType, F](model.FunctionTypeThresholdListData), + }...) + } + + if featureType == model.FeatureTypeTypeTimeInformation || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.TimeDistributorDataType, F](model.FunctionTypeTimeDistributorData), + createFunctionData[model.TimeDistributorEnquiryCallType, F](model.FunctionTypeTimeDistributorEnquiryCall), + createFunctionData[model.TimeInformationDataType, F](model.FunctionTypeTimeInformationData), + createFunctionData[model.TimePrecisionDataType, F](model.FunctionTypeTimePrecisionData), + }...) + } + + if featureType == model.FeatureTypeTypeTimeSeries || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.TimeSeriesDescriptionListDataType, F](model.FunctionTypeTimeSeriesDescriptionListData), + createFunctionData[model.TimeSeriesConstraintsListDataType, F](model.FunctionTypeTimeSeriesConstraintsListData), + createFunctionData[model.TimeSeriesListDataType, F](model.FunctionTypeTimeSeriesListData), + }...) + } + + if featureType == model.FeatureTypeTypeTimeTable || featureType == model.FeatureTypeTypeGeneric { + result = append(result, []F{ + createFunctionData[model.TimeTableConstraintsListDataType, F](model.FunctionTypeTimeTableConstraintsListData), + createFunctionData[model.TimeTableDescriptionListDataType, F](model.FunctionTypeTimeTableDescriptionListData), + createFunctionData[model.TimeTableListDataType, F](model.FunctionTypeTimeTableListData), + }...) + } + + if len(result) == 0 { + panic(fmt.Errorf("unknown featureType '%s'", featureType)) + } + + return result +} + +func createFunctionData[T any, F any](functionType model.FunctionType) F { + x := any(new(F)) + switch x.(type) { + case *api.FunctionDataCmdInterface: + return any(NewFunctionDataCmd[T](functionType)).(F) + case *api.FunctionDataInterface: + return any(NewFunctionData[T](functionType)).(F) + default: + panic(fmt.Errorf("only FunctionData and FunctionDataCmd are supported")) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/heartbeat_manager.go b/src/eebus-bridge/third_party/spine-go/spine/heartbeat_manager.go new file mode 100644 index 0000000..8e663b9 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/heartbeat_manager.go @@ -0,0 +1,160 @@ +package spine + +import ( + "sync" + "sync/atomic" + "time" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type HeartbeatManager struct { + localEntity api.EntityLocalInterface + localFeature api.FeatureLocalInterface + + heartBeatNum uint64 // see https://github.com/golang/go/issues/11891 + stopHeartbeatC chan struct{} + stopMux sync.Mutex + + heartBeatTimeout *model.DurationType + + mux sync.Mutex +} + +var _ api.HeartbeatManagerInterface = (*HeartbeatManager)(nil) + +// Create a new Heartbeat Manager which handles sending of heartbeats +func NewHeartbeatManager(localEntity api.EntityLocalInterface, timeout time.Duration) *HeartbeatManager { + h := &HeartbeatManager{ + localEntity: localEntity, + heartBeatTimeout: model.NewDurationType(timeout), + } + + return h +} + +func (c *HeartbeatManager) IsHeartbeatRunning() bool { + c.stopMux.Lock() + defer c.stopMux.Unlock() + + if c.stopHeartbeatC != nil && !c.isHeartbeatClosed() { + return true + } + + return false +} + +func (c *HeartbeatManager) SetLocalFeature(entity api.EntityLocalInterface, feature api.FeatureLocalInterface) { + if entity == nil || feature == nil { + return + } + + if feature.Type() != model.FeatureTypeTypeDeviceDiagnosis || + feature.Role() != model.RoleTypeServer { + return + } + + // check if the local device diagnosis server feature, supports the heartbeat function + ops, ok := feature.Operations()[model.FunctionTypeDeviceDiagnosisHeartbeatData] + if !ok || !ops.Read() { + return + } + + c.mux.Lock() + + c.localEntity = entity + c.localFeature = feature + + // initialise heartbeat data + heartbeatData := c.heartbeatData(time.Now().UTC(), c.heartBeatCounter()) + + // updating the data will automatically notify all subscribed remote features + feature.SetData(model.FunctionTypeDeviceDiagnosisHeartbeatData, heartbeatData) + + c.mux.Unlock() + + // start creating heartbeats + _ = c.StartHeartbeat() +} + +// Start setting heartbeat data +// Make sure the a required FeatureTypeTypeDeviceDiagnosis with the role server is present +// otherwise this will end with an error +// Note: Remote features need to have a subscription to get notifications +func (c *HeartbeatManager) StartHeartbeat() error { + timeout, err := c.heartBeatTimeout.GetTimeDuration() + if err != nil { + return err + } + + // stop an already running heartbeat + c.StopHeartbeat() + + c.stopHeartbeatC = make(chan struct{}) + + go c.updateHeartbeatData(c.stopHeartbeatC, timeout) + + return nil +} + +// Stop updating heartbeat data +// Note: No active subscribers will get any further notifications! +func (c *HeartbeatManager) StopHeartbeat() { + if c.IsHeartbeatRunning() { + close(c.stopHeartbeatC) + } +} + +func (c *HeartbeatManager) heartbeatData(t time.Time, counter *uint64) *model.DeviceDiagnosisHeartbeatDataType { + timestamp := model.NewAbsoluteOrRelativeTimeTypeFromTime(t) + + return &model.DeviceDiagnosisHeartbeatDataType{ + Timestamp: timestamp, + HeartbeatCounter: counter, + HeartbeatTimeout: c.heartBeatTimeout, + } +} + +func (c *HeartbeatManager) updateHeartbeatData(stopC chan struct{}, d time.Duration) { + // Substract two seconds, because some devices (like Elli Connect/Pro) with OPEV/OSCEV interpret + // the heartbeat timeout (<= 4s) as the time within which a heartbeat should be received and otherwise + // will go into fallback mode. + // But other EVSE devices and in LPC (<= 60s), the heartbeat should be considered missing, if it is not + // received within twice the heartbeat timeout timeframe. + if d > 2*time.Second { + d -= 2 * time.Second + } + ticker := time.NewTicker(d) + for { + select { + case <-ticker.C: + + heartbeatData := c.heartbeatData(time.Now().UTC(), c.heartBeatCounter()) + + c.mux.Lock() + // updating the data will automatically notify all subscribed remote features + c.localFeature.SetData(model.FunctionTypeDeviceDiagnosisHeartbeatData, heartbeatData) + c.mux.Unlock() + + case <-stopC: + return + } + } +} + +func (c *HeartbeatManager) isHeartbeatClosed() bool { + select { + case <-c.stopHeartbeatC: + return true + default: + } + + return false +} + +// TODO heartBeatCounter should be global on CEM level, not on connection level +func (c *HeartbeatManager) heartBeatCounter() *uint64 { + i := atomic.AddUint64(&c.heartBeatNum, 1) + return &i +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement.go new file mode 100644 index 0000000..2b2c12e --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement.go @@ -0,0 +1,113 @@ +package spine + +import ( + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +const NodeManagementFeatureId uint = 0 + +func NodeManagementAddress(deviceAddress *model.AddressDeviceType) *model.FeatureAddressType { + return &model.FeatureAddressType{ + Entity: []model.AddressEntityType{0}, + Feature: util.Ptr(model.AddressFeatureType(NodeManagementFeatureId)), + Device: deviceAddress, + } +} + +var _ api.NodeManagementInterface = (*NodeManagement)(nil) + +type NodeManagement struct { + *FeatureLocal + entity api.EntityLocalInterface +} + +func NewNodeManagement(id uint, entity api.EntityLocalInterface) *NodeManagement { + f := &NodeManagement{ + FeatureLocal: NewFeatureLocal( + id, entity, + model.FeatureTypeTypeNodeManagement, + model.RoleTypeSpecial), + entity: entity, + } + + f.AddFunctionType(model.FunctionTypeNodeManagementDetailedDiscoveryData, true, false) + f.AddFunctionType(model.FunctionTypeNodeManagementUseCaseData, true, false) + f.AddFunctionType(model.FunctionTypeNodeManagementSubscriptionData, true, false) + f.AddFunctionType(model.FunctionTypeNodeManagementSubscriptionRequestCall, false, false) + f.AddFunctionType(model.FunctionTypeNodeManagementSubscriptionDeleteCall, false, false) + f.AddFunctionType(model.FunctionTypeNodeManagementBindingData, true, false) + f.AddFunctionType(model.FunctionTypeNodeManagementBindingRequestCall, false, false) + f.AddFunctionType(model.FunctionTypeNodeManagementBindingDeleteCall, false, false) + if f.Device().FeatureSet() != nil && *f.Device().FeatureSet() != model.NetworkManagementFeatureSetTypeSimple { + f.AddFunctionType(model.FunctionTypeNodeManagementDestinationListData, true, false) + } + + return f +} + +func (r *NodeManagement) Device() api.DeviceLocalInterface { + return r.entity.Device() +} + +func (r *NodeManagement) HandleMessage(message *api.Message) *model.ErrorType { + switch { + case message.Cmd.ResultData != nil: + if err := r.processResult(message); err != nil { + return err + } + + case message.Cmd.NodeManagementDetailedDiscoveryData != nil: + if err := r.handleMsgDetailedDiscoveryData(message, message.Cmd.NodeManagementDetailedDiscoveryData); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementSubscriptionRequestCall != nil: + if err := r.handleMsgSubscriptionRequestCall(message, message.Cmd.NodeManagementSubscriptionRequestCall); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementSubscriptionDeleteCall != nil: + if err := r.handleMsgSubscriptionDeleteCall(message, message.Cmd.NodeManagementSubscriptionDeleteCall); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementSubscriptionData != nil: + if err := r.handleMsgSubscriptionData(message); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementBindingRequestCall != nil: + if err := r.handleMsgBindingRequestCall(message, message.Cmd.NodeManagementBindingRequestCall); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementBindingDeleteCall != nil: + if err := r.handleMsgBindingDeleteCall(message, message.Cmd.NodeManagementBindingDeleteCall); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementBindingData != nil: + if err := r.handleMsgBindingData(message); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementUseCaseData != nil: + if err := r.handleMsgUseCaseData(message, message.Cmd.NodeManagementUseCaseData); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + case message.Cmd.NodeManagementDestinationListData != nil: + if err := r.handleMsgDestinationListData(message, message.Cmd.NodeManagementDestinationListData); err != nil { + return model.NewErrorType(model.ErrorNumberTypeGeneralError, err.Error()) + } + + default: + return model.NewErrorType(model.ErrorNumberTypeCommandNotSupported, fmt.Sprintf("nodemanagement.Handle: Cmd data not implemented: %s", message.Cmd.DataName())) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_binding.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_binding.go new file mode 100644 index 0000000..b5f9d45 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_binding.go @@ -0,0 +1,80 @@ +package spine + +import ( + "fmt" + + "github.com/ahmetb/go-linq/v3" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +func NewNodeManagementBindingRequestCallType(clientAddress *model.FeatureAddressType, serverAddress *model.FeatureAddressType, featureType model.FeatureTypeType) *model.NodeManagementBindingRequestCallType { + return &model.NodeManagementBindingRequestCallType{ + BindingRequest: &model.BindingManagementRequestCallType{ + ClientAddress: clientAddress, + ServerAddress: serverAddress, + ServerFeatureType: &featureType, + }, + } +} + +func NewNodeManagementBindingDeleteCallType(clientAddress *model.FeatureAddressType, serverAddress *model.FeatureAddressType) *model.NodeManagementBindingDeleteCallType { + return &model.NodeManagementBindingDeleteCallType{ + BindingDelete: &model.BindingManagementDeleteCallType{ + ClientAddress: clientAddress, + ServerAddress: serverAddress, + }, + } +} + +// route bindings request calls to the appropriate feature implementation and add the bindings to the current list +func (r *NodeManagement) processReadBindingData(message *api.Message) error { + var remoteDeviceBindings []model.BindingManagementEntryDataType + remoteDeviceBindingEntries := r.Device().BindingManager().Bindings(message.FeatureRemote.Device()) + linq.From(remoteDeviceBindingEntries).SelectT(func(s *api.BindingEntry) model.BindingManagementEntryDataType { + return model.BindingManagementEntryDataType{ + BindingId: util.Ptr(model.BindingIdType(s.Id)), + ServerAddress: s.ServerFeature.Address(), + ClientAddress: s.ClientFeature.Address(), + } + }).ToSlice(&remoteDeviceBindings) + + cmd := model.CmdType{ + NodeManagementBindingData: &model.NodeManagementBindingDataType{ + BindingEntry: remoteDeviceBindings, + }, + } + + return message.FeatureRemote.Device().Sender().Reply(message.RequestHeader, r.Address(), cmd) +} + +func (r *NodeManagement) handleMsgBindingData(message *api.Message) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + return r.processReadBindingData(message) + + default: + return fmt.Errorf("nodemanagement.handleBindingDeleteCall: NodeManagementBindingRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} + +func (r *NodeManagement) handleMsgBindingRequestCall(message *api.Message, data *model.NodeManagementBindingRequestCallType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + return r.Device().BindingManager().AddBinding(message.FeatureRemote.Device(), *data.BindingRequest) + + default: + return fmt.Errorf("nodemanagement.handleBindingRequestCall: NodeManagementBindingRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} + +func (r *NodeManagement) handleMsgBindingDeleteCall(message *api.Message, data *model.NodeManagementBindingDeleteCallType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + return r.Device().BindingManager().RemoveBinding(*data.BindingDelete, message.FeatureRemote.Device()) + + default: + return fmt.Errorf("nodemanagement.handleBindingDeleteCall: NodeManagementBindingRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_destinationlist.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_destinationlist.go new file mode 100644 index 0000000..528e5b3 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_destinationlist.go @@ -0,0 +1,48 @@ +package spine + +import ( + "errors" + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +func (r *NodeManagement) RequestDestinationListData(remoteDeviceAddress *model.AddressDeviceType, sender api.SenderInterface) (*model.MsgCounterType, *model.ErrorType) { + return nil, model.NewErrorTypeFromString("Not implemented") +} + +func (r *NodeManagement) processReadDestinationListData(featureRemote api.FeatureRemoteInterface, requestHeader *model.HeaderType) error { + data := []model.NodeManagementDestinationDataType{ + r.Device().DestinationData(), + } + // add other remote devices here + + cmd := model.CmdType{ + NodeManagementDestinationListData: &model.NodeManagementDestinationListDataType{ + NodeManagementDestinationData: data, + }, + } + + return featureRemote.Device().Sender().Reply(requestHeader, r.Address(), cmd) +} + +func (r *NodeManagement) processReplyDestinationListData(_ *api.Message, _ model.NodeManagementDestinationListDataType) error { + return errors.New("Not implemented") +} + +func (r *NodeManagement) handleMsgDestinationListData(message *api.Message, data *model.NodeManagementDestinationListDataType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeRead: + return r.processReadDestinationListData(message.FeatureRemote, message.RequestHeader) + + case model.CmdClassifierTypeReply: + return r.processReplyDestinationListData(message, *data) + + case model.CmdClassifierTypeNotify: + return r.processReplyDestinationListData(message, *data) + + default: + return fmt.Errorf("nodemanagement.handleMsgDestinationListData: NodeManagementDestinationListDataType CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_detaileddiscovery.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_detaileddiscovery.go new file mode 100644 index 0000000..ee6363c --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_detaileddiscovery.go @@ -0,0 +1,354 @@ +package spine + +import ( + "errors" + "fmt" + "slices" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +// request detailed discovery data from a remote device +func (r *NodeManagement) RequestDetailedDiscovery(remoteDeviceSki string, remoteDeviceAddress *model.AddressDeviceType, sender api.SenderInterface) (*model.MsgCounterType, *model.ErrorType) { + rfAddress := featureAddressType(NodeManagementFeatureId, EntityAddressType(remoteDeviceAddress, DeviceInformationAddressEntity)) + cmd := model.CmdType{ + NodeManagementDetailedDiscoveryData: &model.NodeManagementDetailedDiscoveryDataType{}, + } + return r.RequestRemoteDataBySenderAddress(cmd, sender, remoteDeviceSki, rfAddress, defaultMaxResponseDelay) +} + +// handle incoming detailed discovery read call +func (r *NodeManagement) processReadDetailedDiscoveryData(deviceRemote api.DeviceRemoteInterface, requestHeader *model.HeaderType) error { + if deviceRemote == nil { + return errors.New("nodemanagement.readDetailedDiscoveryData: invalid deviceRemote") + } + + var entityInformation []model.NodeManagementDetailedDiscoveryEntityInformationType + var featureInformation []model.NodeManagementDetailedDiscoveryFeatureInformationType + + for _, e := range r.Device().Entities() { + entityInformation = append(entityInformation, *e.Information()) + + for _, f := range e.Features() { + featureInformation = append(featureInformation, *f.Information()) + } + } + + cmd := model.CmdType{ + NodeManagementDetailedDiscoveryData: &model.NodeManagementDetailedDiscoveryDataType{ + SpecificationVersionList: &model.NodeManagementSpecificationVersionListType{ + SpecificationVersion: []model.SpecificationVersionDataType{model.SpecificationVersionDataType(SpecificationVersion)}, + }, + DeviceInformation: r.Device().Information(), + EntityInformation: entityInformation, + FeatureInformation: featureInformation, + }, + } + + return deviceRemote.Sender().Reply(requestHeader, r.Address(), cmd) +} + +// handle incoming detailed discovery reply data +func (r *NodeManagement) processReplyDetailedDiscoveryData(message *api.Message, data *model.NodeManagementDetailedDiscoveryDataType) error { + remoteDevice := message.DeviceRemote + + deviceDescription := data.DeviceInformation.Description + if deviceDescription == nil { + return errors.New("nodemanagement.replyDetailedDiscoveryData: invalid DeviceInformation.Description") + } + + remoteDevice.UpdateDevice(deviceDescription) + entities, err := remoteDevice.AddEntityAndFeatures(true, data) + if err != nil { + return err + } + + // publish event for remote device added + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeDeviceChange, + ChangeType: api.ElementChangeAdd, + Device: remoteDevice, + Feature: message.FeatureRemote, + Data: data, + } + Events.Publish(payload) + + // publish event for each added remote entity + for _, entity := range entities { + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeEntityChange, + ChangeType: api.ElementChangeAdd, + Device: remoteDevice, + Entity: entity, + Data: data, + } + Events.Publish(payload) + } + + return nil +} + +// check if an AddressEntity slice exists in a list of AddressEntity slices +func (r *NodeManagement) addressEntityListContainsAddressEntity(list [][]model.AddressEntityType, entityAddress []model.AddressEntityType) bool { + for _, entityList := range list { + if slices.Equal(entityList, entityAddress) { + return true + } + } + + return false +} + +// process incoming detailed discovery notify with full data +// and return the data diff +func (r *NodeManagement) provideDetailedDiscoveryDiffForFullNotify(message *api.Message, data *model.NodeManagementDetailedDiscoveryDataType) *model.NodeManagementDetailedDiscoveryDataType { + remoteDevice := message.FeatureRemote.Device() + + var existingEntities, addedEntities [][]model.AddressEntityType + + var updatedEntityInformation []model.NodeManagementDetailedDiscoveryEntityInformationType + + // search for new entities + for _, entity := range data.EntityInformation { + if entity.Description == nil || entity.Description.EntityAddress == nil { + continue + } + + // check if the entity already exists + address := entity.Description.EntityAddress + if remoteDevice.Entity(address.Entity) == nil { + // does not exists + added := model.NetworkManagementStateChangeTypeAdded + entity.Description.LastStateChange = &added + addedEntities = append(addedEntities, address.Entity) + updatedEntityInformation = append(updatedEntityInformation, entity) + } else { + // exists + existingEntities = append(existingEntities, address.Entity) + } + } + + // seach for removed entites + for _, entity := range remoteDevice.Entities() { + address := entity.Address() + if !r.addressEntityListContainsAddressEntity(existingEntities, address.Entity) { + // does not exists + removed := model.NetworkManagementStateChangeTypeRemoved + entityType := entity.EntityType() + + removedEntityDescription := model.NodeManagementDetailedDiscoveryEntityInformationType{ + Description: &model.NetworkManagementEntityDescriptionDataType{ + EntityAddress: address, + EntityType: &entityType, + LastStateChange: &removed, + }, + } + + updatedEntityInformation = append(updatedEntityInformation, removedEntityDescription) + } + } + + data.EntityInformation = updatedEntityInformation + + // update the feature information + var updatedFeatureInformation []model.NodeManagementDetailedDiscoveryFeatureInformationType + for _, feature := range data.FeatureInformation { + if feature.Description == nil || feature.Description.FeatureAddress == nil { + continue + } + + address := feature.Description.FeatureAddress + // if the entity of the feature was added, add it + // if the entity of the feature already existed, do not add it + if r.addressEntityListContainsAddressEntity(addedEntities, address.Entity) { + updatedFeatureInformation = append(updatedFeatureInformation, feature) + } + } + + data.FeatureInformation = updatedFeatureInformation + + return data +} + +// handle incoming detailed discovery notify data +func (r *NodeManagement) processNotifyDetailedDiscoveryData(message *api.Message, data *model.NodeManagementDetailedDiscoveryDataType) error { + // is this a partial request? + if message.FilterPartial == nil { + data = r.provideDetailedDiscoveryDiffForFullNotify(message, data) + } + + if len(data.EntityInformation) == 0 { + return errors.New("nodemanagement.notifyDetailedDiscoveryData: invalid EntityInformation") + } + + for _, entity := range data.EntityInformation { + if entity.Description == nil || + entity.Description.EntityAddress == nil || + entity.Description.LastStateChange == nil { + return errors.New("nodemanagement.notifyDetailedDiscoveryData: invalid EntityInformation.Description") + } + + lastStateChange := *entity.Description.LastStateChange + remoteDevice := message.FeatureRemote.Device() + + // addition example: + // {"data":[{"header":[{"protocolId":"ee1.0"}]},{"payload":{"datagram":[{"header":[{"specificationVersion":"1.1.1"},{"addressSource":[{"device":"d:_i:19667_PorscheEVSE-00016544"},{"entity":[0]},{"feature":0}]},{"addressDestination":[{"device":"EVCC_HEMS"},{"entity":[0]},{"feature":0}]},{"msgCounter":926685},{"cmdClassifier":"notify"}]},{"payload":[{"cmd":[[{"function":"nodeManagementDetailedDiscoveryData"},{"filter":[[{"cmdControl":[{"partial":[]}]}]]},{"nodeManagementDetailedDiscoveryData":[{"deviceInformation":[{"description":[{"deviceAddress":[{"device":"d:_i:19667_PorscheEVSE-00016544"}]}]}]},{"entityInformation":[[{"description":[{"entityAddress":[{"entity":[1,1]}]},{"entityType":"EV"},{"lastStateChange":"added"},{"description":"Electric Vehicle"}]}]]},{"featureInformation":[[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":1}]},{"featureType":"LoadControl"},{"role":"server"},{"supportedFunction":[[{"function":"loadControlLimitDescriptionListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"loadControlLimitListData"},{"possibleOperations":[{"read":[]},{"write":[]}]}]]},{"description":"Load Control"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":2}]},{"featureType":"ElectricalConnection"},{"role":"server"},{"supportedFunction":[[{"function":"electricalConnectionParameterDescriptionListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"electricalConnectionDescriptionListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"electricalConnectionPermittedValueSetListData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Electrical Connection"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":3}]},{"featureType":"Measurement"},{"specificUsage":["Electrical"]},{"role":"server"},{"supportedFunction":[[{"function":"measurementListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"measurementDescriptionListData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Measurements"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":5}]},{"featureType":"DeviceConfiguration"},{"role":"server"},{"supportedFunction":[[{"function":"deviceConfigurationKeyValueDescriptionListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"deviceConfigurationKeyValueListData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Device Configuration EV"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":6}]},{"featureType":"DeviceClassification"},{"role":"server"},{"supportedFunction":[[{"function":"deviceClassificationManufacturerData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Device Classification for EV"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":7}]},{"featureType":"TimeSeries"},{"role":"server"},{"supportedFunction":[[{"function":"timeSeriesConstraintsListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"timeSeriesDescriptionListData"},{"possibleOperations":[{"read":[]}]}],[{"function":"timeSeriesListData"},{"possibleOperations":[{"read":[]},{"write":[]}]}]]},{"description":"Time Series"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":8}]},{"featureType":"IncentiveTable"},{"role":"server"},{"supportedFunction":[[{"function":"incentiveTableConstraintsData"},{"possibleOperations":[{"read":[]}]}],[{"function":"incentiveTableData"},{"possibleOperations":[{"read":[]},{"write":[]}]}],[{"function":"incentiveTableDescriptionData"},{"possibleOperations":[{"read":[]},{"write":[]}]}]]},{"description":"Incentive Table"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":9}]},{"featureType":"DeviceDiagnosis"},{"role":"server"},{"supportedFunction":[[{"function":"deviceDiagnosisStateData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Device Diagnosis EV"}]}],[{"description":[{"featureAddress":[{"entity":[1,1]},{"feature":10}]},{"featureType":"Identification"},{"role":"server"},{"supportedFunction":[[{"function":"identificationListData"},{"possibleOperations":[{"read":[]}]}]]},{"description":"Identification for EV"}]}]]}]}]]}]}]}}]} + // { + // "cmd":[[ + // {"function":"nodeManagementDetailedDiscoveryData"}, + // {"filter":[[{"cmdControl":[{"partial":[]}]}]]}, + // {"nodeManagementDetailedDiscoveryData":[ + // {"deviceInformation":[{"description":[{"deviceAddress":[{"device":"d:_i:19667_PorscheEVSE-00016544"}]}]}]}, + // {"entityInformation":[[ + // {"description":[ + // {"entityAddress":[{"entity":[1,1]}]}, + // {"entityType":"EV"}, + // {"lastStateChange":"added"}, + // {"description":"Electric Vehicle"} + // ]} + // ]]}, + // {"featureInformation":[ + // [{"description":[ + // {"featureAddress":[{"entity":[1,1]},{"feature":1}]}, + // {"featureType":"LoadControl"}, + // {"role":"server"}, + // {"supportedFunction":[ + // [{"function":"loadControlLimitDescriptionListData"},{"possibleOperations":[{"read":[]}]}], + // [{"function":"loadControlLimitListData"},{"possibleOperations":[{"read":[]},{"write":[]}]}] + // ]}, + // {"description":"Load Control"} + // ]}], + // ... + + // is this addition? + if lastStateChange == model.NetworkManagementStateChangeTypeAdded { + entities, err := remoteDevice.AddEntityAndFeatures(false, data) + if err != nil { + return err + } + + // publish event for each added remote entity + for _, entity := range entities { + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeEntityChange, + ChangeType: api.ElementChangeAdd, + Device: remoteDevice, + Entity: entity, + Data: data, + } + Events.Publish(payload) + } + } + + // removal example: + // {"data":[{"header":[{"protocolId":"ee1.0"}]},{"payload":{"datagram":[{"header":[{"specificationVersion":"1.1.1"},{"addressSource":[{"device":"d:_i:19667_PorscheEVSE-00016544"},{"entity":[0]},{"feature":0}]},{"addressDestination":[{"device":"EVCC_HEMS"},{"entity":[0]},{"feature":0}]},{"msgCounter":4835},{"cmdClassifier":"notify"}]},{"payload":[{"cmd":[[{"function":"nodeManagementDetailedDiscoveryData"},{"filter":[[{"cmdControl":[{"partial":[]}]}]]},{"nodeManagementDetailedDiscoveryData":[{"deviceInformation":[{"description":[{"deviceAddress":[{"device":"d:_i:19667_PorscheEVSE-00016544"}]}]}]},{"entityInformation":[[{"description":[{"entityAddress":[{"entity":[1,1]}]},{"lastStateChange":"removed"}]}]]}]}]]}]}]}}]} + // { + // "cmd": [[ + // {"function": "nodeManagementDetailedDiscoveryData"}, + // {"filter": [[{"cmdControl": [{"partial": []}]}]]}, + // {"nodeManagementDetailedDiscoveryData": [ + // {"deviceInformation": [{"description": [{"deviceAddress": [{"device": "d:_i:19667_PorscheEVSE-00016544"}]}]}]}, + // {"entityInformation": [[ + // { + // "description": [ + // {"entityAddress": [{"entity": [1,1]}]}, + // {"lastStateChange": "removed"} + // ... + + // is this removal? + if lastStateChange == model.NetworkManagementStateChangeTypeRemoved { + for _, ei := range data.EntityInformation { + if err := remoteDevice.CheckEntityInformation(false, ei); err != nil { + return err + } + + entityAddress := ei.Description.EntityAddress.Entity + removedEntity := remoteDevice.RemoveEntityByAddress(entityAddress) + + // only continue if the entity existed + if removedEntity == nil { + continue + } + + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeEntityChange, + ChangeType: api.ElementChangeRemove, + Device: remoteDevice, + Entity: removedEntity, + Data: data, + } + Events.Publish(payload) + + // remove all subscriptions for this entity + subscriptionMgr := r.Device().SubscriptionManager() + subscriptionMgr.RemoveSubscriptionsForEntity(removedEntity) + + // remove all bindings for this entity + bindingMgr := r.Device().BindingManager() + bindingMgr.RemoveBindingsForEntity(removedEntity) + + // remove all feature caches for this entity + r.Device().CleanRemoteEntityCaches(removedEntity.Address()) + } + } + } + + return nil +} + +// func (f *NodeManagement) announceFeatureDiscovery(e Entity) error { +// entity := f.Entity() +// if entity == nil { +// return errors.New("announceFeatureDiscovery: entity not found") +// } +// device := entity.Device() +// if device == nil { +// return errors.New("announceFeatureDiscovery: device not found") +// } +// entities := device.Entities() +// if entities == nil { +// return errors.New("announceFeatureDiscovery: entities not found") +// } + +// for _, le := range entities { +// for _, lf := range le.Features() { + +// // connect client to server features +// for _, rf := range e.Features() { +// lr := lf.Role() +// rr := rf.Role() +// rolesValid := (lr == model.RoleTypeSpecial && rr == model.RoleTypeSpecial) || (lr == model.RoleTypeClient && rr == model.RoleTypeServer) +// if lf.Type() == rf.Type() && rolesValid { +// if cf, ok := lf.(ClientFeature); ok { +// if err := cf.ServerFound(rf); err != nil { +// return err +// } +// } +// } +// } +// } +// } + +// return nil +// } + +func (r *NodeManagement) handleMsgDetailedDiscoveryData(message *api.Message, data *model.NodeManagementDetailedDiscoveryDataType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeRead: + return r.processReadDetailedDiscoveryData(message.DeviceRemote, message.RequestHeader) + + case model.CmdClassifierTypeReply: + return r.processReplyDetailedDiscoveryData(message, data) + + case model.CmdClassifierTypeNotify: + return r.processNotifyDetailedDiscoveryData(message, data) + + default: + return fmt.Errorf("nodemanagement.handleDetailedDiscoveryData: NodeManagementDetailedDiscoveryData CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_subscription.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_subscription.go new file mode 100644 index 0000000..ef1ebd9 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_subscription.go @@ -0,0 +1,84 @@ +package spine + +import ( + "fmt" + + "github.com/ahmetb/go-linq/v3" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +func NewNodeManagementSubscriptionRequestCallType(clientAddress *model.FeatureAddressType, serverAddress *model.FeatureAddressType, featureType model.FeatureTypeType) *model.NodeManagementSubscriptionRequestCallType { + return &model.NodeManagementSubscriptionRequestCallType{ + SubscriptionRequest: &model.SubscriptionManagementRequestCallType{ + ClientAddress: clientAddress, + ServerAddress: serverAddress, + ServerFeatureType: &featureType, + }, + } +} + +func NewNodeManagementSubscriptionDeleteCallType(clientAddress *model.FeatureAddressType, serverAddress *model.FeatureAddressType) *model.NodeManagementSubscriptionDeleteCallType { + return &model.NodeManagementSubscriptionDeleteCallType{ + SubscriptionDelete: &model.SubscriptionManagementDeleteCallType{ + ClientAddress: clientAddress, + ServerAddress: serverAddress, + }, + } +} + +// route subscription request calls to the appropriate feature implementation and add the subscription to the current list +func (r *NodeManagement) processReadSubscriptionData(message *api.Message) error { + var remoteDeviceSubscriptions []model.SubscriptionManagementEntryDataType + remoteDeviceSubscriptionEntries := r.Device().SubscriptionManager().Subscriptions(message.FeatureRemote.Device()) + linq.From(remoteDeviceSubscriptionEntries).SelectT(func(s *api.SubscriptionEntry) model.SubscriptionManagementEntryDataType { + return model.SubscriptionManagementEntryDataType{ + SubscriptionId: util.Ptr(model.SubscriptionIdType(s.Id)), + ServerAddress: s.ServerFeature.Address(), + ClientAddress: s.ClientFeature.Address(), + } + }).ToSlice(&remoteDeviceSubscriptions) + + cmd := model.CmdType{ + NodeManagementSubscriptionData: &model.NodeManagementSubscriptionDataType{ + SubscriptionEntry: remoteDeviceSubscriptions, + }, + } + + return message.FeatureRemote.Device().Sender().Reply(message.RequestHeader, r.Address(), cmd) +} + +func (r *NodeManagement) handleMsgSubscriptionData(message *api.Message) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + return r.processReadSubscriptionData(message) + + default: + return fmt.Errorf("nodemanagement.handleSubscriptionDeleteCall: NodeManagementSubscriptionRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} + +func (r *NodeManagement) handleMsgSubscriptionRequestCall(message *api.Message, data *model.NodeManagementSubscriptionRequestCallType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + subscriptionMgr := r.Device().SubscriptionManager() + + return subscriptionMgr.AddSubscription(message.FeatureRemote.Device(), *data.SubscriptionRequest) + + default: + return fmt.Errorf("nodemanagement.handleSubscriptionRequestCall: NodeManagementSubscriptionRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} + +func (r *NodeManagement) handleMsgSubscriptionDeleteCall(message *api.Message, data *model.NodeManagementSubscriptionDeleteCallType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeCall: + subscriptionMgr := r.Device().SubscriptionManager() + + return subscriptionMgr.RemoveSubscription(*data.SubscriptionDelete, message.FeatureRemote.Device()) + + default: + return fmt.Errorf("nodemanagement.handleSubscriptionDeleteCall: NodeManagementSubscriptionRequestCall CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_usecase.go b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_usecase.go new file mode 100644 index 0000000..40b7e43 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/nodemanagement_usecase.go @@ -0,0 +1,63 @@ +package spine + +import ( + "errors" + "fmt" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +func (r *NodeManagement) RequestUseCaseData(remoteDeviceSki string, remoteDeviceAddress *model.AddressDeviceType, sender api.SenderInterface) (*model.MsgCounterType, *model.ErrorType) { + rfAddress := featureAddressType(NodeManagementFeatureId, EntityAddressType(remoteDeviceAddress, DeviceInformationAddressEntity)) + cmd := model.CmdType{ + NodeManagementUseCaseData: &model.NodeManagementUseCaseDataType{}, + } + return r.RequestRemoteDataBySenderAddress(cmd, sender, remoteDeviceSki, rfAddress, defaultMaxResponseDelay) +} + +func (r *NodeManagement) processReadUseCaseData(featureRemote api.FeatureRemoteInterface, requestHeader *model.HeaderType) error { + fd := r.functionData(model.FunctionTypeNodeManagementUseCaseData) + if fd == nil { + return errors.New("function data not found") + } + cmd := fd.ReplyCmdType(false) + + return featureRemote.Device().Sender().Reply(requestHeader, r.Address(), cmd) +} + +func (r *NodeManagement) processReplyUseCaseData(message *api.Message, data *model.NodeManagementUseCaseDataType) error { + _, _ = message.FeatureRemote.UpdateData(true, model.FunctionTypeNodeManagementUseCaseData, data, nil, nil) + + // the data was updated, so send an event, other event handlers may watch out for this as well + payload := api.EventPayload{ + Ski: message.FeatureRemote.Device().Ski(), + EventType: api.EventTypeDataChange, + ChangeType: api.ElementChangeUpdate, + Feature: message.FeatureRemote, + Device: message.FeatureRemote.Device(), + Entity: message.FeatureRemote.Entity(), + CmdClassifier: util.Ptr(message.CmdClassifier), + Data: data, + } + Events.Publish(payload) + + return nil +} + +func (r *NodeManagement) handleMsgUseCaseData(message *api.Message, data *model.NodeManagementUseCaseDataType) error { + switch message.CmdClassifier { + case model.CmdClassifierTypeRead: + return r.processReadUseCaseData(message.FeatureRemote, message.RequestHeader) + + case model.CmdClassifierTypeReply: + return r.processReplyUseCaseData(message, data) + + case model.CmdClassifierTypeNotify: + return r.processReplyUseCaseData(message, data) + + default: + return fmt.Errorf("nodemanagement.handleUseCaseData: NodeManagementUseCaseData CmdClassifierType not implemented: %s", message.CmdClassifier) + } +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/operations.go b/src/eebus-bridge/third_party/spine-go/spine/operations.go new file mode 100644 index 0000000..b0e0be6 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/operations.go @@ -0,0 +1,70 @@ +package spine + +import ( + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +type Operations struct { + read, write bool + readPartial, writePartial bool +} + +var _ api.OperationsInterface = (*Operations)(nil) + +func NewOperations(read, readPartial, write, writePartial bool) *Operations { + return &Operations{ + read: read, + readPartial: readPartial, + write: write, + writePartial: writePartial, + } +} +func (r *Operations) Read() bool { + return r.read +} + +func (r *Operations) ReadPartial() bool { + return r.readPartial +} + +func (r *Operations) Write() bool { + return r.write +} + +func (r *Operations) WritePartial() bool { + return r.writePartial +} + +func (r *Operations) String() string { + switch { + case r.read && !r.write: + return "RO" + case r.read && r.write: + return "RW" + default: + return "--" + } +} + +func (r *Operations) Information() *model.PossibleOperationsType { + res := new(model.PossibleOperationsType) + if r.read { + res.Read = &model.PossibleOperationsReadType{} + if r.readPartial { + res.Read = &model.PossibleOperationsReadType{ + Partial: &model.ElementTagType{}, + } + } + } + if r.write { + res.Write = &model.PossibleOperationsWriteType{} + if r.writePartial { + res.Write = &model.PossibleOperationsWriteType{ + Partial: &model.ElementTagType{}, + } + } + } + + return res +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/send.go b/src/eebus-bridge/third_party/spine-go/spine/send.go new file mode 100644 index 0000000..3c77f3a --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/send.go @@ -0,0 +1,370 @@ +package spine + +import ( + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "sort" + "sync" + "sync/atomic" + + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/logging" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/golanguzb70/lrucache" +) + +type reqMsgCacheData map[model.MsgCounterType]string + +type Sender struct { + msgNum uint64 // 64bit values need to be defined on top of the struct to make atomic commands work on 32bit systems + + // we cache the last 100 notify messages, so we can find the matching item for result errors being returned + datagramNotifyCache *lrucache.LRUCache[model.MsgCounterType, model.DatagramType] + + writeHandler shipapi.ShipConnectionDataWriterInterface + + reqMsgCache reqMsgCacheData // cache for unanswered request messages, so we can filter duplicates and not send them + + muxNotifyCache sync.RWMutex + muxReadCache sync.RWMutex +} + +var _ api.SenderInterface = (*Sender)(nil) + +func NewSender(writeI shipapi.ShipConnectionDataWriterInterface) api.SenderInterface { + cache := lrucache.New[model.MsgCounterType, model.DatagramType](100, 0) + return &Sender{ + datagramNotifyCache: &cache, + writeHandler: writeI, + reqMsgCache: make(reqMsgCacheData), + } +} + +// return the datagram for a given msgCounter (only availbe for Notify messasges!), error if not found +func (c *Sender) DatagramForMsgCounter(msgCounter model.MsgCounterType) (model.DatagramType, error) { + c.muxNotifyCache.RLock() + defer c.muxNotifyCache.RUnlock() + + if datagram, ok := c.datagramNotifyCache.Get(msgCounter); ok { + return datagram, nil + } + + return model.DatagramType{}, errors.New("msgCounter not found") +} + +func (c *Sender) sendSpineMessage(datagram model.DatagramType) error { + // pack into datagram + data := model.Datagram{ + Datagram: datagram, + } + + // marshal + msg, err := json.Marshal(data) + if err != nil { + return err + } + + if c.writeHandler == nil { + return errors.New("outgoing interface implementation not set") + } + + if msg == nil { + return errors.New("message is nil") + } + + logging.Log().Debug(datagram.PrintMessageOverview(true, "", "")) + + // write to channel + c.writeHandler.WriteShipMessageWithPayload(msg) + + return nil +} + +// Caching of outgoing and unanswered requests, so we can filter duplicates +func (c *Sender) hashForMessage(destinationAddress *model.FeatureAddressType, cmd []model.CmdType) string { + cmdString, err := json.Marshal(cmd) + if err != nil { + return "" + } + + sig := fmt.Sprintf("%s-%s", destinationAddress.String(), cmdString) + shaBytes := sha256.Sum256([]byte(sig)) + return hex.EncodeToString(shaBytes[:]) +} + +func (c *Sender) msgCounterForHashFromCache(hash string) *model.MsgCounterType { + c.muxReadCache.RLock() + defer c.muxReadCache.RUnlock() + + for msgCounter, h := range c.reqMsgCache { + if h == hash { + return &msgCounter + } + } + + return nil +} + +func (c *Sender) hasMsgCounterInCache(msgCounter model.MsgCounterType) bool { + c.muxReadCache.RLock() + defer c.muxReadCache.RUnlock() + + _, ok := c.reqMsgCache[msgCounter] + + return ok +} + +func (c *Sender) addMsgCounterHashToCache(msgCounter model.MsgCounterType, hash string) { + c.muxReadCache.Lock() + defer c.muxReadCache.Unlock() + + // cleanup cache, keep only the last 20 messages + if len(c.reqMsgCache) > 20 { + keys := make([]uint64, 0, len(c.reqMsgCache)) + for k := range c.reqMsgCache { + keys = append(keys, uint64(k)) + } + sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) + + // oldest key is the one with the lowest msgCounterValue + oldestKey := keys[0] + delete(c.reqMsgCache, model.MsgCounterType(oldestKey)) + } + + c.reqMsgCache[msgCounter] = hash +} + +// we need to remove the msgCounter from the cache, if we have it cached +func (c *Sender) ProcessResponseForMsgCounterReference(msgCounterRef *model.MsgCounterType) { + if msgCounterRef != nil && + c.hasMsgCounterInCache(*msgCounterRef) { + c.muxReadCache.Lock() + defer c.muxReadCache.Unlock() + + delete(c.reqMsgCache, *msgCounterRef) + } +} + +// Sends request +func (c *Sender) Request(cmdClassifier model.CmdClassifierType, senderAddress, destinationAddress *model.FeatureAddressType, ackRequest bool, cmd []model.CmdType) (*model.MsgCounterType, error) { + // check if there is an unanswered subscribe message for this destination and cmd and return that msgCounter + hash := c.hashForMessage(destinationAddress, cmd) + if len(hash) > 0 { + if msgCounterCache := c.msgCounterForHashFromCache(hash); msgCounterCache != nil { + return msgCounterCache, nil + } + } + + msgCounter := c.getMsgCounter() + + datagram := model.DatagramType{ + Header: model.HeaderType{ + SpecificationVersion: &SpecificationVersion, + AddressSource: senderAddress, + AddressDestination: destinationAddress, + MsgCounter: msgCounter, + CmdClassifier: &cmdClassifier, + }, + Payload: model.PayloadType{ + Cmd: cmd, + }, + } + + if ackRequest { + datagram.Header.AckRequest = &ackRequest + } + + err := c.sendSpineMessage(datagram) + if err == nil { + if len(hash) > 0 { + c.addMsgCounterHashToCache(*msgCounter, hash) + } + } + + return msgCounter, err +} + +func (c *Sender) ResultSuccess(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType) error { + return c.result(requestHeader, senderAddress, nil) +} + +func (c *Sender) ResultError(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, err *model.ErrorType) error { + return c.result(requestHeader, senderAddress, err) +} + +// sends a result for a request +func (c *Sender) result(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, err *model.ErrorType) error { + cmdClassifier := model.CmdClassifierTypeResult + + addressSource := *requestHeader.AddressDestination + addressSource.Device = senderAddress.Device + + var resultData model.ResultDataType + if err != nil { + resultData = model.ResultDataType{ + ErrorNumber: &err.ErrorNumber, + Description: err.Description, + } + } else { + resultData = model.ResultDataType{ + ErrorNumber: util.Ptr(model.ErrorNumberTypeNoError), + } + } + + cmd := model.CmdType{ + ResultData: &resultData, + } + + datagram := model.DatagramType{ + Header: model.HeaderType{ + SpecificationVersion: &SpecificationVersion, + AddressSource: &addressSource, + AddressDestination: requestHeader.AddressSource, + MsgCounter: c.getMsgCounter(), + MsgCounterReference: requestHeader.MsgCounter, + CmdClassifier: &cmdClassifier, + }, + Payload: model.PayloadType{ + Cmd: []model.CmdType{cmd}, + }, + } + + return c.sendSpineMessage(datagram) +} + +// Reply sends reply to original sender +func (c *Sender) Reply(requestHeader *model.HeaderType, senderAddress *model.FeatureAddressType, cmd model.CmdType) error { + cmdClassifier := model.CmdClassifierTypeReply + + addressSource := *requestHeader.AddressDestination + addressSource.Device = senderAddress.Device + + datagram := model.DatagramType{ + Header: model.HeaderType{ + SpecificationVersion: &SpecificationVersion, + AddressSource: &addressSource, + AddressDestination: requestHeader.AddressSource, + MsgCounter: c.getMsgCounter(), + MsgCounterReference: requestHeader.MsgCounter, + CmdClassifier: &cmdClassifier, + }, + Payload: model.PayloadType{ + Cmd: []model.CmdType{cmd}, + }, + } + + return c.sendSpineMessage(datagram) +} + +// Notify sends notification to destination +func (c *Sender) Notify(senderAddress, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) { + msgCounter := c.getMsgCounter() + + cmdClassifier := model.CmdClassifierTypeNotify + + datagram := model.DatagramType{ + Header: model.HeaderType{ + SpecificationVersion: &SpecificationVersion, + AddressSource: senderAddress, + AddressDestination: destinationAddress, + MsgCounter: msgCounter, + CmdClassifier: &cmdClassifier, + }, + Payload: model.PayloadType{ + Cmd: []model.CmdType{cmd}, + }, + } + + c.muxNotifyCache.Lock() + c.datagramNotifyCache.Put(*msgCounter, datagram) + c.muxNotifyCache.Unlock() + + return msgCounter, c.sendSpineMessage(datagram) +} + +// Write sends notification to destination +func (c *Sender) Write(senderAddress, destinationAddress *model.FeatureAddressType, cmd model.CmdType) (*model.MsgCounterType, error) { + msgCounter := c.getMsgCounter() + + cmdClassifier := model.CmdClassifierTypeWrite + ackRequest := true + + datagram := model.DatagramType{ + Header: model.HeaderType{ + SpecificationVersion: &SpecificationVersion, + AddressSource: senderAddress, + AddressDestination: destinationAddress, + MsgCounter: msgCounter, + CmdClassifier: &cmdClassifier, + AckRequest: &ackRequest, + }, + Payload: model.PayloadType{ + Cmd: []model.CmdType{cmd}, + }, + } + + return msgCounter, c.sendSpineMessage(datagram) +} + +// Send a subscription request to a remote server feature +func (c *Sender) Subscribe(senderAddress, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) { + cmd := model.CmdType{ + NodeManagementSubscriptionRequestCall: NewNodeManagementSubscriptionRequestCallType(senderAddress, destinationAddress, serverFeatureType), + } + + // we always send it to the remote NodeManagement feature, which always is at entity:[0],feature:0 + localAddress := NodeManagementAddress(senderAddress.Device) + remoteAddress := NodeManagementAddress(destinationAddress.Device) + + return c.Request(model.CmdClassifierTypeCall, localAddress, remoteAddress, true, []model.CmdType{cmd}) +} + +// Send a subscription deletion request to a remote server feature +func (c *Sender) Unsubscribe(senderAddress, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) { + cmd := model.CmdType{ + NodeManagementSubscriptionDeleteCall: NewNodeManagementSubscriptionDeleteCallType(senderAddress, destinationAddress), + } + + // we always send it to the remote NodeManagement feature, which always is at entity:[0],feature:0 + localAddress := NodeManagementAddress(senderAddress.Device) + remoteAddress := NodeManagementAddress(destinationAddress.Device) + + return c.Request(model.CmdClassifierTypeCall, localAddress, remoteAddress, true, []model.CmdType{cmd}) +} + +// Send a binding request to a remote server feature +func (c *Sender) Bind(senderAddress, destinationAddress *model.FeatureAddressType, serverFeatureType model.FeatureTypeType) (*model.MsgCounterType, error) { + cmd := model.CmdType{ + NodeManagementBindingRequestCall: NewNodeManagementBindingRequestCallType(senderAddress, destinationAddress, serverFeatureType), + } + + // we always send it to the remote NodeManagement feature, which always is at entity:[0],feature:0 + localAddress := NodeManagementAddress(senderAddress.Device) + remoteAddress := NodeManagementAddress(destinationAddress.Device) + + return c.Request(model.CmdClassifierTypeCall, localAddress, remoteAddress, true, []model.CmdType{cmd}) +} + +// Send a binding request to a remote server feature +func (c *Sender) Unbind(senderAddress, destinationAddress *model.FeatureAddressType) (*model.MsgCounterType, error) { + cmd := model.CmdType{ + NodeManagementBindingDeleteCall: NewNodeManagementBindingDeleteCallType(senderAddress, destinationAddress), + } + + // we always send it to the remote NodeManagement feature, which always is at entity:[0],feature:0 + localAddress := NodeManagementAddress(senderAddress.Device) + remoteAddress := NodeManagementAddress(destinationAddress.Device) + + return c.Request(model.CmdClassifierTypeCall, localAddress, remoteAddress, true, []model.CmdType{cmd}) +} + +func (c *Sender) getMsgCounter() *model.MsgCounterType { + // TODO: persistence + i := model.MsgCounterType(atomic.AddUint64(&c.msgNum, 1)) + return &i +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/subscription_manager.go b/src/eebus-bridge/third_party/spine-go/spine/subscription_manager.go new file mode 100644 index 0000000..9b7951d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/subscription_manager.go @@ -0,0 +1,232 @@ +package spine + +import ( + "errors" + "fmt" + "reflect" + "sync" + "sync/atomic" + + "github.com/ahmetb/go-linq/v3" + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" +) + +type SubscriptionManager struct { + localDevice api.DeviceLocalInterface + + subscriptionNum uint64 + subscriptionEntries []*api.SubscriptionEntry + + mux sync.Mutex + // TODO: add persistence +} + +func NewSubscriptionManager(localDevice api.DeviceLocalInterface) *SubscriptionManager { + c := &SubscriptionManager{ + subscriptionNum: 0, + localDevice: localDevice, + } + + return c +} + +// is sent from the client (remote device) to the server (local device) +func (c *SubscriptionManager) AddSubscription(remoteDevice api.DeviceRemoteInterface, data model.SubscriptionManagementRequestCallType) error { + serverFeature := c.localDevice.FeatureByAddress(data.ServerAddress) + if serverFeature == nil { + return fmt.Errorf("server feature '%s' in local device '%s' not found", data.ServerAddress, *c.localDevice.Address()) + } + if err := c.checkRoleAndType(serverFeature, model.RoleTypeServer, *data.ServerFeatureType); err != nil { + return err + } + + clientFeature := remoteDevice.FeatureByAddress(data.ClientAddress) + if clientFeature == nil { + return fmt.Errorf("client feature '%s' in remote device '%s' not found", data.ClientAddress, *remoteDevice.Address()) + } + if err := c.checkRoleAndType(clientFeature, model.RoleTypeClient, *data.ServerFeatureType); err != nil { + return err + } + + subscriptionEntry := &api.SubscriptionEntry{ + Id: c.subscriptionId(), + ServerFeature: serverFeature, + ClientFeature: clientFeature, + } + + c.mux.Lock() + defer c.mux.Unlock() + + for _, item := range c.subscriptionEntries { + if reflect.DeepEqual(item.ServerFeature, serverFeature) && reflect.DeepEqual(item.ClientFeature, clientFeature) { + return fmt.Errorf("requested subscription is already present") + } + } + + c.subscriptionEntries = append(c.subscriptionEntries, subscriptionEntry) + + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeSubscriptionChange, + ChangeType: api.ElementChangeAdd, + Data: data, + Device: remoteDevice, + Entity: clientFeature.Entity(), + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + + return nil +} + +// Remove a specific subscription that is provided by a delete message from a remote device +func (c *SubscriptionManager) RemoveSubscription(data model.SubscriptionManagementDeleteCallType, remoteDevice api.DeviceRemoteInterface) error { + var newSubscriptionEntries []*api.SubscriptionEntry + + // according to the spec 7.4.4 + // a. The absence of "subscriptionDelete. clientAddress. device" SHALL be treated as if it was + // present and set to the sender's "device" address part. + // b. The absence of "subscriptionDelete. serverAddress. device" SHALL be treated as if it was + // present and set to the recipient's "device" address part. + + var clientAddress model.FeatureAddressType + util.DeepCopy(data.ClientAddress, &clientAddress) + if data.ClientAddress.Device == nil { + clientAddress.Device = remoteDevice.Address() + } + + clientFeature := remoteDevice.FeatureByAddress(data.ClientAddress) + if clientFeature == nil { + return fmt.Errorf("client feature '%s' in remote device '%s' not found", data.ClientAddress, *remoteDevice.Address()) + } + + serverFeature := c.localDevice.FeatureByAddress(data.ServerAddress) + if serverFeature == nil { + return fmt.Errorf("server feature '%s' in local device '%s' not found", data.ServerAddress, *c.localDevice.Address()) + } + + c.mux.Lock() + defer c.mux.Unlock() + + for _, item := range c.subscriptionEntries { + itemAddress := item.ClientFeature.Address() + + if !reflect.DeepEqual(itemAddress.Device, clientAddress.Device) || + !reflect.DeepEqual(itemAddress.Entity, clientAddress.Entity) || + !reflect.DeepEqual(itemAddress.Feature, clientAddress.Feature) || + !reflect.DeepEqual(item.ServerFeature, serverFeature) { + newSubscriptionEntries = append(newSubscriptionEntries, item) + } + } + + if len(newSubscriptionEntries) == len(c.subscriptionEntries) { + return errors.New("could not find requested SubscriptionId to be removed") + } + + c.subscriptionEntries = newSubscriptionEntries + + payload := api.EventPayload{ + Ski: remoteDevice.Ski(), + EventType: api.EventTypeSubscriptionChange, + ChangeType: api.ElementChangeRemove, + Data: data, + Device: remoteDevice, + Entity: clientFeature.Entity(), + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + + return nil +} + +// Remove all existing subscriptions for a given remote device +func (c *SubscriptionManager) RemoveSubscriptionsForDevice(remoteDevice api.DeviceRemoteInterface) { + if remoteDevice == nil { + return + } + + for _, entity := range remoteDevice.Entities() { + c.RemoveSubscriptionsForEntity(entity) + } +} + +// Remove all existing subscriptions for a given remote device entity +func (c *SubscriptionManager) RemoveSubscriptionsForEntity(remoteEntity api.EntityRemoteInterface) { + if remoteEntity == nil { + return + } + + c.mux.Lock() + defer c.mux.Unlock() + + var newSubscriptionEntries []*api.SubscriptionEntry + for _, item := range c.subscriptionEntries { + if !reflect.DeepEqual(item.ClientFeature.Address().Device, remoteEntity.Address().Device) || + !reflect.DeepEqual(item.ClientFeature.Address().Entity, remoteEntity.Address().Entity) { + newSubscriptionEntries = append(newSubscriptionEntries, item) + continue + } + + serverFeature := c.localDevice.FeatureByAddress(item.ServerFeature.Address()) + clientFeature := remoteEntity.FeatureOfAddress(item.ClientFeature.Address().Feature) + payload := api.EventPayload{ + Ski: remoteEntity.Device().Ski(), + EventType: api.EventTypeSubscriptionChange, + ChangeType: api.ElementChangeRemove, + Device: remoteEntity.Device(), + Entity: remoteEntity, + Feature: clientFeature, + LocalFeature: serverFeature, + } + Events.Publish(payload) + } + + c.subscriptionEntries = newSubscriptionEntries +} + +func (c *SubscriptionManager) Subscriptions(remoteDevice api.DeviceRemoteInterface) []*api.SubscriptionEntry { + var result []*api.SubscriptionEntry + + c.mux.Lock() + defer c.mux.Unlock() + + linq.From(c.subscriptionEntries).WhereT(func(s *api.SubscriptionEntry) bool { + return s.ClientFeature.Device().Ski() == remoteDevice.Ski() + }).ToSlice(&result) + + return result +} + +func (c *SubscriptionManager) SubscriptionsOnFeature(featureAddress model.FeatureAddressType) []*api.SubscriptionEntry { + var result []*api.SubscriptionEntry + + c.mux.Lock() + defer c.mux.Unlock() + + linq.From(c.subscriptionEntries).WhereT(func(s *api.SubscriptionEntry) bool { + return reflect.DeepEqual(*s.ServerFeature.Address(), featureAddress) + }).ToSlice(&result) + + return result +} + +func (c *SubscriptionManager) subscriptionId() uint64 { + i := atomic.AddUint64(&c.subscriptionNum, 1) + return i +} + +func (c *SubscriptionManager) checkRoleAndType(feature api.FeatureInterface, role model.RoleType, featureType model.FeatureTypeType) error { + if feature.Role() != model.RoleTypeSpecial && feature.Role() != role { + return fmt.Errorf("found feature %s is not matching required role %s", feature.Type(), role) + } + + if feature.Type() != featureType && feature.Type() != model.FeatureTypeTypeGeneric { + return fmt.Errorf("found feature %s is not matching required type %s", feature.Type(), featureType) + } + + return nil +} diff --git a/src/eebus-bridge/third_party/spine-go/spine/util.go b/src/eebus-bridge/third_party/spine-go/spine/util.go new file mode 100644 index 0000000..1fab90b --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/spine/util.go @@ -0,0 +1,42 @@ +package spine + +import ( + "errors" + "reflect" + + "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" +) + +var notFoundError = errors.New("data not found") + +func dataCopyOfType[T any](rdata any) (T, error) { + x := any(*new(T)) + + if rdata == nil { + return x.(T), notFoundError + } + + v := reflect.ValueOf(rdata) + kind := v.Kind() + if kind == reflect.Ptr && v.IsNil() { + return x.(T), notFoundError + } + + data, ok := rdata.(T) + if !ok { + return x.(T), notFoundError + } + + return data, nil +} + +// Note: the type has to be a pointer! +func LocalFeatureDataCopyOfType[T any](feature api.FeatureLocalInterface, function model.FunctionType) (T, error) { + return dataCopyOfType[T](feature.DataCopy(function)) +} + +// Note: the type has to be a pointer! +func RemoteFeatureDataCopyOfType[T any](remote api.FeatureRemoteInterface, function model.FunctionType) (T, error) { + return dataCopyOfType[T](remote.DataCopy(function)) +} diff --git a/src/eebus-bridge/third_party/spine-go/util/helper.go b/src/eebus-bridge/third_party/spine-go/util/helper.go new file mode 100644 index 0000000..2e0eee0 --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/util/helper.go @@ -0,0 +1,28 @@ +package util + +import ( + "encoding/json" + "reflect" +) + +// quick way to a struct into another +func DeepCopy[A any](source, dest A) { + byt, _ := json.Marshal(source) + _ = json.Unmarshal(byt, dest) +} + +// checck if a value is nil for any type +func IsNil(data any) bool { + if data == nil { + return true + } + switch reflect.TypeOf(data).Kind() { + case reflect.Ptr, + reflect.Map, + reflect.Array, + reflect.Chan, + reflect.Slice: + return reflect.ValueOf(data).IsNil() + } + return false +} diff --git a/src/eebus-bridge/third_party/spine-go/util/ptr.go b/src/eebus-bridge/third_party/spine-go/util/ptr.go new file mode 100644 index 0000000..e82ce5d --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/util/ptr.go @@ -0,0 +1,5 @@ +package util + +func Ptr[T any](v T) *T { + return &v +} diff --git a/src/eebus-bridge/third_party/spine-go/util/type.go b/src/eebus-bridge/third_party/spine-go/util/type.go new file mode 100644 index 0000000..44478bf --- /dev/null +++ b/src/eebus-bridge/third_party/spine-go/util/type.go @@ -0,0 +1,13 @@ +package util + +import "reflect" + +func Type[T any]() reflect.Type { + return reflect.TypeOf((*T)(nil)).Elem() +} + +// checks if type T implements interface I +func Implements[T any, I any]() bool { + _, supported := any((*T)(nil)).(I) + return supported +}