(lp loadpoint.API, minLen int, firstSlotDuration time.Duration, grid api.Rates)
| 413 | } |
| 414 | |
| 415 | func (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 |
no test coverage detected