From bf58f079bd98204f7aa90ba4da0397070d37b2b9 Mon Sep 17 00:00:00 2001 From: CoderBear801 Date: Mon, 9 Mar 2020 10:13:39 -0700 Subject: [PATCH] fix: change name from ChargingStatus to State --- .../chargingstrategy/charge_strategy_creator.go | 8 ++++---- .../oasis/chargingstrategy/chargingstrategy.go | 12 ++++++------ .../oasis/chargingstrategy/null_charge_strategy.go | 6 +++--- integration/oasis/stationgraph/node.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/integration/oasis/chargingstrategy/charge_strategy_creator.go b/integration/oasis/chargingstrategy/charge_strategy_creator.go index 056f94edb2d..befde4bad48 100644 --- a/integration/oasis/chargingstrategy/charge_strategy_creator.go +++ b/integration/oasis/chargingstrategy/charge_strategy_creator.go @@ -1,7 +1,7 @@ package chargingstrategy -// ChargingStatus contains charging related information -type ChargingStatus struct { +// State contains charging related information +type State struct { ChargingEnergy float64 } @@ -15,8 +15,8 @@ type ChargingCost struct { type ChargingStrategyCreator interface { // CreateChargingStrategies creates charge strategies which could be used by other algorithm - CreateChargingStrategies() []ChargingStatus + CreateChargingStrategies() []State // EvaluateCost accepts current status and target status and returns cost needed - EvaluateCost(arrivalEnergy float64, targetState ChargingStatus) ChargingCost + EvaluateCost(arrivalEnergy float64, targetState State) ChargingCost } diff --git a/integration/oasis/chargingstrategy/chargingstrategy.go b/integration/oasis/chargingstrategy/chargingstrategy.go index 93a30b7d22e..36915441052 100644 --- a/integration/oasis/chargingstrategy/chargingstrategy.go +++ b/integration/oasis/chargingstrategy/chargingstrategy.go @@ -18,15 +18,15 @@ func NewFakeChargingStrategyCreator(maxEnergyLevel float64) *fakeChargingStrateg // @todo: // - Influence of returning candidate with no charge time and additional energy // CreateChargingStrategies returns different charging strategy -func (f *fakeChargingStrategyCreator) CreateChargingStrategies() []ChargingStatus { - return []ChargingStatus{ - ChargingStatus{ +func (f *fakeChargingStrategyCreator) CreateChargingStrategies() []State { + return []State{ + State{ ChargingEnergy: f.maxEnergyLevel * 0.6, }, - ChargingStatus{ + State{ ChargingEnergy: f.maxEnergyLevel * 0.8, }, - ChargingStatus{ + State{ ChargingEnergy: f.maxEnergyLevel, }, } @@ -37,7 +37,7 @@ func (f *fakeChargingStrategyCreator) CreateChargingStrategies() []ChargingStatu // 1 hour charge to 60% of max energy // 2 hour charge to 80%, means from 60% ~ 80% need 1 hour // 4 hour charge to 100%, means from 80% ~ 100% need 2 hours -func (f *fakeChargingStrategyCreator) EvaluateCost(arrivalEnergy float64, targetState ChargingStatus) ChargingCost { +func (f *fakeChargingStrategyCreator) EvaluateCost(arrivalEnergy float64, targetState State) ChargingCost { sixtyPercentOfMaxEnergy := f.maxEnergyLevel * 0.6 eightyPercentOfMaxEnergy := f.maxEnergyLevel * 0.8 noNeedCharge := ChargingCost{ diff --git a/integration/oasis/chargingstrategy/null_charge_strategy.go b/integration/oasis/chargingstrategy/null_charge_strategy.go index 316f1e5c102..8dc2dded527 100644 --- a/integration/oasis/chargingstrategy/null_charge_strategy.go +++ b/integration/oasis/chargingstrategy/null_charge_strategy.go @@ -8,10 +8,10 @@ func NewNullChargeStrategy() *nullChargeStrategy { return &nullChargeStrategy{} } -func (f *nullChargeStrategy) CreateChargingStrategies() []ChargingStatus { - return []ChargingStatus{} +func (f *nullChargeStrategy) CreateChargingStrategies() []State { + return []State{} } -func (f *nullChargeStrategy) EvaluateCost(arrivalEnergy float64, targetState ChargingStatus) ChargingCost { +func (f *nullChargeStrategy) EvaluateCost(arrivalEnergy float64, targetState State) ChargingCost { return ChargingCost{} } diff --git a/integration/oasis/stationgraph/node.go b/integration/oasis/stationgraph/node.go index 51bf11586ff..a0e7f6bc3ab 100644 --- a/integration/oasis/stationgraph/node.go +++ b/integration/oasis/stationgraph/node.go @@ -51,7 +51,7 @@ func (n *node) calcChargeTime(prev *node, distance float64, strategy chargingstr if arrivalEnergy < 0 { glog.Fatalf("Before updateNode should check isLocationReachable() prev.arrivalEnergy=%#v distance=%#v", prev.arrivalEnergy, distance) } - return strategy.EvaluateCost(arrivalEnergy, chargingstrategy.ChargingStatus{ChargingEnergy: n.chargeEnergy}).Duration + return strategy.EvaluateCost(arrivalEnergy, chargingstrategy.State{ChargingEnergy: n.chargeEnergy}).Duration } func (n *node) updateChargingTime(chargingTime float64) {