Skip to content

Commit

Permalink
fix: change name from ChargingStatus to State
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBear801 committed Mar 9, 2020
1 parent 1af4fbf commit bf58f07
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions integration/oasis/chargingstrategy/charge_strategy_creator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package chargingstrategy

// ChargingStatus contains charging related information
type ChargingStatus struct {
// State contains charging related information
type State struct {
ChargingEnergy float64
}

Expand All @@ -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
}
12 changes: 6 additions & 6 deletions integration/oasis/chargingstrategy/chargingstrategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand All @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions integration/oasis/chargingstrategy/null_charge_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
2 changes: 1 addition & 1 deletion integration/oasis/stationgraph/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bf58f07

Please sign in to comment.