From 71eaf7e71365bac9ac24e03225a9c7a9505915ce Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Fri, 15 Apr 2022 16:17:12 +0200 Subject: [PATCH] Start from scratch becaus of crashing --- .../src/{rz_web.cpp => BCM_pids.cpp} | 51 +----- .../vehicle_renaultzoe_ph2/src/BCM_pids.h | 3 - .../src/{EVC_pids.h => EVC_pids.cpp} | 30 +++- .../vehicle_renaultzoe_ph2/src/HVAC_pids.cpp | 50 ++++++ .../vehicle_renaultzoe_ph2/src/HVAC_pids.h | 27 --- .../src/{INV_pids.h => INV_pids.cpp} | 30 +++- .../src/{LBC_pids.h => LBC_pids.cpp} | 30 +++- .../vehicle_renaultzoe_ph2/src/UCM_pids.cpp | 29 ++++ .../vehicle_renaultzoe_ph2/src/UCM_pids.h | 3 - .../vehicle_renaultzoe_ph2/src/ph2_poller.h | 25 +++ .../src/rz_commands.cpp | 163 ----------------- .../src/vehicle_renaultzoe_ph2.cpp | 164 +----------------- .../src/vehicle_renaultzoe_ph2.h | 45 +---- 13 files changed, 203 insertions(+), 447 deletions(-) rename OVMS.V3/components/vehicle_renaultzoe_ph2/src/{rz_web.cpp => BCM_pids.cpp} (51%) delete mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.h rename OVMS.V3/components/vehicle_renaultzoe_ph2/src/{EVC_pids.h => EVC_pids.cpp} (67%) create mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp delete mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.h rename OVMS.V3/components/vehicle_renaultzoe_ph2/src/{INV_pids.h => INV_pids.cpp} (60%) rename OVMS.V3/components/vehicle_renaultzoe_ph2/src/{LBC_pids.h => LBC_pids.cpp} (77%) create mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp delete mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.h delete mode 100644 OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_commands.cpp diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_web.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.cpp similarity index 51% rename from OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_web.cpp rename to OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.cpp index 994a7de..f4f1aa8 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_web.cpp +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.cpp @@ -1,15 +1,8 @@ /* ; Project: Open Vehicle Monitor System -; Date: 11th Sep 2019 +; Date: 15th Apr 2022 ; -; Changes: -; 1.0 Initial release -; -; (C) 2011 Michael Stegen / Stegen Electronics -; (C) 2011-2017 Mark Webb-Johnson -; (C) 2011 Sonny Chen @ EPRO/DX -; (C) 2018 Marcos Mezo -; (C) 2019 Thomas Heuer @Dimitrie78 +; (C) 2022 Carsten Schmiemann ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal @@ -30,42 +23,8 @@ ; THE SOFTWARE. */ -#include -#ifdef CONFIG_OVMS_COMP_WEBSERVER - -#include -#include -#include "ovms_metrics.h" -#include "ovms_events.h" -#include "ovms_config.h" -#include "ovms_command.h" -#include "metrics_standard.h" -#include "ovms_notify.h" -#include "ovms_webserver.h" - #include "vehicle_renaultzoe_ph2.h" -using namespace std; - -#define _attr(text) (c.encode_html(text).c_str()) -#define _html(text) (c.encode_html(text).c_str()) - - -/** - * WebInit: register pages - */ -void OvmsVehicleRenaultZoePh2::WebInit() -{ - // vehicle menu: - MyWebServer.RegisterPage("/zph2/battmon", "Battery Monitor", OvmsWebServer::HandleBmsCellMonitor, PageMenu_Vehicle, PageAuth_Cookie); -} - -/** - * WebDeInit: deregister pages - */ -void OvmsVehicleRenaultZoePh2::WebDeInit() -{ - MyWebServer.DeregisterPage("/zph2/battmon"); -} - -#endif //CONFIG_OVMS_COMP_WEBSERVER +void OvmsVehicleRenaultZoePh2::IncomingBCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) { + +} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.h deleted file mode 100644 index ab7748e..0000000 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/BCM_pids.h +++ /dev/null @@ -1,3 +0,0 @@ -void OvmsVehicleRenaultZoePh2::IncomingBCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) { - -} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.cpp similarity index 67% rename from OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.h rename to OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.cpp index 95c07f9..bf01e43 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.h +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/EVC_pids.cpp @@ -1,6 +1,30 @@ -/** - * Handle incoming polls from the EVC Computer - */ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ + +#include "vehicle_renaultzoe_ph2.h" + void OvmsVehicleRenaultZoePh2::IncomingEVC(uint16_t type, uint16_t pid, const char* data, uint16_t len) { switch (pid) { case 0x2006: { // Odometer (Total Vehicle Distance) diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp new file mode 100644 index 0000000..6c53188 --- /dev/null +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp @@ -0,0 +1,50 @@ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ +#include "vehicle_renaultzoe_ph2.h" + +void OvmsVehicleRenaultZoePh2::IncomingHVAC(uint16_t type, uint16_t pid, const char* data, uint16_t len) { + switch (pid) { + case 0x4361: { //Cabin temperature + StandardMetrics.ms_v_env_cabintemp->SetValue(float(CAN_UINT(0) - 40), Celcius); + ESP_LOGD(TAG, "4361 HVAC ms_v_env_cabintemp: %d", (CAN_UINT(0) - 40)); + break; + } + case 0x4360: { //Cabin setpoint + StandardMetrics.ms_v_env_cabinsetpoint->SetValue(float(((CAN_UINT(0) + 32) / 2)), Celcius); + ESP_LOGD(TAG, "4360 HVAC ms_v_env_cabinsetpoint: %d", (CAN_UINT(0) + 32) / 2); + break; + } + case 0x436B: { //Cabin FAN speed + StandardMetrics.ms_v_env_cabinfan->SetValue(float(CAN_UINT(0)), Percentage); + ESP_LOGD(TAG, "436B HVAC ms_v_env_cabinfan: %d", CAN_UINT(0)); + break; + } + case 0x43D8: { //Compressor speed + mt_hvac_compressor_speed->SetValue(float(CAN_UINT(0))); + ESP_LOGD(TAG, "43D8 HVAC mt_hvac_compressor_speed: %d", CAN_UINT(0)); + break; + } + } +} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.h deleted file mode 100644 index c8b1758..0000000 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Handle incoming polls from the ClimBox HVAC controller - */ -void OvmsVehicleRenaultZoePh2::IncomingHVAC(uint16_t type, uint16_t pid, const char* data, uint16_t len) { - switch (pid) { - case 0x4361: { //Cabin temperature - StandardMetrics.ms_v_env_cabintemp->SetValue(float(CAN_UINT(0) - 40), Celcius); - ESP_LOGD(TAG, "4361 HVAC ms_v_env_cabintemp: %d", (CAN_UINT(0) - 40)); - break; - } - case 0x4360: { //Cabin setpoint - StandardMetrics.ms_v_env_cabinsetpoint->SetValue(float(((CAN_UINT(0) + 32) / 2)), Celcius); - ESP_LOGD(TAG, "4360 HVAC ms_v_env_cabinsetpoint: %d", (CAN_UINT(0) + 32) / 2); - break; - } - case 0x436B: { //Cabin FAN speed - StandardMetrics.ms_v_env_cabinfan->SetValue(float(CAN_UINT(0)), Percentage); - ESP_LOGD(TAG, "436B HVAC ms_v_env_cabinfan: %d", CAN_UINT(0)); - break; - } - case 0x43D8: { //Compressor speed - mt_hvac_compressor_speed->SetValue(float(CAN_UINT(0))); - ESP_LOGD(TAG, "43D8 HVAC mt_hvac_compressor_speed: %d", CAN_UINT(0)); - break; - } - } -} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.cpp similarity index 60% rename from OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.h rename to OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.cpp index b53b1b1..69047f5 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.h +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/INV_pids.cpp @@ -1,6 +1,30 @@ -/** - * Handle incoming polls from the motor inverter - */ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ + +#include "vehicle_renaultzoe_ph2.h" + void OvmsVehicleRenaultZoePh2::IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len) { switch (pid) { case 0x700C: { // Inverter temperature diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.cpp similarity index 77% rename from OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.h rename to OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.cpp index fc96b5c..3a50eb9 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.h +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/LBC_pids.cpp @@ -1,6 +1,30 @@ -/** - * Handle incoming polls from the LBC Computer - */ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ + +#include "vehicle_renaultzoe_ph2.h" + void OvmsVehicleRenaultZoePh2::IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len) { switch (pid) { case 0x9005: { //Battery voltage diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp new file mode 100644 index 0000000..e42fe1b --- /dev/null +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp @@ -0,0 +1,29 @@ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ +#include "vehicle_renaultzoe_ph2.h" + +void OvmsVehicleRenaultZoePh2::IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) { + +} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.h deleted file mode 100644 index 65c3717..0000000 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.h +++ /dev/null @@ -1,3 +0,0 @@ -void OvmsVehicleRenaultZoePh2::IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) { - -} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/ph2_poller.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/ph2_poller.h index b4766db..bf57d6c 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/ph2_poller.h +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/ph2_poller.h @@ -1,3 +1,28 @@ +/* +; Project: Open Vehicle Monitor System +; Date: 15th Apr 2022 +; +; (C) 2022 Carsten Schmiemann +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in +; all copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +; THE SOFTWARE. +*/ + #define SESSION_EXTDIAG 0x1003 #define SESSION_DEFAULT 0x1001 #define SESSION_AfterSales 0x10C0 diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_commands.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_commands.cpp deleted file mode 100644 index 7623f75..0000000 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/rz_commands.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* -; Project: Open Vehicle Monitor System -; Date: 11th Sep 2019 -; -; Changes: -; 1.0 Initial release -; -; (C) 2011 Michael Stegen / Stegen Electronics -; (C) 2011-2017 Mark Webb-Johnson -; (C) 2011 Sonny Chen @ EPRO/DX -; (C) 2018 Marcos Mezo -; (C) 2019 Thomas Heuer @Dimitrie78 -; (C) 2022 Carsten Schmiemann (Zoe PH2 Integration) -; -; Permission is hereby granted, free of charge, to any person obtaining a copy -; of this software and associated documentation files (the "Software"), to deal -; in the Software without restriction, including without limitation the rights -; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -; copies of the Software, and to permit persons to whom the Software is -; furnished to do so, subject to the following conditions: -; -; The above copyright notice and this permission notice shall be included in -; all copies or substantial portions of the Software. -; -; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -; THE SOFTWARE. -*/ - -#include "ovms_log.h" -static const char *TAG = "v-zoe-ph2"; - -#include -#include -#include -#include "pcp.h" -#include "ovms_metrics.h" -#include "ovms_events.h" -#include "ovms_config.h" -#include "ovms_command.h" -#include "metrics_standard.h" -#include "ovms_notify.h" -#include "ovms_peripherals.h" - -#include "vehicle_renaultzoe_ph2.h" - -OvmsVehicle::vehicle_command_t OvmsVehicleRenaultZoePh2::CommandTrip(int verbosity, OvmsWriter* writer) { - metric_unit_t rangeUnit = (MyConfig.GetParamValue("vehicle", "units.distance") == "M") ? Miles : Kilometers; - - writer->printf("Driven: %s\n", (char*) StdMetrics.ms_v_pos_trip->AsUnitString("-", rangeUnit, 1).c_str()); - writer->printf("Energy used: %s\n", (char*) StdMetrics.ms_v_bat_energy_used->AsUnitString("-", Native, 3).c_str()); - writer->printf("Energy recd: %s\n", (char*) StdMetrics.ms_v_bat_energy_recd->AsUnitString("-", Native, 3).c_str()); - writer->printf("Energy Available: %s\n", (char*) mt_available_energy->AsUnitString("-", Native, 1).c_str()); - - return Success; -} - -void OvmsVehicleRenaultZoePh2::NotifyTrip() { - StringWriter buf(200); - CommandTrip(COMMAND_RESULT_NORMAL, &buf); - MyNotify.NotifyString("info","xrz.trip",buf.c_str()); -} - -OvmsVehicle::vehicle_command_t OvmsVehicleRenaultZoePh2::CommandStat(int verbosity, OvmsWriter* writer) { - metric_unit_t rangeUnit = (MyConfig.GetParamValue("vehicle", "units.distance") == "M") ? Miles : Kilometers; - - bool chargeport_open = StdMetrics.ms_v_door_chargeport->AsBool(); - if (chargeport_open) - { - std::string charge_mode = StdMetrics.ms_v_charge_mode->AsString(); - std::string charge_state = StdMetrics.ms_v_charge_state->AsString(); - bool show_details = !(charge_state == "done" || charge_state == "stopped"); - - // Translate mode codes: - if (charge_mode == "standard") - charge_mode = "Standard"; - else if (charge_mode == "storage") - charge_mode = "Storage"; - else if (charge_mode == "range") - charge_mode = "Range"; - else if (charge_mode == "performance") - charge_mode = "Performance"; - - // Translate state codes: - if (charge_state == "charging") - charge_state = "Charging"; - else if (charge_state == "topoff") - charge_state = "Topping off"; - else if (charge_state == "done") - charge_state = "Charge Done"; - else if (charge_state == "preparing") - charge_state = "Preparing"; - else if (charge_state == "heating") - charge_state = "Charging, Heating"; - else if (charge_state == "stopped") - charge_state = "Charge Stopped"; - - writer->printf("%s - %s\n", charge_mode.c_str(), charge_state.c_str()); - - if (show_details) - { - writer->printf("%s/%s\n", - (char*) StdMetrics.ms_v_charge_voltage->AsUnitString("-", Native, 1).c_str(), - (char*) StdMetrics.ms_v_charge_current->AsUnitString("-", Native, 1).c_str()); - - int duration_full = StdMetrics.ms_v_charge_duration_full->AsInt(); - if (duration_full > 0) - writer->printf("Full: %d mins\n", duration_full); - - int duration_soc = StdMetrics.ms_v_charge_duration_soc->AsInt(); - if (duration_soc > 0) - writer->printf("%s: %d mins\n", - (char*) StdMetrics.ms_v_charge_limit_soc->AsUnitString("SOC", Native, 0).c_str(), - duration_soc); - - int duration_range = StdMetrics.ms_v_charge_duration_range->AsInt(); - if (duration_range > 0) - writer->printf("%s: %d mins\n", - (char*) StdMetrics.ms_v_charge_limit_range->AsUnitString("Range", rangeUnit, 0).c_str(), - duration_range); - } - } - else - { - writer->puts("Not charging"); - } - - writer->printf("SOC: %s\n", (char*) StdMetrics.ms_v_bat_soc->AsUnitString("-", Native, 1).c_str()); - - const char* range_ideal = StdMetrics.ms_v_bat_range_ideal->AsUnitString("-", rangeUnit, 0).c_str(); - if (*range_ideal != '-') - writer->printf("Ideal range: %s\n", range_ideal); - - const char* range_est = StdMetrics.ms_v_bat_range_est->AsUnitString("-", rangeUnit, 0).c_str(); - if (*range_est != '-') - writer->printf("Est. range: %s\n", range_est); - - const char* chargedkwh = StdMetrics.ms_v_charge_kwh->AsUnitString("-", Native, 3).c_str(); - if (*chargedkwh != '-') - writer->printf("Energy charged: %s\n", chargedkwh); - - const char* odometer = StdMetrics.ms_v_pos_odometer->AsUnitString("-", rangeUnit, 1).c_str(); - if (*odometer != '-') - writer->printf("ODO: %s\n", odometer); - - const char* cac = StdMetrics.ms_v_bat_cac->AsUnitString("-", Native, 1).c_str(); - if (*cac != '-') - writer->printf("CAC: %s\n", cac); - - const char* soh = StdMetrics.ms_v_bat_soh->AsUnitString("-", Native, 1).c_str(); - if (*soh != '-') - writer->printf("SOH: %s\n", soh); - - const char* avai_energy = mt_available_energy->AsUnitString("-", Native, 1).c_str(); - if (*avai_energy != '-') - writer->printf("Energy Available: %s\n", avai_energy); - - return Success; -} diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp index 1adb8a5..5c78c2a 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.cpp @@ -1,15 +1,8 @@ /* ; Project: Open Vehicle Monitor System -; Date: 11th Sep 2019 +; Date: 15th Apr 2022 ; -; Changes: -; 1.0 Initial release -; -; (C) 2011 Michael Stegen / Stegen Electronics -; (C) 2011-2017 Mark Webb-Johnson -; (C) 2011 Sonny Chen @ EPRO/DX -; (C) 2018 Marcos Mezo -; (C) 2019 Thomas Heuer @Dimitrie78 +; (C) 2022 Carsten Schmiemann ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal @@ -30,8 +23,8 @@ ; THE SOFTWARE. */ + #include "ovms_log.h" -static const char *TAG = "v-zoe-ph2"; #include #include @@ -48,26 +41,6 @@ static const char *TAG = "v-zoe-ph2"; #include "vehicle_renaultzoe_ph2.h" #include "ph2_poller.h" -#include "INV_pids.h" -#include "EVC_pids.h" -#include "BCM_pids.h" -#include "LBC_pids.h" -#include "HVAC_pids.h" -#include "UCM_pids.h" - - -OvmsVehicleRenaultZoePh2* OvmsVehicleRenaultZoePh2::GetInstance(OvmsWriter* writer /*=NULL*/) -{ - OvmsVehicleRenaultZoePh2* zoe = (OvmsVehicleRenaultZoePh2*) MyVehicleFactory.ActiveVehicle(); - string type = StdMetrics.ms_v_type->AsString(); - if (!zoe || type != "RZ2") { - if (writer) - writer->puts("Error: Renault Zoe Ph2 vehicle module not selected"); - return NULL; - } - return zoe; -} - OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() { ESP_LOGI(TAG, "Start Renault Zoe Ph2 vehicle module"); @@ -75,9 +48,6 @@ OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() { StandardMetrics.ms_v_type->SetValue("RZ2"); StandardMetrics.ms_v_charge_inprogress->SetValue(false); - //MyConfig.RegisterParam("zph2", "Renault Zoe Ph2", true, true); - //ConfigChanged(NULL); - // Zoe CAN bus runs at 500 kbps RegisterCanBus(1, CAN_MODE_ACTIVE, CAN_SPEED_500KBPS); @@ -103,9 +73,6 @@ OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() { mt_inv_hv_current = MyMetrics.InitFloat("zph2.m.inverter.current", SM_STALE_MID, 0, Amps); mt_bat_max_charge_power = MyMetrics.InitFloat("zph2.b.max.charge.power", SM_STALE_MID, 0, kW); mt_hvac_compressor_speed = MyMetrics.InitFloat("zph2.h.compressor.speed", SM_STALE_MID, 0); - - // init commands: - cmd_zoe = MyCommandApp.RegisterCommand("zoe-ph2", "Renault Zoe Ph2"); // BMS configuration: BmsSetCellArrangementVoltage(96, 8); @@ -115,17 +82,10 @@ OvmsVehicleRenaultZoePh2::OvmsVehicleRenaultZoePh2() { BmsSetCellDefaultThresholdsVoltage(0.030, 0.050); BmsSetCellDefaultThresholdsTemperature(4.0, 5.0); -#ifdef CONFIG_OVMS_COMP_WEBSERVER - WebInit(); -#endif } OvmsVehicleRenaultZoePh2::~OvmsVehicleRenaultZoePh2() { ESP_LOGI(TAG, "Stop Renault Zoe Ph2 vehicle module"); - -#ifdef CONFIG_OVMS_COMP_WEBSERVER - WebDeInit(); -#endif } /** @@ -204,13 +164,6 @@ void OvmsVehicleRenaultZoePh2::car_on(bool isOn) { // Handle 12Vcharging StandardMetrics.ms_v_env_charging12v->SetValue(true); POLLSTATE_RUNNING; - // Reset trip values - if (!m_reset_trip) { - StandardMetrics.ms_v_bat_energy_recd->SetValue(0); - StandardMetrics.ms_v_bat_energy_used->SetValue(0); - mt_pos_odometer_start->SetValue(StandardMetrics.ms_v_pos_odometer->AsFloat()); - StandardMetrics.ms_v_pos_trip->SetValue(0); - } } else if(!isOn && StandardMetrics.ms_v_env_on->AsBool()) { // Car is being turned OFF @@ -223,118 +176,17 @@ void OvmsVehicleRenaultZoePh2::car_on(bool isOn) { } StandardMetrics.ms_v_env_on->SetValue( isOn ); StandardMetrics.ms_v_env_awake->SetValue( isOn ); - StandardMetrics.ms_v_pos_speed->SetValue( 0 ); - if (StandardMetrics.ms_v_pos_trip->AsFloat(0) > 0.1) - NotifyTrip(); + StandardMetrics.ms_v_pos_speed->SetValue( 0 );; } } -void OvmsVehicleRenaultZoePh2::Ticker1(uint32_t ticker) { - - HandleEnergy(); - - // Handle Tripcounter - if (mt_pos_odometer_start->AsFloat(0) == 0 && StandardMetrics.ms_v_pos_odometer->AsFloat(0) > 0.0) { - mt_pos_odometer_start->SetValue(StandardMetrics.ms_v_pos_odometer->AsFloat()); - } - if (StandardMetrics.ms_v_env_on->AsBool() && StandardMetrics.ms_v_pos_odometer->AsFloat(0) > 0.0 && mt_pos_odometer_start->AsFloat(0) > 0.0) { - StandardMetrics.ms_v_pos_trip->SetValue(StandardMetrics.ms_v_pos_odometer->AsFloat(0) - mt_pos_odometer_start->AsFloat(0)); - } - - // Handle v2Server connection - if (StandardMetrics.ms_s_v2_connected->AsBool()) { - m_reboot_ticker = 5 * 60; // set reboot ticker - } - else if (m_reboot_ticker > 0 && --m_reboot_ticker == 0) { - MyNetManager.RestartNetwork(); - m_reboot_ticker = 5 * 60; - //MyBoot.Restart(); // restart Module - } -} - -void OvmsVehicleRenaultZoePh2::Ticker10(uint32_t ticker) { - HandleCharging(); -} - -/** - * Update derived energy metrics while driving - * Called once per second - */ -void OvmsVehicleRenaultZoePh2::HandleEnergy() { - float voltage = StandardMetrics.ms_v_bat_voltage->AsFloat(0, Volts); - float current = StandardMetrics.ms_v_bat_current->AsFloat(0, Amps); - - // Power (in kw) resulting from voltage and current - float power = voltage * current / 1000.0; - - StandardMetrics.ms_v_bat_power->SetValue(power * -1.0f); - - // Are we driving? - if (power != 0.0 && StandardMetrics.ms_v_env_on->AsBool()) { - // Update energy used and recovered - float energy = power / 3600.0; // 1 second worth of energy in kwh's - if (energy < 0.0f) - StandardMetrics.ms_v_bat_energy_used->SetValue( StandardMetrics.ms_v_bat_energy_used->AsFloat() - energy); - else // (energy > 0.0f) - StandardMetrics.ms_v_bat_energy_recd->SetValue( StandardMetrics.ms_v_bat_energy_recd->AsFloat() + energy); - } -} - -/** - * Calculates minutes remaining before target is reached. Based on current charge speed. - */ -int OvmsVehicleRenaultZoePh2::calcMinutesRemaining(float target_soc, float charge_voltage, float charge_current) { - float bat_soc = StandardMetrics.ms_v_bat_soc->AsFloat(100); - if (bat_soc == (float)100 ) { - return 0; // Done! - } - float remaining_wh = m_battery_capacity * (target_soc - bat_soc) / 100.0; - float remaining_hours = remaining_wh / (charge_current * charge_voltage); - float remaining_mins = remaining_hours * 60.0; - - return MIN( 1440, (int)remaining_mins ); -} - -/** - * Update derived metrics when charging - * Called once per 10 seconds from Ticker10 - */ -void OvmsVehicleRenaultZoePh2::HandleCharging() { - float charge_current = StandardMetrics.ms_v_bat_current->AsFloat(0, Amps); - float charge_voltage = StandardMetrics.ms_v_bat_voltage->AsFloat(0, Volts); - - // Are we charging? - if (!StandardMetrics.ms_v_charge_pilot->AsBool() || - !StandardMetrics.ms_v_charge_inprogress->AsBool() || - (charge_current <= 0.0) ) { - return; - } - - // Check if we have what is needed to calculate energy and remaining minutes - if (charge_voltage > 0 && charge_current > 0) { - // Update energy taken - // Value is reset to 0 when a new charging session starts... - float power = charge_voltage * charge_current / 1000.0; // power in kw - float energy = power / 3600.0 * 10.0; // 10 second worth of energy in kwh's - StandardMetrics.ms_v_charge_kwh->SetValue( StandardMetrics.ms_v_charge_kwh->AsFloat() + energy); - - int minsremaining_soc = calcMinutesRemaining((float)100, charge_voltage, charge_current); - - StandardMetrics.ms_v_charge_duration_soc->SetValue(minsremaining_soc, Minutes); - ESP_LOGV(TAG, "Time remaining: %d mins to %d soc", minsremaining_soc, 100); - } -} - -//----------------------------------------------------------------------------- -// -// RenaultZoeInit -// class OvmsVehicleRenaultZoePh2Init { public: OvmsVehicleRenaultZoePh2Init(); } MyOvmsVehicleRenaultZoePh2Init __attribute__ ((init_priority (9000))); -OvmsVehicleRenaultZoePh2Init::OvmsVehicleRenaultZoePh2Init() { - ESP_LOGI(TAG, "Registering Vehicle: Renault Zoe Ph2 (9000)"); +OvmsVehicleRenaultZoePh2Init::OvmsVehicleRenaultZoePh2Init() +{ + ESP_LOGI(TAG, "Registering Vehicle: Renault Zoe Ph2 (9000)"); MyVehicleFactory.RegisterVehicle("RZ2","Renault Zoe Ph2"); -} +} \ No newline at end of file diff --git a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.h b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.h index 200346f..d78367f 100644 --- a/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.h +++ b/OVMS.V3/components/vehicle_renaultzoe_ph2/src/vehicle_renaultzoe_ph2.h @@ -1,16 +1,8 @@ /* ; Project: Open Vehicle Monitor System -; Date: 11th Sep 2019 +; Date: 15th Apr 2022 ; -; Changes: -; 0.1.0 Initial release -; - fork of vehicle_demo -; -; (C) 2011 Michael Stegen / Stegen Electronics -; (C) 2011-2017 Mark Webb-Johnson -; (C) 2011 Sonny Chen @ EPRO/DX -; (C) 2018 Marcos Mezo -; (C) 2019 Thomas Heuer @Dimitrie78 +; (C) 2022 Carsten Schmiemann ; ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal @@ -34,6 +26,8 @@ #ifndef __VEHICLE_RENAULTZOE_PH2_H__ #define __VEHICLE_RENAULTZOE_PH2_H__ +static const char *TAG = "v-zoe-ph2"; + #include #include "can.h" @@ -62,8 +56,6 @@ #define POLLSTATE_RUNNING PollSetState(2); #define POLLSTATE_CHARGING PollSetState(3); -#define RZ_CANDATA_TIMEOUT 10 - using namespace std; class OvmsVehicleRenaultZoePh2 : public OvmsVehicle { @@ -85,16 +77,7 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle { void IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len); void car_on(bool isOn); - virtual void Ticker1(uint32_t ticker); - virtual void Ticker10(uint32_t ticker); - - void HandleCharging(); - void HandleEnergy(); - void NotifyTrip(); - int calcMinutesRemaining(float target, float charge_voltage, float charge_current); - - OvmsCommand *cmd_zoe; - + // Renault ZOE specific metrics OvmsMetricFloat *mt_pos_odometer_start; // ODOmeter at Start OvmsMetricBool *mt_bus_awake; // can-bus awake status @@ -110,26 +93,8 @@ class OvmsVehicleRenaultZoePh2 : public OvmsVehicle { OvmsMetricFloat *mt_bat_max_charge_power; //Battery max charge power OvmsMetricFloat *mt_hvac_compressor_speed; //Compressor speed - public: - void WebInit(); - void WebDeInit(); - static void WebCfgFeatures(PageEntry_t& p, PageContext_t& c); - static void WebCfgBattery(PageEntry_t& p, PageContext_t& c); - virtual vehicle_command_t CommandTrip(int verbosity, OvmsWriter* writer); - virtual vehicle_command_t CommandStat(int verbosity, OvmsWriter* writer); - - protected: - char zoe_vin[8] = ""; // last 7 digits of full VIN - int m_range_ideal; // … Range Ideal (default 160 km) - int m_battery_capacity; // Battery Capacity (default 27000) - bool m_enable_egpio; // enable EGPIO for Homelink commands - bool m_reset_trip; // Reset trip when charging else when env on - int m_vehicle_type; // Vehicle type (Zoe, Kangoo...) - int m_reboot_ticker; - protected: string zoe_obd_rxbuf; - }; #endif //#ifndef __VEHICLE_RENAULTZOE_PH2_H__