/* ; 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. */ #ifndef __VEHICLE_RENAULTZOE_PH2_H__ #define __VEHICLE_RENAULTZOE_PH2_H__ static const char *TAG = "v-zoe-ph2"; #include #include "can.h" #include "vehicle.h" #include "ovms_log.h" #include "ovms_config.h" #include "ovms_metrics.h" #include "ovms_command.h" #include "freertos/timers.h" #ifdef CONFIG_OVMS_COMP_WEBSERVER #include "ovms_webserver.h" #endif // CAN buffer access macros: b=byte# 0..7 / n=nibble# 0..15 #define CAN_BYTE(b) data[b] #define CAN_UINT(b) (((UINT)CAN_BYTE(b) << 8) | CAN_BYTE(b+1)) #define CAN_UINT24(b) (((uint32_t)CAN_BYTE(b) << 16) | ((UINT)CAN_BYTE(b+1) << 8) | CAN_BYTE(b+2)) #define CAN_UINT32(b) (((uint32_t)CAN_BYTE(b) << 24) | ((uint32_t)CAN_BYTE(b+1) << 16) | ((UINT)CAN_BYTE(b+2) << 8) | CAN_BYTE(b+3)) #define CAN_NIBL(b) (data[b] & 0x0f) #define CAN_NIBH(b) (data[b] >> 4) #define CAN_NIB(n) (((n)&1) ? CAN_NIBL((n)>>1) : CAN_NIBH((n)>>1)) #define POLLSTATE_OFF PollSetState(0); #define POLLSTATE_ON PollSetState(1); #define POLLSTATE_RUNNING PollSetState(2); #define POLLSTATE_CHARGING PollSetState(3); using namespace std; class OvmsVehicleRenaultZoePh2 : public OvmsVehicle { public: OvmsVehicleRenaultZoePh2(); ~OvmsVehicleRenaultZoePh2(); static OvmsVehicleRenaultZoePh2* GetInstance(OvmsWriter* writer=NULL); void IncomingFrameCan1(CAN_frame_t* p_frame); void IncomingPollReply(canbus* bus, uint16_t type, uint16_t pid, uint8_t* data, uint8_t length, uint16_t remain); void WebInit(); void WebDeInit(); bool CarIsDriving = false; protected: void IncomingINV(uint16_t type, uint16_t pid, const char* data, uint16_t len); void IncomingEVC(uint16_t type, uint16_t pid, const char* data, uint16_t len); void IncomingBCM(uint16_t type, uint16_t pid, const char* data, uint16_t len); void IncomingLBC(uint16_t type, uint16_t pid, const char* data, uint16_t len); void IncomingHVAC(uint16_t type, uint16_t pid, const char* data, uint16_t len); void IncomingUCM(uint16_t type, uint16_t pid, const char* data, uint16_t len); // Renault ZOE specific metrics OvmsMetricFloat *mt_pos_odometer_start; // ODOmeter at Start OvmsMetricBool *mt_bus_awake; // can-bus awake status OvmsMetricFloat *mt_available_energy; // Available Energy OvmsMetricFloat *mt_main_power_consumed; // Mains active power consumed OvmsMetricString *mt_inv_status; //Inverter status string OvmsMetricFloat *mt_mot_temp_stator1; OvmsMetricFloat *mt_mot_temp_stator2; OvmsMetricFloat *mt_aux_power_consumer; //Power usage by consumer OvmsMetricFloat *mt_aux_power_ptc; //Power usage by PTCs OvmsMetricFloat *mt_inv_hv_voltage; //Battery voltage sense OvmsMetricFloat *mt_inv_hv_current; //Battery current sense OvmsMetricFloat *mt_bat_max_charge_power; //Battery max charge power OvmsMetricFloat *mt_hvac_compressor_speed; //Compressor speed protected: string zoe_obd_rxbuf; }; #endif //#ifndef __VEHICLE_RENAULTZOE_PH2_H__