-
Notifications
You must be signed in to change notification settings - Fork 57
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
all pattern matching ops on ChargingPointType now cover all cases #1941
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,30 +56,30 @@ object ChargingPointType { | |
|
||
} | ||
|
||
private[ChargingPointType] val CustomChargingPointRegex: Regex = "(\\w+)\\((\\d+),(\\w+)\\)".r | ||
private[ChargingPointType] val CustomChargingPointRegex: Regex = "(\\w+)\\((\\d+),(\\w+)\\)".r.unanchored | ||
|
||
// matches either the standard ones or a custom one | ||
// these were breaking some tests with a ChargingPoint parsing error caused by Event handlers | ||
def apply(s: String): Option[ChargingPointType] = { | ||
s.trim.toLowerCase match { | ||
// case "householdsocket" => Some(HouseholdSocket) | ||
// case "bluehouseholdsocket" => Some(BlueHouseholdSocket) | ||
// case "cee16asocket" => Some(Cee16ASocket) | ||
// case "cee32asocket" => Some(Cee32ASocket) | ||
// case "cee63asocket" => Some(Cee63ASocket) | ||
// case "chargingstationtype1" => Some(ChargingStationType1) | ||
// case "chargingstationtype2" => Some(ChargingStationType2) | ||
// case "chargingstationccscombotype1" => Some(ChargingStationCcsComboType1) | ||
// case "chargingstationccscombotype2" => Some(ChargingStationCcsComboType2) | ||
// case "teslasupercharger" => Some(TeslaSuperCharger) | ||
case "level1" => Some(Level1) | ||
case "level2" => Some(Level2) | ||
case "dcfast" => Some(DCFast) | ||
case "ultrafast" => Some(UltraFast) | ||
case "nocharger" => Some(NoCharger) | ||
case "householdsocket" => Some(HouseholdSocket) | ||
case "bluehouseholdsocket" => Some(BlueHouseholdSocket) | ||
case "cee16asocket" => Some(Cee16ASocket) | ||
case "cee32asocket" => Some(Cee32ASocket) | ||
case "cee63asocket" => Some(Cee63ASocket) | ||
case "chargingstationtype1" => Some(ChargingStationType1) | ||
case "chargingstationtype2" => Some(ChargingStationType2) | ||
case "chargingstationccscombotype1" => Some(ChargingStationCcsComboType1) | ||
case "chargingstationccscombotype2" => Some(ChargingStationCcsComboType2) | ||
case "teslasupercharger" => Some(TeslaSuperCharger) | ||
case "level1" => Some(Level1) | ||
case "level2" => Some(Level2) | ||
case "dcfast" => Some(DCFast) | ||
case "ultrafast" => Some(UltraFast) | ||
case "nocharger" => Some(NoCharger) | ||
// case "" => None | ||
// case CustomChargingPointRegex(id, installedCapacity, currentType) => | ||
// Some(CustomChargingPoint(id, installedCapacity, currentType)) | ||
case CustomChargingPointRegex(id, installedCapacity, currentType) => | ||
Some(CustomChargingPoint(id, installedCapacity, currentType)) | ||
case _ => None | ||
// throw new IllegalArgumentException("invalid argument for ChargingPointType: " + s.trim) | ||
} | ||
|
@@ -99,7 +99,13 @@ object ChargingPointType { | |
case ChargingStationCcsComboType2 => 50 | ||
case TeslaSuperCharger => 135 | ||
case CustomChargingPoint(_, v, _) => v | ||
case _ => throw new IllegalArgumentException("invalid argument") | ||
// legacy charging points (values taken from 2018 BEAM code) | ||
case Level1 => 1.5 | ||
case Level2 => 6.7 | ||
case DCFast => 50 | ||
case UltraFast => 250 | ||
case NoCharger => 0 | ||
case _ => throw new IllegalArgumentException("invalid argument") | ||
} | ||
} | ||
|
||
|
@@ -116,7 +122,13 @@ object ChargingPointType { | |
case ChargingStationCcsComboType2 => DC | ||
case TeslaSuperCharger => DC | ||
case CustomChargingPoint(_, _, c) => c | ||
case _ => throw new IllegalArgumentException("invalid argument") | ||
// legacy charging points | ||
case Level2 => AC | ||
case Level1 => AC | ||
case DCFast => DC | ||
case UltraFast => DC | ||
case NoCharger => AC | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't make sense as a call on NoCharger should throw an IllegalArgumentException but we can keep this anyway for now to make it work. |
||
case _ => throw new IllegalArgumentException("invalid argument") | ||
} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanneshiry plz double-check the values i put in place for the legacy types, if you don't mind - both AC/DC and the KwH. i just grabbed them from the old implementation. i think it should work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "worse" thing about the old definitions is, that Level1 / Level2 Charging rate are not fixed defined but more of a range of installed charging capacity. Anyway the values you picked are in range or close to the definitions of Level1/2 charging. So we can keep them for now until the personal ev branch will be merged in.