|
@@ -42,6 +42,7 @@
|
|
|
#include "./Define/define.h"
|
|
|
#include "./SelectGun/SelectGun.h"
|
|
|
#include "Config.h"
|
|
|
+#include "./ModuleEvComm/Module_EvComm.h"
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
#define CMD_KEY_WAIT (1)
|
|
@@ -705,6 +706,91 @@ static void setConfirmSelGun(uint8_t selGun)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+static float ReadAdcVolt(uint8_t AdcChannel)
|
|
|
+{
|
|
|
+ //AIN0=CCS GUN Temp 1
|
|
|
+ //AIN1=CCS GUN Temp 2
|
|
|
+ //AIN2=CCS_Proximity/2
|
|
|
+ //AIN3=pilot voltage
|
|
|
+ int fd = -1;
|
|
|
+ uint8_t str[64] = { 0 };
|
|
|
+ uint8_t AdcValue[8] = { '\0' };
|
|
|
+
|
|
|
+ if (AdcChannel > 7) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ sprintf((char*)str, "/sys/bus/iio/devices/iio\:device0/in_voltage%d_raw", AdcChannel);
|
|
|
+ fd = open((char*)str, O_RDONLY);
|
|
|
+ read(fd, AdcValue, 4);
|
|
|
+
|
|
|
+ close(fd);
|
|
|
+
|
|
|
+ return (1.8 * atoi((char*)&AdcValue[0])) / 4095;
|
|
|
+ //return (1.8 * atoi((char *)&AdcValue)) / 4095;
|
|
|
+}
|
|
|
+
|
|
|
+static void getChillerTemperature(struct ChargingInfoData* chargingData)
|
|
|
+{
|
|
|
+ uint8_t i = 0;
|
|
|
+ float adcVoltage = 0.0;
|
|
|
+ ChillerTemp pChillerTemp;
|
|
|
+ uint8_t maxTemp;
|
|
|
+ for (i = 0; i < 4; i++) {
|
|
|
+ adcVoltage = 0.0;
|
|
|
+ adcVoltage = ReadAdcVolt(i);
|
|
|
+ ShmDcCommonData->TempVolt[i] = adcVoltage;
|
|
|
+ if ((adcVoltage <= 0.9) && (adcVoltage >= 0.8)) { //0 ~ -40
|
|
|
+ pChillerTemp.Temp[i] = ((adcVoltage - 0.908) * 500) + 60;
|
|
|
+ //log_info("1 adcVoltage = %f", (adcVoltage - 0.9) * 500);
|
|
|
+ } else if ((adcVoltage <= 1.07) && (adcVoltage > 0.9)) {
|
|
|
+ pChillerTemp.Temp[i] = ((adcVoltage - 0.91) * 705.88) + 60;
|
|
|
+ //log_info("2 adcVoltage = %f", (adcVoltage - 0.9) * 500);
|
|
|
+ } else {
|
|
|
+ pChillerTemp.Temp[i] = UNDEFINED_TEMP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ maxTemp = pChillerTemp.Temp[0];
|
|
|
+ memcpy((char*)ShmDcCommonData->SystemTemp, (char*)pChillerTemp.Temp, sizeof(ChillerTemp));
|
|
|
+ for (i = 1; i < 4; i++) {
|
|
|
+ if (pChillerTemp.Temp[i] > pChillerTemp.Temp[i - 1] && pChillerTemp.Temp[i] != UNDEFINED_TEMP) {
|
|
|
+ maxTemp = pChillerTemp.Temp[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ chargingData->ChillerTemp = maxTemp;
|
|
|
+}
|
|
|
+
|
|
|
+void GetOtpPwrOrCurMethod(struct ChargingInfoData* chargingData, float* pow, float* cur)
|
|
|
+{
|
|
|
+ if (((chargingData->ConnectorTemp >= STAGE1_GUN_DERATING_TEMP &&
|
|
|
+ chargingData->ConnectorTemp < STAGE2_GUN_DERATING_TEMP) ||
|
|
|
+ (chargingData->ChillerTemp >= STAGE1_GUN_DERATING_TEMP &&
|
|
|
+ chargingData->ChillerTemp < STAGE2_GUN_DERATING_TEMP)) &&
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex < 1)
|
|
|
+ {
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex = 1;
|
|
|
+ } else if ((chargingData->ConnectorTemp >= STAGE2_GUN_DERATING_TEMP ||
|
|
|
+ chargingData->ChillerTemp >= STAGE2_GUN_DERATING_TEMP) &&
|
|
|
+ chargingData->ConnectorTemp != UNDEFINED_TEMP &&
|
|
|
+ chargingData->ChillerTemp != UNDEFINED_TEMP &&
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex < 2)
|
|
|
+ {
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex] != 0)
|
|
|
+ {
|
|
|
+ *pow *= chargingData->deratingByConnOtp.deratingTargetRate[chargingData->deratingByConnOtp.deratingIndex];
|
|
|
+ } else if (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex] != 0)
|
|
|
+ {
|
|
|
+ if (*cur > (chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex]/10)) {
|
|
|
+ *cur = chargingData->deratingByConnOtp.deratingTargetCurrent[chargingData->deratingByConnOtp.deratingIndex]/10;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
{
|
|
|
int _GunIndex;
|
|
@@ -714,6 +800,9 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
int isContinue = 1;
|
|
|
float _Voltage;
|
|
|
float _Current;
|
|
|
+ float deratingPower;
|
|
|
+ float deratingCurrent;
|
|
|
+ int derating_index = 0;
|
|
|
uint8_t PreviousSystemStatus[2] = {0xff};
|
|
|
char *usageMsg = "Usage:\n"
|
|
|
" strchg <index> <voltage> <current> ex: strchg 0 150 2\n"
|
|
@@ -921,6 +1010,24 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
// pDcChargingInfo->EvBatterytargetVoltage,
|
|
|
// pDcChargingInfo->EvBatterytargetCurrent);
|
|
|
//ev task do this
|
|
|
+ if (pDcChargingInfo->deratingByConnOtp.isNeedDerating) {
|
|
|
+ deratingCurrent = pDcChargingInfo->EvBatterytargetCurrent;
|
|
|
+ deratingPower = pDcChargingInfo->AvailableChargingPower;
|
|
|
+
|
|
|
+ getChillerTemperature(pDcChargingInfo);
|
|
|
+ GetOtpPwrOrCurMethod(pDcChargingInfo, &deratingPower, &deratingCurrent);
|
|
|
+ if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
|
|
|
+ printf("Change Derating Index:%d\n", pDcChargingInfo->deratingByConnOtp.deratingIndex);
|
|
|
+ derating_index = pDcChargingInfo->deratingByConnOtp.deratingIndex;
|
|
|
+ }
|
|
|
+ if (pDcChargingInfo->EvBatterytargetCurrent != deratingCurrent ||
|
|
|
+ pDcChargingInfo->AvailableChargingPower != deratingPower) {
|
|
|
+ pDcChargingInfo->EvBatterytargetCurrent = deratingCurrent;
|
|
|
+ pDcChargingInfo->AvailableChargingPower = deratingPower;
|
|
|
+ printf("Derating Current:%.3f Power:%.3f\n", pDcChargingInfo->EvBatterytargetCurrent, pDcChargingInfo->AvailableChargingPower);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
pDcChargingInfo->PresentChargingPower =
|
|
|
((float)((pDcChargingInfo->PresentChargingVoltage) *
|
|
|
(pDcChargingInfo->PresentChargingCurrent)) / 1000);
|
|
@@ -1341,6 +1448,7 @@ static void writeGunAndChillerTemp(void)
|
|
|
usleep(sleepTime);
|
|
|
}//while
|
|
|
}
|
|
|
+
|
|
|
void ShowPowerConsumption(char* v1)
|
|
|
{
|
|
|
printf("Dispenser Gun0 PowerConsumption:%.4f\n", ShmDcCommonData->pGunInfo[0].PowerConsumption);
|