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

Feature/add protocol state to interface #136

Conversation

lukaslombriserdesignwerk
Copy link
Contributor

Added the following features:

  • stop charger when TCP connection has stopped
  • improved precharge handling
  • fix for optional "units" for DIN
  • set protocol state in interface

await self.comm_session.evse_controller.set_precharge(
precharge_req.ev_target_voltage, precharge_req.ev_target_current
)
self.expect_pre_charge_req = False
Copy link
Contributor

Choose a reason for hiding this comment

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

since we are setting it at every time, I dont think we need the flag anymore and can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my opinion it is still used for the function "self.check_msg_dinspec(....)".
But i moved the line (where the flag is set) to the end of the State "PreCharge". Like in other states.

await self.comm_session.evse_controller.set_precharge(
precharge_req.ev_target_voltage, precharge_req.ev_target_current
)
self.precharge_req_was_reveived = True
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as for the DIN

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same for DIN

Comment on lines 231 to 244
DIN_REAL_WORLD_MESSAGES = [
TestMessage(
message_name="ChargeParameterDiscoveryReq",
json_str='{"V2G_Message": {"Header": {"SessionID": "C427C77F5FAA1DD5"},'
' "Body": {"ChargeParameterDiscoveryReq": '
'{"EVRequestedEnergyTransferType": "DC_extended", '
'"DC_EVChargeParameter": {"DC_EVStatus": {"EVReady": false, '
'"EVErrorCode": "NO_ERROR", "EVRESSSOC": 43}, '
'"EVMaximumCurrentLimit": {"Multiplier": -1, "Value": 3500}, '
'"EVMaximumVoltageLimit": {"Multiplier": -1, "Value": 4690}, '
'"EVEnergyRequest": {"Multiplier": 0, "Value": 500}}}}}}',
description="EV: VW ID3; Date: 06.09.2022; Element 'Unit' in "
"PhysicalValuetype in DIN is optional. "
"In ISO it is mandatory.",
),
]


Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think it is necessary to create a separate test for this case. We can simply add the payload to the DIN_TEST_MESSSAGES. The description on the the TestMessage is enough to understand the purpose

@@ -328,6 +328,139 @@ class PVStartValue(PhysicalValue):
unit: Literal[UnitSymbol.WATT] = Field(..., alias="Unit")


class PVEVEnergyCapacityDin(PVEVEnergyCapacity):
Copy link
Contributor

Choose a reason for hiding this comment

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

for clarity reasons, add comment on top stating that due to the fact the unit field is Option in the DIN, we have to override the ISO 15118 datatypes

Comment on lines 332 to 518
super(PVEVMaxVoltageLimit)
unit: Literal[UnitSymbol.VOLTAGE] = Field(None, alias="Unit")


class PVEVSECurrentRegulationToleranceDin(PVEVSECurrentRegulationTolerance):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSECurrentRegulationTolerance)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVSEEnergyToBeDeliveredDin(PVEVSEEnergyToBeDelivered):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEEnergyToBeDelivered)
unit: Literal[UnitSymbol.WATT_HOURS] = Field(None, alias="Unit")


class PVEVSEMaxCurrentLimitDin(PVEVSEMaxCurrentLimit):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEMaxCurrentLimit)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVSEMaxPowerLimitDin(PVEVSEMaxPowerLimit):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEMaxPowerLimit)
unit: Literal[UnitSymbol.WATT] = Field(None, alias="Unit")


class PVEVSEMaxVoltageLimitDin(PVEVSEMaxVoltageLimit):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEMaxVoltageLimit)
unit: Literal[UnitSymbol.VOLTAGE] = Field(None, alias="Unit")


class PVEVSEMinCurrentLimitDin(PVEVSEMinCurrentLimit):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEMinCurrentLimit)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVSEMinVoltageLimitDin(PVEVSEMinVoltageLimit):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEMinVoltageLimit)
unit: Literal[UnitSymbol.VOLTAGE] = Field(None, alias="Unit")


class PVEVSEPeakCurrentRippleDin(PVEVSEPeakCurrentRipple):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEPeakCurrentRipple)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVSEPresentCurrentDin(PVEVSEPresentCurrent):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEPresentCurrent)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVSEPresentVoltageDin(PVEVSEPresentVoltage):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVSEPresentVoltage)
unit: Literal[UnitSymbol.VOLTAGE] = Field(None, alias="Unit")


class PVEVTargetCurrentDin(PVEVTargetCurrent):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVTargetCurrent)
unit: Literal[UnitSymbol.AMPERE] = Field(None, alias="Unit")


class PVEVTargetVoltageDin(PVEVTargetVoltage):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVEVTargetVoltage)
unit: Literal[UnitSymbol.VOLTAGE] = Field(None, alias="Unit")


class PVRemainingTimeToFullSOCDin(PVRemainingTimeToFullSOC):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVRemainingTimeToFullSOC)
unit: Literal[UnitSymbol.SECONDS] = Field(None, alias="Unit")


class PVRemainingTimeToBulkSOCDin(PVRemainingTimeToBulkSOC):
"""See section 9.5.2.4 in DIN SPEC 70121"""

super(PVRemainingTimeToBulkSOC)
unit: Literal[UnitSymbol.SECONDS] = Field(None, alias="Unit")
Copy link
Contributor

Choose a reason for hiding this comment

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

you dont need the super. Overriding the unit will do the trick. Check:

In [1]: class Base:
   ...:     unit: int = 3
   ...:

In [2]: class Child(Base):
   ...:     unit: str = "lala"
   ...:

In [3]: test_base = Base()

In [4]: test_child = Child()

In [5]:

In [5]: test_base.unit
Out[5]: 3

In [6]: test_child.unit
Out[6]: 'lala'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right.

@lukaslombriserdesignwerk
Copy link
Contributor Author

Hi André,

thanks for the review!
I have made the imprevements.

@@ -1950,7 +1950,7 @@ async def process_message(
msg = self.check_msg_v2(
message,
[PreChargeReq, PowerDeliveryReq],
not self.precharge_req_was_reveived,
not self.expecting_precharge_req,
Copy link
Contributor

Choose a reason for hiding this comment

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

this now is confusing... I guess you meant to set the expecting_precharge_req to True, so that here we actually are checking for the presence of it and not for the not self.expecting_precharge_req

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you are right.
I fixed it und pushed it.

@lukaslombriserdesignwerk lukaslombriserdesignwerk force-pushed the feature/add_protocol_state_to_interface branch from 84cf7f1 to 9a17cc9 Compare September 22, 2022 15:14
@lukaslombriserdesignwerk lukaslombriserdesignwerk force-pushed the feature/add_protocol_state_to_interface branch from 1cff7f7 to 9a6c734 Compare September 26, 2022 12:14
@lukaslombriserdesignwerk
Copy link
Contributor Author

HI André

would be great if you could do the review/merge before the next branch will be merged. Otherwise I have to rebase again :).

best regards.
Lukas

@tropxy tropxy merged commit 5b81286 into EcoG-io:master Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants