EEBus: abort run loop and limit assertion on context cancellation (#32494)
This commit is contained in:
parent
4a878838e7
commit
fed3fb731c
8 changed files with 54 additions and 12 deletions
|
|
@ -23,6 +23,7 @@ import (
|
|||
// Uses MPC (Monitoring & Power Consumption) for all other cases (default)
|
||||
// Additionally supports LPC (Limitation of Power Consumption) and LPP (Limitation of Power Production)
|
||||
type EEBus struct {
|
||||
ctx context.Context // device lifetime, aborts limit retries
|
||||
log *util.Logger
|
||||
|
||||
connector *eebus.Connector
|
||||
|
|
@ -114,6 +115,7 @@ func NewEEBus(ctx context.Context, ski, ip string, usage *templates.Usage) (api.
|
|||
}
|
||||
|
||||
c := &EEBus{
|
||||
ctx: ctx,
|
||||
log: util.NewLogger("eebus-" + useCase),
|
||||
ma: ma,
|
||||
eg: inst.EnergyGuard(),
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func (c *EEBus) egLpcUseCaseSupportUpdate(entity spineapi.EntityRemoteInterface)
|
|||
c.egLpcEntity = entity
|
||||
|
||||
// [LPC-913]: state the limit to the newly available CS
|
||||
go eebus.AssertLimit(c.log, func() error { return c.Dim(c.lastDimmed()) })
|
||||
go eebus.AssertLimit(c.ctx, c.log, func() error { return c.Dim(c.lastDimmed()) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,6 +98,6 @@ func (c *EEBus) egLppUseCaseSupportUpdate(entity spineapi.EntityRemoteInterface)
|
|||
c.egLppEntity = entity
|
||||
|
||||
// [LPP-913]: state the limit to the newly available CS
|
||||
go eebus.AssertLimit(c.log, func() error { return c.SetCurtailPercent(c.lastCurtailPercent()) })
|
||||
go eebus.AssertLimit(c.ctx, c.log, func() error { return c.SetCurtailPercent(c.lastCurtailPercent()) })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ func newEGMeter(t *testing.T) (*EEBus, *egmocks.EgLPCInterface, *egmocks.EgLPPIn
|
|||
entity := spinemocks.NewEntityRemoteInterface(t)
|
||||
|
||||
c := &EEBus{
|
||||
ctx: t.Context(),
|
||||
log: util.NewLogger("eebus-eg-test"),
|
||||
eg: &eebus.EnergyGuard{EgLPCInterface: lpc, EgLPPInterface: lpp},
|
||||
egLpcEntity: entity,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue