Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement function to calcualte charge cost #204

Merged
merged 3 commits into from
Mar 11, 2020

Conversation

CodeBear801
Copy link

@CodeBear801 CodeBear801 commented Mar 7, 2020

issue: #143

  • Calculate charging cost for given status and target status.
    • ChargeStrategy creates several charge solutions via function CreateChargingStrategies, which means charge battery to a certain certain energy level.
    • When user reaches a charge station, he has a inital arrival energy and target status, he could use EvaluateCost to calculate cost needed, such as time, money, etc.
  • Add NullChargeStrategy for unit tests
  • Fix the issue of hard coded chargeTime
  • Remove test cases for chargeEnergy, which will be added later in the future pull

Tasklist

  • modify code
  • add tests
  • review

Requirements / Relations

@CodeBear801
Copy link
Author

CodeBear801 commented Mar 8, 2020

To be done later:

  • Change interface name from ChargingStrategyCreator to ChargingStrategy
  • Change interface func from CreateChargingStrategies to CreateChargingSolutions

For context please go to: #203

@CodeBear801 CodeBear801 added the Prototype Proof of concept label Mar 8, 2020

var epsilon float64 = 0.00000001

func floatEquals(a, b float64) bool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to find/implement a floatEquals package. There're too many places want to use it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and location

Copy link
Author

@CodeBear801 CodeBear801 Mar 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • How about adding common package in integration/oasis? For floatEquals, we add it into util.go. Search this from other repository, one sample is go-gl/mathgl/mathgl32/util
  • For Location, add to commontypes under common package.
  • Later if they are needed by external package, could be moved to integration

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only oasis need it, but also other packages. What if create a integration/util package for the floatEquals, and a integration/map package for the Location? The Location here is for general purpose, if some special usage(e.g., Coordinate in osrm) just create their owns.

Copy link
Author

@CodeBear801 CodeBear801 Mar 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will put it to integration. Will make floatEqual to there and change the calling in this pull.

For Location and make other places calling floatEqual will make it in future pull. Recorded here: #211

// 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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetState or targetStatus, which one would be better?

Copy link
Author

@CodeBear801 CodeBear801 Mar 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep them consistency is most important, keep the name targetState here.

@CodeBear801 CodeBear801 mentioned this pull request Mar 9, 2020
9 tasks
@CodeBear801 CodeBear801 merged commit 7831889 into master Mar 11, 2020
@CodeBear801 CodeBear801 deleted the feature/oasis-integration2-patch1 branch March 11, 2020 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prototype Proof of concept
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants