2023-01-07 16:41:15 +11:00
|
|
|
/*
|
|
|
|
Copyright 2023 Josh Deprez
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-01-10 14:43:46 +11:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2022-08-23 15:19:43 +10:00
|
|
|
const (
|
|
|
|
//dailySupplyCharge = 105.750 / 100 // 1 July 2020 - 30 June 2021
|
|
|
|
//dailySupplyCharge = 98.234 / 100 // 1 July 2021 - 30 June 2022
|
2023-01-07 16:41:15 +11:00
|
|
|
//dailySupplyCharge = 98.234 / 100 // 1 July 2021 - 30 June 2022
|
|
|
|
dailySupplyCharge = 1.099030 // 1 July 2022 - 30 June 2023
|
|
|
|
|
|
|
|
//solarFeedInTariff = fixedTariff(8.471 / 100) // 1 July 2020 - 30 June 2021
|
|
|
|
//solarFeedInTariff = fixedTariff(6.501 / 100) // 1 July 2021 - 30 June 2022
|
|
|
|
solarFeedInTariff = fixedTariff(0.088830) // 1 July 2022 - 30 June 2023
|
2021-01-10 14:43:46 +11:00
|
|
|
)
|
|
|
|
|
2022-08-23 15:19:43 +10:00
|
|
|
var tariff93 = &onOffPeakTariff{
|
|
|
|
// 1 July 2020 - 30 June 2021:
|
|
|
|
//onPeak: 32.137 / 100,
|
|
|
|
//offPeak: 14.963 / 100,
|
|
|
|
// 1 July 2021 - 30 June 2022:
|
|
|
|
//onPeak: 29.852 / 100,
|
|
|
|
//offPeak: 13.9 / 100,
|
|
|
|
// 1 July 2022 - 30 June 2023:
|
2023-01-07 16:41:15 +11:00
|
|
|
onPeak: 0.333990,
|
2022-08-23 15:19:43 +10:00
|
|
|
offPeak: 0.155510,
|
|
|
|
isPeak: (&weekdayHours{
|
|
|
|
zone: time.FixedZone("UTC+10", +10*60*60),
|
|
|
|
on: [24]bool{
|
|
|
|
7: true,
|
|
|
|
8: true,
|
|
|
|
9: true,
|
|
|
|
16: true,
|
|
|
|
17: true,
|
|
|
|
18: true,
|
|
|
|
19: true,
|
|
|
|
20: true,
|
|
|
|
},
|
|
|
|
}).isPeak,
|
|
|
|
}
|
|
|
|
|
2023-01-07 16:41:15 +11:00
|
|
|
// type tariff interface {
|
|
|
|
// pricePerKWh(time.Time) float64
|
|
|
|
// }
|
2021-01-10 14:43:46 +11:00
|
|
|
|
|
|
|
type fixedTariff float64
|
|
|
|
|
|
|
|
func (f fixedTariff) pricePerKWh(time.Time) float64 { return float64(f) }
|
|
|
|
|
|
|
|
type onOffPeakTariff struct {
|
|
|
|
onPeak, offPeak float64
|
|
|
|
isPeak func(time.Time) bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *onOffPeakTariff) pricePerKWh(t time.Time) float64 {
|
|
|
|
if o.isPeak(t) {
|
|
|
|
return o.onPeak
|
|
|
|
}
|
|
|
|
return o.offPeak
|
|
|
|
}
|
|
|
|
|
|
|
|
type weekdayHours struct {
|
|
|
|
zone *time.Location
|
|
|
|
on [24]bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *weekdayHours) isPeak(t time.Time) bool {
|
|
|
|
t = t.In(w.zone)
|
|
|
|
switch t.Weekday() {
|
|
|
|
case time.Saturday, time.Sunday:
|
|
|
|
return false
|
|
|
|
default:
|
|
|
|
return w.on[t.Hour()]
|
|
|
|
}
|
|
|
|
}
|