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

all pattern matching ops on ChargingPointType now cover all cases #1941

Merged
merged 2 commits into from
Jul 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Copy link
Collaborator Author

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.

Copy link
Collaborator

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.

case Level1 => 1.5
case Level2 => 6.7
case DCFast => 50
case UltraFast => 250
case NoCharger => 0
case _ => throw new IllegalArgumentException("invalid argument")
}
}

Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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")
}
}

Expand Down