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

Fixes to get the simulation to work with the current HEAD #4

Merged
merged 11 commits into from
Jun 13, 2024

Conversation

shankari
Copy link

This fixes the third issue in
US-JOET/base-camp#153 (comment)
which was first reported at
US-JOET/base-camp#153 (comment)
and the fix was outlined in
US-JOET/base-camp#153 (comment)

Signed-off-by: Shankari <[email protected]>
This is no longer required given 3372b2b
And it can potentially break given EVerest#44 (comment)

given that our simulator has a single port, let's restore to simplicity

Signed-off-by: Shankari <[email protected]>
This fixes the second issue in
US-JOET/base-camp#153 (comment)
by making the nodered consistent with
EVerest/everest-core@993a60c

- we pass in `ac` or `dc` as the energy type
- we add in the payment method, which we will plumb through in the next commit
- we change the mqtt toptic, also consistent with the commit above

Signed-off-by: Shankari <[email protected]>
Changes needed:
- change the `iso_start_v2g_session` to take two parameters
- convert the first to the payment method and use the second for the energy type
- add a new argument to the module method for `start_charging`
- pass the payment method through properly

The changes are applied by:
- checking in another patch
- applying the patch after changing into the build directory

Testing done:
- AC EIM works

```
2024-06-12 05:40:37.622543 [INFO] car_simulator_1  :: {
  cmd: 'iso_start_v2g_session',
  args: [ 'externalpayment', 'ac' ],
  exec: [Function (anonymous)]
}

2024-06-12 05:40:37.624913 [DEBG] iso15118_car    Everest::Everest::provide_cmd(std::string, std::string, JsonCommand)::<lambda(Everest::json)> :: Incoming iso15118_car:PyEvJosev->ev:ISO15118_ev->start_charging(EnergyTransferMode) for <handler>

2024-06-12 05:40:42.726368 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Message to encode (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message": {"Header": {"SessionID": "6954F76C3DCCE6FD"}, "Body": {"PaymentServiceSelectionReq": {"SelectedPaymentOption": "ExternalPayment", "SelectedServiceList": {"SelectedService": [{"ServiceID": 1}]}}}}}

2024-06-12 05:40:46.308633 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"6954F76C3DCCE6FD"},"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK","EVSEProcessing":"Finished","SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1,"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0,"duration":86400},"PMax":{"Multiplier":0,"Unit":"W","Value":22080}}]}}]},"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0,"EVSENotification":"None","RCD":false},"EVSENominalVoltage":{"Multiplier":-1,"Unit":"V","Value":2300},"EVSEMaxCurrent":{"Multiplier":-1,"Unit":"A","Value":320}}}}}}

2024-06-12 05:40:46.310640 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Message to encode (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message": {"Header": {"SessionID": "6954F76C3DCCE6FD"}, "Body": {"PowerDeliveryReq": {"ChargeProgress": "Start", "SAScheduleTupleID": 1, "ChargingProfile": {"ProfileEntry": [{"ChargingProfileEntryStart": 0, "ChargingProfileEntryMaxPower": {"Value": 22080, "Multiplier": 0, "Unit": "W"}}, {"ChargingProfileEntryStart": 86400, "ChargingProfileEntryMaxPower": {"Value": 0, "Multiplier": 0, "Unit": "W"}}]}}}}}
```

- AC contract cert works

```
  cmd: 'iso_start_v2g_session',
  args: [ 'contract', 'ac' ],
  exec: [Function (anonymous)]
}

2024-06-12 05:48:00.517485 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Message to encode (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message": {"Header": {"SessionID": "18B5F6A7DB7EEE7F"}, "Body": {"PaymentServiceSelectionReq": {"SelectedPaymentOption": "Contract", "SelectedServiceList": {"SelectedService": [{"ServiceID": 1}]}}}}}

2024-06-12 05:48:04.212986 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"18B5F6A7DB7EEE7F"},"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK","EVSEProcessing":"Finished","SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1,"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0,"duration":86400},"PMax":{"Multiplier":0,"Unit":"W","Value":22080}}]}}]},"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0,"EVSENotification":"None","RCD":false},"EVSENominalVoltage":{"Multiplier":-1,"Unit":"V","Value":2300},"EVSEMaxCurrent":{"Multiplier":-1,"Unit":"A","Value":320}}}}}}

2024-06-12 05:48:04.215246 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Message to encode (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message": {"Header": {"SessionID": "18B5F6A7DB7EEE7F"}, "Body": {"PowerDeliveryReq": {"ChargeProgress": "Start", "SAScheduleTupleID": 1, "ChargingProfile": {"ProfileEntry": [{"ChargingProfileEntryStart": 0, "ChargingProfileEntryMaxPower": {"Value": 22080, "Multiplier": 0, "Unit": "W"}}, {"ChargingProfileEntryStart": 86400, "ChargingProfileEntryMaxPower": {"Value": 0, "Multiplier": 0, "Unit": "W"}}]}}}}}
```

Signed-off-by: Shankari <[email protected]>
@shankari
Copy link
Author

After creating the PR, re-ran the command again and then charged again.
Got the same results as 11a1a90

Without this change, while trying to set a charging profile, the validation
fails because no units are configured.

Sqlite commands used:

```
sqlite> select * from variable;
170|RateUnit||17|170|1
sqlite> select * from variable_attribute where variable_id=170;
170|170|0|1|0|0|
sqlite> update variable_attribute set value="A" where variable_id=170;
sqlite> select * from variable_attribute where variable_id=170;
170|170|0|1|0|0|A
```
Since we need to recompile after making everest module and libocpp changes, and
make (or more accurately `ld`) fails if there is insufficient memory.
- Adding additional logs indicating when the `set_external_limits` function was
  called
- Bumped up the log level in a couple of places so that they would show up
- 💩Hack to fix the indicies of the evse and the mapping to the evse manager
    - the list simply iterates over an array of charging schedules and sets the limits for each one
    - however, our list of valid EVSE IDs starts with 1
    - so the first entry/zeroth EVSE ID should be skipped
    - and the evse manager list indices are off by one from the EVSE IDs, so we
      should subtract one before looking it up
- Add additional logging (lots, and all with warning or above so it shows up).
  This should be cleaned up once the feature is complete and before the final submission.
- Call `handle_set_charging_profile_req` from `handleMessage` so that when the
  CSMS makes the call, it actually triggers the EVerest implementation
- Parse the message properly in the way EVerest expects it in the `messages/SetChargingProfile.cpp` class
    - Add logging to verify this
    - Import a bunch of header files to enable the logging
- leave in commented code in which we tried to handle the parsing mismatch
  while receiving the message, but failed due to const issues. This should be
  removed once the compatibility between the CSMS and the station is sorted out.
These were required to get the charge profiles to work.
The changes require recompile, so they are applied first, and then we recompile
Recompiling overrides code in `libexec`, so we apply those changes later
@shankari
Copy link
Author

Testing done:

  • Modified demo-iso15118-2-ac-plus-ocpp.sh to copy instead of clone
  • bash demo-iso15118-2-ac-plus-ocpp.sh -r .../everest-demo -3
  • Selected AC ISO 15118; worked
  • Selected AC ISO 15118 PnC; worked

However, the detailed ISO logging isn't showing up. fixing that...

So that the recompile does not overwrite it
This fixes
#4 (comment)
@shankari
Copy link
Author

Fixed. Now tried to call setChargingProfile, which failed with the following error. it looks like @louisg1337 fixed MaEVe 😄
Fixing this in the patch for now and will ask @louisg1337 to test by removing the patch tomorrow.

2024-06-13 03:38:11.473557 [ERRO] ocpp:OCPP201    void ocpp::v201::from_json(const json&, SetChargingProfileRequest&) :: In the message class, parsing from JSON: {"ChargingProfile":{"chargingProfileKind":"Absolute","chargingProfilePurpose":"TxDefaultProfile","chargingSchedule":[{"chargingRateUnit":"A","chargingSchedulePeriod":[{"limit":20,"numberPhases":1,"startPeriod":0}],"duration":86400,"id":0,"minChargingRate":0,"startSchedule":"2024-06-12T00:00:00.000Z"}],"id":1,"recurrencyKind":"Daily","stackLevel":1},"EvseId":0}
2024-06-13 03:38:11.473955 [ERRO] ocpp:OCPP201    void ocpp::v201::ChargePoint::message_callback(const std::string&) :: JSON exception during handling of message: [json.exception.out_of_range.403] key 'ChargingProfileType' not found

@shankari
Copy link
Author

Everything seems to work now. @louisg1337 can you pull from this branch, run and verify that you get the same results? I can then merge this to the charin-e2e-demo branch so that AFS can build on it. Then finally, we can start removing the patches one by one by incorporating the changes into the actual code 😄

Testing done:

Plugged in the car and got a charge delivery of 22kW with a 230V and 32 A
[DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"67634FE7DDFF935F"}
"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK"
"EVSEProcessing":"Finished"
"SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1
"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0
"duration":86400}
"PMax":{"Multiplier":0
"Unit":"W"
"Value":22080}}]}}]}
"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0
"EVSENotification":"None"
"RCD":false}
"EVSENominalVoltage":{"Multiplier":-1
"Unit":"V"
"Value":2300}
"EVSEMaxCurrent":{"Multiplier":-1
"Unit":"A"
"Value":320}}}}}}
Unplugged the car, and set a profile that was valid starting `2024-06-13T00:00:00.000Z` and a limit of 20 A (the file is attached)
2024-06-13 03:52:58.408417 [ERRO] ocpp:OCPP201    void ocpp::v201::ChargePoint::handle_set_charging_profile_req(ocpp::Call<ocpp::v201::SetChargingProfileRequest>) :: Received SetChargingProfile: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "TxDefaultProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 20.0,
                        "numberPhases": 1,
                        "startPeriod": 0
                    }
                ],
                "duration": 86400,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-06-13T00:00:00.000Z"
            }
        ],
        "id": 1,
        "recurrencyKind": "Daily",
        "stackLevel": 1
    },
    "evseId": 1
}
with messageId: 2b9f7b12-ac9b-46b8-88a3-72327a66928b
2024-06-13 03:52:58.409520 [WARN] ocpp:OCPP201    module::OCPP201::ready()::<lambda()> :: Received a new Charging Schedules from the CSMS or another actor.
2024-06-13 03:52:58.409682 [INFO] ocpp:OCPP201     :: ProfileId #1 Kind: Absolute
2024-06-13 03:52:58.409723 [INFO] ocpp:OCPP201     :: #1 find_period_at> 2024-06-13T00:00:00.000Z
2024-06-13 03:52:58.409765 [INFO] ocpp:OCPP201     ::    find_period_at>        start_time> 2024-06-13T03:52:58.409Z
2024-06-13 03:52:58.409794 [INFO] ocpp:OCPP201     ::    find_period_at> period_start_time> 2024-06-13T00:00:00.000Z
2024-06-13 03:52:58.409821 [INFO] ocpp:OCPP201     ::    find_period_at>   period_end_time> 2024-06-14T00:00:00.000Z
2024-06-13 03:52:58.409929 [INFO] ocpp:OCPP201     :: PeriodDateTimePair>  period: {
    "limit": 20.0,
    "numberPhases": 1,
    "startPeriod": 0
} end_time: 2024-06-14T00:00:00.000Z
2024-06-13 03:52:58.409998 [INFO] ocpp:OCPP201     :: period.has_value() limit = 4600
2024-06-13 03:52:58.410040 [INFO] ocpp:OCPP201     :: period.has_value() stackLevel = 4600
2024-06-13 03:52:58.453739 [ERRO] ocpp:OCPP201    void ocpp::v201::ChargePoint::handle_set_charging_profile_req(ocpp::Call<ocpp::v201::SetChargingProfileRequest>) :: Received profile validity: Validsetting response to {
    "status": "Accepted"
}
Plugged in the car again, and got max power of 4600 W, with 230V and 6.6A
[DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"6F6CE6DFFD1F6169"}
"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK"
"EVSEProcessing":"Finished"
"SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1
"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0
"duration":86400}
"PMax":{"Multiplier":0
"Unit":"W"
"Value":4600}}]}}]}
"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0
"EVSENotification":"None"
"RCD":false}
"EVSENominalVoltage":{"Multiplier":-1
"Unit":"V"
"Value":2300}
"EVSEMaxCurrent":{"Multiplier":-1
"Unit":"A"
"Value":66}}}}}}

TXProfile_1.json

After Louis fixed it in his MaEVe repo
This fixes #4 (comment)
@louisg1337
Copy link

louisg1337 commented Jun 13, 2024

To do my testing, I clone the US-JOET/everest-demo repo and checked out charin-e2e-demo-last-min-hacks. I then deleted all previous docker containers I had and ran bash demo-iso15118-2-ac-plus-ocpp.sh -3.

Plugged in the car and got a charge delivery of 22kW with a 230V and 32 A

Got the same result when plugging in the car normally.

2024-06-13 15:03:56.582203 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"9FAA4FDD3FEFBD3F"},
"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK",
"EVSEProcessing":"Finished",
"SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1,
"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0,
"duration":86400},
"PMax":{"Multiplier":0,
"Unit":"W",
"Value":22080}}]}}]},
"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0,
"EVSENotification":"None",
"RCD":false},
"EVSENominalVoltage":{"Multiplier":-1,
"Unit":"V",
"Value":2300},
"EVSEMaxCurrent":{"Multiplier":-1,
"Unit":"A",
"Value":320}}}}}}

Unplugged the car, and set a profile that was valid starting 2024-06-13T00:00:00.000Z and a limit of 20 A (the file is attached)

I unfortunately was not able to reproduce the setChargingProfile working properly. I ran the setChargingProfile script we have with the JSON file, but there weren't any EVerest logs that indicated we received a new profile. I did check the OCPP logs, however, and I found the setChargingProfile requests there, but with the typical "Unknown" response we have always gotten.

Screenshot 2024-06-13 at 11 21 17 AM

I'm not sure if I am doing something wrong, or if I don't have an updated version of EVerest with the new chargingProfile implementation. I'll keep on messing around with it to see what I am doing wrong that i am not getting the same results.

Plugged in the car again, and got max power of 4600 W, with 230V and 6.6A

Unable to reproduce because of the above.

EDIT: I think I realize why. When applying the patches I kept on getting "xxx.patch file not found", which is because I wasn't running the script with my local version of everest-demo. I'll run the tests again, this time using my local version, and record the results.

@louisg1337
Copy link

Updated Testing

As I said in the edit section above, I was running the script without pointing it to my local directory, so I wasn't getting any of the patches. Now that I have the patches, things are working as expected.

Plugged in the car and got a charge delivery of 22kW with a 230V and 32 A

Same as the comment above.

Unplugged the car, and set a profile that was valid starting 2024-06-13T00:00:00.000Z and a limit of 20 A (the file is attached)

Got the same response after setChargingProfile API call
2024-06-13 16:28:32.924613 [ERRO] ocpp:OCPP201    void ocpp::v201::ChargePoint::handle_set_charging_profile_req(ocpp::Call<ocpp::v201::SetChargingProfileRequest>) :: Received SetChargingProfile: {
    "chargingProfile": {
        "chargingProfileKind": "Absolute",
        "chargingProfilePurpose": "TxDefaultProfile",
        "chargingSchedule": [
            {
                "chargingRateUnit": "A",
                "chargingSchedulePeriod": [
                    {
                        "limit": 20.0,
                        "numberPhases": 1,
                        "startPeriod": 0
                    }
                ],
                "duration": 86400,
                "id": 0,
                "minChargingRate": 0.0,
                "startSchedule": "2024-06-13T00:00:00.000Z"
            }
        ],
        "id": 1,
        "recurrencyKind": "Daily",
        "stackLevel": 1
    },
    "evseId": 1
}
with messageId: 197d7fa0-8aba-4135-bb0f-9fcbe3c2d280
2024-06-13 16:28:32.926104 [WARN] ocpp:OCPP201    module::OCPP201::ready()::<lambda()> :: Received a new Charging Schedules from the CSMS or another actor.
2024-06-13 16:28:32.926363 [INFO] ocpp:OCPP201     :: ProfileId #1 Kind: Absolute
2024-06-13 16:28:32.926639 [INFO] ocpp:OCPP201     :: #1 find_period_at> 2024-06-13T00:00:00.000Z
2024-06-13 16:28:32.926950 [INFO] ocpp:OCPP201     ::    find_period_at>        start_time> 2024-06-13T16:28:32.926Z
2024-06-13 16:28:32.927014 [INFO] ocpp:OCPP201     ::    find_period_at> period_start_time> 2024-06-13T00:00:00.000Z
2024-06-13 16:28:32.927057 [INFO] ocpp:OCPP201     ::    find_period_at>   period_end_time> 2024-06-14T00:00:00.000Z
2024-06-13 16:28:32.927286 [INFO] ocpp:OCPP201     :: PeriodDateTimePair>  period: {
    "limit": 20.0,
    "numberPhases": 1,
    "startPeriod": 0
} end_time: 2024-06-14T00:00:00.000Z
2024-06-13 16:28:32.927585 [INFO] ocpp:OCPP201     :: period.has_value() limit = 4600
2024-06-13 16:28:32.927671 [INFO] ocpp:OCPP201     :: period.has_value() stackLevel = 4600
2024-06-13 16:28:33.018306 [ERRO] ocpp:OCPP201    void ocpp::v201::ChargePoint::handle_set_charging_profile_req(ocpp::Call<ocpp::v201::SetChargingProfileRequest>) :: Received profile validity: Validsetting response to {
    "status": "Accepted"
}

Plugged in the car again, and got max power of 4600 W, with 230V and 6.6A

Got the same result once started charging using new profile
2024-06-13 16:33:53.809243 [DEBG] iso15118_car    pybind11_init_everestpy(pybind11::module_&)::<lambda(const std::string&)> :: Decoded message (ns=urn:iso:15118:2:2013:MsgDef): {"V2G_Message":{"Header":{"SessionID":"E8875BBEF62E2EFF"},
"Body":{"ChargeParameterDiscoveryRes":{"ResponseCode":"OK",
"EVSEProcessing":"Finished",
"SAScheduleList":{"SAScheduleTuple":[{"SAScheduleTupleID":1,
"PMaxSchedule":{"PMaxScheduleEntry":[{"RelativeTimeInterval":{"start":0,
"duration":86400},
"PMax":{"Multiplier":0,
"Unit":"W",
"Value":4600}}]}}]},
"AC_EVSEChargeParameter":{"AC_EVSEStatus":{"NotificationMaxDelay":0,
"EVSENotification":"None",
"RCD":false},
"EVSENominalVoltage":{"Multiplier":-1,
"Unit":"V",
"Value":2300},
"EVSEMaxCurrent":{"Multiplier":-1,
"Unit":"A",
"Value":66}}}}}}

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