Start from scratch becaus of crashing
This commit is contained in:
parent
4794b21784
commit
71eaf7e713
13 changed files with 203 additions and 447 deletions
|
@ -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 <sdkconfig.h>
|
||||
#ifdef CONFIG_OVMS_COMP_WEBSERVER
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#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) {
|
||||
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
void OvmsVehicleRenaultZoePh2::IncomingBCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
|
||||
|
||||
}
|
|
@ -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)
|
50
OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp
Normal file
50
OVMS.V3/components/vehicle_renaultzoe_ph2/src/HVAC_pids.cpp
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -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
|
29
OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp
Normal file
29
OVMS.V3/components/vehicle_renaultzoe_ph2/src/UCM_pids.cpp
Normal file
|
@ -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) {
|
||||
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
void OvmsVehicleRenaultZoePh2::IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len) {
|
||||
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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 <stdio.h>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#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;
|
||||
}
|
|
@ -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 <stdio.h>
|
||||
#include <string>
|
||||
|
@ -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<OvmsVehicleRenaultZoePh2>("RZ2","Renault Zoe Ph2");
|
||||
}
|
||||
}
|
|
@ -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 <atomic>
|
||||
|
||||
#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__
|
||||
|
|
Loading…
Reference in a new issue