MCPcopy Create free account
hub / github.com/evcc-io/evcc / loadpointRequest

Method loadpointRequest

core/site_optimizer.go:415–493  ·  view source on GitHub ↗
(lp loadpoint.API, minLen int, firstSlotDuration time.Duration, grid api.Rates)

Source from the content-addressed store, hash-verified

413}
414
415func (site *Site) loadpointRequest(lp loadpoint.API, minLen int, firstSlotDuration time.Duration, grid api.Rates) (optimizer.BatteryConfig, batteryDetail) {
416 bat := optimizer.BatteryConfig{
417 ChargeFromGrid: true,
418 CMin: float32(lp.EffectiveMinPower()),
419 CMax: float32(lp.EffectiveMaxPower()),
420 DMax: 0,
421 SMin: 0,
422 // PA: pa,
423 }
424
425 if profile := loadpointProfile(lp, minLen); profile != nil {
426 bat.PDemand = prorate(profile, firstSlotDuration)
427 }
428
429 detail := batteryDetail{
430 Type: batteryTypeLoadpoint,
431 Title: lp.GetTitle(),
432 }
433
434 // vehicle
435 v := lp.GetVehicle()
436
437 maxSoc := v.Capacity() * 1e3 // Wh
438 if v := lp.EffectiveLimitSoc(); v > 0 {
439 maxSoc *= float64(v) / 100
440 } else if v := lp.GetLimitEnergy(); v > 0 {
441 maxSoc = v * 1e3
442 }
443
444 bat.SInitial = float32(v.Capacity() * lp.GetSoc() * 10) // Wh
445 bat.SMax = max(bat.SInitial, float32(maxSoc)) // prevent infeasible if current soc above maximum
446
447 detail.Type = batteryTypeVehicle
448 detail.Capacity = v.Capacity()
449
450 if vt := v.GetTitle(); vt != "" {
451 if detail.Title != "" {
452 detail.Title += " – "
453 }
454 detail.Title += vt
455 }
456
457 // find vehicle name/id
458 for _, dev := range config.Vehicles().Devices() {
459 if dev.Instance() == v {
460 detail.Name = dev.Config().Name
461 }
462 }
463
464 var demand []float32
465
466 switch lp.GetMode() {
467 case api.ModeOff:
468 // disable charging
469 bat.CMax = 0
470
471 case api.ModeNow:
472 // forced max charging

Callers 1

optimizerUpdateMethod · 0.95

Calls 15

applyPlanGoalMethod · 0.95
VehiclesFunction · 0.92
loadpointProfileFunction · 0.85
prorateFunction · 0.85
continuousDemandFunction · 0.85
applySmartCostLimitFunction · 0.85
EffectiveMinPowerMethod · 0.65
EffectiveMaxPowerMethod · 0.65
GetTitleMethod · 0.65
GetVehicleMethod · 0.65
CapacityMethod · 0.65
EffectiveLimitSocMethod · 0.65

Tested by

no test coverage detected