|
@@ -42,6 +42,8 @@
|
|
|
#include "./Define/define.h"
|
|
|
#include "./SelectGun/SelectGun.h"
|
|
|
#include "Config.h"
|
|
|
+#include "./ModuleEvComm/Module_EvComm.h"
|
|
|
+#include "./CSU/main.h"
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
#define CMD_KEY_WAIT (1)
|
|
@@ -342,6 +344,7 @@ void GetFwVerProc(void)
|
|
|
|
|
|
printf("ModelName = %s\r\n", pSysConfig->ModelName);
|
|
|
printf("DC Main Version = %s \n", pSysInfo->CsuRootFsFwRev);
|
|
|
+ printf("DC Main Debug Version = %s \n", ShmDcCommonData->DebugVersion);
|
|
|
printf("407 FW Version = %s\n", ShmPrimaryMcuData->version);
|
|
|
printf("Gun 0 FW Version = %s \n", pSysInfo->Connector1FwRev);
|
|
|
printf("Gun 1 FW Version = %s \n", pSysInfo->Connector2FwRev);
|
|
@@ -704,6 +707,86 @@ 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)
|
|
|
+{
|
|
|
+ for(int i = 0 ; i < 4 ; i++) {
|
|
|
+ if (ShmDcCommonData->SystemTemp[i] >= STAGE1_GUN_DERATING_TEMP &&
|
|
|
+ ShmDcCommonData->SystemTemp[i] < STAGE2_GUN_DERATING_TEMP &&
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex < 1) {
|
|
|
+ chargingData->deratingByConnOtp.deratingIndex = 1;
|
|
|
+ } else if (ShmDcCommonData->SystemTemp[i] >= STAGE2_GUN_DERATING_TEMP &&
|
|
|
+ ShmDcCommonData->SystemTemp[i] != 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;
|
|
@@ -713,7 +796,11 @@ 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};
|
|
|
+ int idx;
|
|
|
char *usageMsg = "Usage:\n"
|
|
|
" strchg <index> <voltage> <current> ex: strchg 0 150 2\n"
|
|
|
" chg <voltage> <current> ex: chg 500 100\n"
|
|
@@ -754,12 +841,16 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
|
|
|
curGun = pSysInfo->CurGunSelected;
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
|
|
|
-
|
|
|
+ if (!pDcChargingInfo->IsAvailable) {
|
|
|
+ printf("Gun%d Not Available\n",curGun);
|
|
|
+ break;
|
|
|
+ }
|
|
|
//fix gun 1
|
|
|
switch (pDcChargingInfo->SystemStatus) {
|
|
|
case S_IDLE:
|
|
|
if (PreviousSystemStatus[curGun] != pDcChargingInfo->SystemStatus) {
|
|
|
PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
|
|
|
+ sleep(3);
|
|
|
#if defined DD360Audi
|
|
|
setConfirmSelGun(curGun);
|
|
|
#endif //defined DD360Audi
|
|
@@ -768,6 +859,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
pDcChargingInfo->ConnectorPlugIn = 1;
|
|
|
printf ("[UnconditionalCharge - S_IDLE]\n");
|
|
|
pDcChargingInfo->Type = 9;
|
|
|
+ sleep(1);
|
|
|
|
|
|
}
|
|
|
if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf == 1) {
|
|
@@ -781,7 +873,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_PREPARNIN]\n");
|
|
|
-
|
|
|
+ ShmFanModuleData->TestFanSpeed = 7000;
|
|
|
//等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
|
|
|
printf ("wait find module\n");
|
|
|
|
|
@@ -840,7 +932,7 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
PreviousSystemStatus[curGun] = pDcChargingInfo->SystemStatus;
|
|
|
|
|
|
printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
|
|
|
-
|
|
|
+ strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
//printf ("tar vol = %d \n", _Voltage);
|
|
|
//printf ("tar cur = %d \n", _Current);
|
|
@@ -920,6 +1012,60 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
// pDcChargingInfo->EvBatterytargetVoltage,
|
|
|
// pDcChargingInfo->EvBatterytargetCurrent);
|
|
|
//ev task do this
|
|
|
+ for (idx = 0; idx < pSysConfig->TotalConnectorCount; idx++) {
|
|
|
+ struct ChargingInfoData* pInfo = (struct ChargingInfoData*)GetDcChargingInfoData(idx);
|
|
|
+ if (!ShmDcCommonData->TestTemperature)
|
|
|
+ getChillerTemperature(pInfo);
|
|
|
+ // 低溫保護
|
|
|
+ if ((strncmp((char*)&pSysConfig->ModelName[7 + idx * 2], "V", 1) == 0) ||
|
|
|
+ (strncmp((char*)&pSysConfig->ModelName[7 + idx * 2], "F", 1) == 0)) {
|
|
|
+ if ((ShmDcCommonData->SystemTemp[idx * 2] <= 70 ||
|
|
|
+ ShmDcCommonData->SystemTemp[idx * 2 + 1] <= 70)) {
|
|
|
+ if (pInfo->EvBatterytargetCurrent > 250) {
|
|
|
+ pInfo->EvBatterytargetCurrent = 250;
|
|
|
+ printf("Chiller%d temperature(%d %d) too low limit target Current under 250A\n", idx, ShmDcCommonData->SystemTemp[idx * 2],
|
|
|
+ ShmDcCommonData->SystemTemp[idx * 2 + 1]);
|
|
|
+ }
|
|
|
+ } else if ((ShmDcCommonData->SystemTemp[idx * 2] >= 80 ||
|
|
|
+ ShmDcCommonData->SystemTemp[idx * 2 + 1] >= 80) && pInfo->EvBatterytargetCurrent != _Current) {
|
|
|
+ pInfo->EvBatterytargetCurrent = _Current;
|
|
|
+ printf("Chiller%d temperature(%d %d) recovery target Current set %.2fA\n", idx, ShmDcCommonData->SystemTemp[idx * 2],
|
|
|
+ ShmDcCommonData->SystemTemp[idx * 2 + 1], pInfo->EvBatterytargetCurrent);
|
|
|
+ }
|
|
|
+ if (ShmPrimaryMcuData->InputDet.bits.Ac_Drop == ABNORMAL) {
|
|
|
+ if (pInfo->EvBatterytargetCurrent > 250) {
|
|
|
+ pInfo->EvBatterytargetCurrent = 250;
|
|
|
+ printf("Chiller alarm limit target Current under 250A\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 高溫保護
|
|
|
+ if (pInfo->deratingByConnOtp.isNeedDerating) {
|
|
|
+ deratingCurrent = pInfo->EvBatterytargetCurrent;
|
|
|
+ deratingPower = pInfo->AvailableChargingPower;
|
|
|
+ GetOtpPwrOrCurMethod(pInfo, &deratingPower, &deratingCurrent);
|
|
|
+ if (derating_index != pDcChargingInfo->deratingByConnOtp.deratingIndex) {
|
|
|
+ printf("Change Derating Index:%d\n", pInfo->deratingByConnOtp.deratingIndex);
|
|
|
+ derating_index = pInfo->deratingByConnOtp.deratingIndex;
|
|
|
+ }
|
|
|
+ if (pInfo->EvBatterytargetCurrent != deratingCurrent ||
|
|
|
+ pInfo->AvailableChargingPower != deratingPower) {
|
|
|
+ pInfo->EvBatterytargetCurrent = deratingCurrent;
|
|
|
+ pInfo->AvailableChargingPower = deratingPower;
|
|
|
+ printf("Derating Current:%.3f Power:%.3f\n", pInfo->EvBatterytargetCurrent, pInfo->AvailableChargingPower);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } // for
|
|
|
+
|
|
|
+ // 水冷槍低溫保護
|
|
|
+ if ((strncmp((char*)&pSysConfig->ModelName[7 + curGun * 2], "V", 1) == 0) ||
|
|
|
+ (strncmp((char*)&pSysConfig->ModelName[7 + curGun * 2], "F", 1) == 0)) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
pDcChargingInfo->PresentChargingPower =
|
|
|
((float)((pDcChargingInfo->PresentChargingVoltage) *
|
|
|
(pDcChargingInfo->PresentChargingCurrent)) / 1000);
|
|
@@ -939,8 +1085,10 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
//無阻塞偵測 keybaord 結束
|
|
|
system(STTY_DEF TTY_PATH);
|
|
|
}
|
|
|
-
|
|
|
+ sleep(1);
|
|
|
+ pDcChargingInfo->ConnectorPlugIn = 0;
|
|
|
pDcChargingInfo->SystemStatus = S_COMPLETE;
|
|
|
+
|
|
|
break;
|
|
|
|
|
|
case S_COMPLETE:
|
|
@@ -955,13 +1103,14 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
|
|
|
if (PreviousSystemStatus[gunIndex] == 0xFF) {
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(curGun);
|
|
|
- pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
+ pDcChargingInfo->IsAvailable ? (pDcChargingInfo->SystemStatus = S_IDLE) : (pDcChargingInfo->SystemStatus = S_MAINTAIN);
|
|
|
+
|
|
|
} else {
|
|
|
pSysInfo->CurGunSelected = gunIndex;
|
|
|
}
|
|
|
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
|
|
|
- if (pDcChargingInfo->SystemStatus == S_IDLE) {
|
|
|
+ if (pDcChargingInfo->SystemStatus == S_IDLE || pDcChargingInfo->SystemStatus == S_MAINTAIN) {
|
|
|
stopChg++;
|
|
|
}
|
|
|
}
|
|
@@ -970,14 +1119,14 @@ void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
pDcChargingInfo->PresentChargingPower = 0;
|
|
|
|
|
|
if (stopChg == pSysConfig->TotalConnectorCount) {
|
|
|
- ShmDcCommonData->debugflag = NO;
|
|
|
system("/root/Module_EvComm &");
|
|
|
+ ShmFanModuleData->TestFanSpeed = 0;
|
|
|
+ ShmDcCommonData->debugflag = NO;
|
|
|
sleep(3);
|
|
|
|
|
|
for (_GunIndex = 0; _GunIndex < pSysConfig->TotalConnectorCount; _GunIndex++) {
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
|
|
|
-
|
|
|
- pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
+ pDcChargingInfo->IsAvailable ? (pDcChargingInfo->SystemStatus = S_IDLE) : (pDcChargingInfo->SystemStatus = S_MAINTAIN);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -1127,16 +1276,20 @@ static void resdGunAndChillerTemp(void)
|
|
|
|
|
|
pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
|
|
|
- printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d, %3d, %3d, %3d\r\n",
|
|
|
+ printTimeMsg("get gun %d temp = %3d, chiller = %3d, ConnTemp = %3d, %3d,SysTemp = %3d(%.3f), %3d(%.3f), %3d(%.3f), %3d(%.3f)\r\n",
|
|
|
i,
|
|
|
pDcChargingInfo->ConnectorTemp,
|
|
|
pDcChargingInfo->ChillerTemp,
|
|
|
ShmDcCommonData->ConnectorTemp[i][0],
|
|
|
ShmDcCommonData->ConnectorTemp[i][1],
|
|
|
ShmDcCommonData->SystemTemp[0],
|
|
|
+ ShmDcCommonData->TempVolt[0],
|
|
|
ShmDcCommonData->SystemTemp[1],
|
|
|
+ ShmDcCommonData->TempVolt[1],
|
|
|
ShmDcCommonData->SystemTemp[2],
|
|
|
- ShmDcCommonData->SystemTemp[3]);
|
|
|
+ ShmDcCommonData->TempVolt[2],
|
|
|
+ ShmDcCommonData->SystemTemp[3],
|
|
|
+ ShmDcCommonData->TempVolt[3]);
|
|
|
}//for
|
|
|
ftime(&showTime);
|
|
|
}
|
|
@@ -1258,6 +1411,27 @@ void setSystemTime(char* date,char* time)
|
|
|
system("hwclock -w -u");
|
|
|
system("hwclock -s");
|
|
|
}
|
|
|
+static uint8_t getMaxConnectTemp(uint8_t headTemp1, uint8_t headTemp2)
|
|
|
+{
|
|
|
+ uint8_t maxTemp = 0;
|
|
|
+
|
|
|
+ if (headTemp1 > TEMP_BOUNDARY &&
|
|
|
+ headTemp2 > TEMP_BOUNDARY) {
|
|
|
+ return UNDEFINED_TEMP;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (headTemp1 <= TEMP_BOUNDARY) {
|
|
|
+ maxTemp = headTemp1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (headTemp2 <= TEMP_BOUNDARY) {
|
|
|
+ if (headTemp2 > maxTemp) {
|
|
|
+ maxTemp = headTemp2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return maxTemp;
|
|
|
+}
|
|
|
+
|
|
|
static void writeGunAndChillerTemp(void)
|
|
|
{
|
|
|
uint8_t _GunIndex = 0;
|
|
@@ -1298,31 +1472,59 @@ static void writeGunAndChillerTemp(void)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (atoi(newString[2]) > 255 ||
|
|
|
+ if (strcmp(newString[0], "chiller") == 0) {
|
|
|
+ if (atoi(newString[2]) > 255 ||
|
|
|
+ atoi(newString[2]) == -1 ||
|
|
|
+ atoi(newString[3]) > 255 ||
|
|
|
+ atoi(newString[3]) == -1 ||
|
|
|
+ atoi(newString[4]) > 255 ||
|
|
|
+ atoi(newString[4]) == -1 ||
|
|
|
+ atoi(newString[5]) > 255 ||
|
|
|
+ atoi(newString[5]) == -1) {
|
|
|
+ printf("temperature value overflow\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (atoi(newString[2]) > 255 ||
|
|
|
atoi(newString[2]) == -1) {
|
|
|
- printf("temperature value overflow\r\n");
|
|
|
- continue;
|
|
|
+ printf("temperature value overflow\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
_GunIndex = atoi((char *)newString[1]);
|
|
|
-
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
|
|
|
if (_GunIndex >= pSysConfig->TotalConnectorCount) {
|
|
|
printf("gun index over total connector\r\n");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (strcmp(newString[0], "chiller") == 0) {//修改水冷機溫度值
|
|
|
- if (_GunIndex >= 1) {
|
|
|
- _GunIndex = 0; //只會有一個水冷機
|
|
|
+ if (ShmDcCommonData->pGunInfo[_GunIndex].withChiller) {
|
|
|
+ ShmDcCommonData->SystemTemp[0] = atoi(newString[2]);
|
|
|
+ ShmDcCommonData->SystemTemp[1] = atoi(newString[3]);
|
|
|
+ ShmDcCommonData->SystemTemp[2] = atoi(newString[4]);
|
|
|
+ ShmDcCommonData->SystemTemp[3] = atoi(newString[5]);
|
|
|
+ for(int i = 0 ; i < pSysConfig->TotalConnectorCount ; i++) {
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(i);
|
|
|
+ if (!ShmDcCommonData->pGunInfo[i].withChiller)
|
|
|
+ continue;
|
|
|
+ if (i == LEFT_GUN_NUM) {
|
|
|
+ pDcChargingInfo->ChillerTemp = getMaxConnectTemp(ShmDcCommonData->SystemTemp[0],ShmDcCommonData->SystemTemp[1]);
|
|
|
+ } else {
|
|
|
+ pDcChargingInfo->ChillerTemp = getMaxConnectTemp(ShmDcCommonData->SystemTemp[2],ShmDcCommonData->SystemTemp[3]);
|
|
|
+ }
|
|
|
+ printf("set %d chiller temperature = %d\r\n",
|
|
|
+ i,
|
|
|
+ pDcChargingInfo->ChillerTemp);
|
|
|
+ }
|
|
|
+ //memset((char*)ShmDcCommonData->SystemTemp, atoi(newString[2]), sizeof(ShmDcCommonData->SystemTemp));
|
|
|
+
|
|
|
+ } else {
|
|
|
+ printf("This Gun without Chiller\r\n");
|
|
|
}
|
|
|
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
|
|
|
- pDcChargingInfo->ChillerTemp = atoi(newString[2]);
|
|
|
- printf("set %d chiller temperature = %d\r\n",
|
|
|
- _GunIndex,
|
|
|
- pDcChargingInfo->ChillerTemp);
|
|
|
} else if (strcmp(newString[0], "conn") == 0) {//修改槍頭溫度值
|
|
|
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(_GunIndex);
|
|
|
|
|
|
pDcChargingInfo->ConnectorTemp = atoi(newString[2]);
|
|
|
printf("set %d connector temp = %d\r\n",
|
|
@@ -1333,15 +1535,95 @@ static void writeGunAndChillerTemp(void)
|
|
|
usleep(sleepTime);
|
|
|
}//while
|
|
|
}
|
|
|
+
|
|
|
+void setledcolor(int on_off)
|
|
|
+{
|
|
|
+ if (on_off)
|
|
|
+ ShmDcCommonData->pTest.ledflag = TRUE;
|
|
|
+ else {
|
|
|
+ ShmDcCommonData->pTest.ledflag = FALSE;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int isContinue = 1;
|
|
|
+ uint32_t sleepTime = 500000;
|
|
|
+ uint32_t color_value;
|
|
|
+ char* usageMsg = "Usage:\n"
|
|
|
+ " r 0~100\n"
|
|
|
+ " g 0~100\n"
|
|
|
+ " b 0~100\n"
|
|
|
+ " exit | c | C\n"
|
|
|
+ " help | ? | h\n"
|
|
|
+ "\r\n";
|
|
|
+
|
|
|
+ while (isContinue) {
|
|
|
+ if (readCmdKey(CMD_KEY_WAIT) == NO) {
|
|
|
+ sleep(sleepTime);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (helpCmd() == YES) {
|
|
|
+ printf("%s\n", usageMsg);
|
|
|
+ continue;
|
|
|
+ } else if (exitCmd() == YES) {
|
|
|
+ ShmDcCommonData->pTest.ledflag = FALSE;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((strcmp(newString[0], "r") != 0) &&
|
|
|
+ (strcmp(newString[1], "-1") == 0 ||
|
|
|
+ strcmp(newString[1], "") == 0)
|
|
|
+ ) {
|
|
|
+ printf("argc 1 is error parameter\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ((strcmp(newString[0], "g") != 0) &&
|
|
|
+ (strcmp(newString[1], "-1") == 0 ||
|
|
|
+ strcmp(newString[1], "") == 0)
|
|
|
+ ) {
|
|
|
+ printf("argc 1 is error parameter\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if ((strcmp(newString[0], "b") != 0) &&
|
|
|
+ (strcmp(newString[1], "-1") == 0 ||
|
|
|
+ strcmp(newString[1], "") == 0)
|
|
|
+ ) {
|
|
|
+ printf("argc 1 is error parameter\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (atoi(newString[1]) < 0 || atoi(newString[1]) > 100) {
|
|
|
+ printf("argc 1 is error parameter range is 0~100\r\n");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (strcmp(newString[0], "r") == EQUAL &&
|
|
|
+ atoi(newString[1]) >= 0 && atoi(newString[1]) <= 100) {
|
|
|
+ pSysConfig->LedInfo.Red[0] = atoi(newString[1]);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ if (strcmp(newString[0], "g") == EQUAL &&
|
|
|
+ atoi(newString[1]) >= 0 && atoi(newString[1]) <= 100) {
|
|
|
+ pSysConfig->LedInfo.Green[0] = atoi(newString[1]);
|
|
|
+ }
|
|
|
+ if (strcmp(newString[0], "b") == EQUAL &&
|
|
|
+ atoi(newString[1]) >= 0 && atoi(newString[1]) <= 100) {
|
|
|
+ pSysConfig->LedInfo.Blue[0] = atoi(newString[1]);
|
|
|
+ }
|
|
|
+ printf("Color set red[%d] green[%d] blue[%d]\n", pSysConfig->LedInfo.Red[0], pSysConfig->LedInfo.Green[0], pSysConfig->LedInfo.Blue[0]);
|
|
|
+
|
|
|
+ usleep(sleepTime);
|
|
|
+ }//while
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ShmDcCommonData->pTest.ledflag = FALSE;
|
|
|
+}
|
|
|
+
|
|
|
void ShowPowerConsumption(char* v1)
|
|
|
{
|
|
|
printf("Dispenser Gun0 PowerConsumption:%.4f\n", ShmDcCommonData->pGunInfo[0].PowerConsumption);
|
|
|
printf("Dispenser Gun1 PowerConsumption:%.4f\n", ShmDcCommonData->pGunInfo[1].PowerConsumption);
|
|
|
|
|
|
- printf("Power Consumption Gun1:%.4f, Gun2:%.4f, Gun3:%.4f, Gun4:%.4f", ShmDcCommonData->pConsumption.Gun1_Consumption,
|
|
|
- ShmDcCommonData->pConsumption.Gun2_Consumption,
|
|
|
- ShmDcCommonData->pConsumption.Gun3_Consumption,
|
|
|
- ShmDcCommonData->pConsumption.Gun4_Consumption);
|
|
|
}
|
|
|
int main(void)
|
|
|
{
|
|
@@ -1354,7 +1636,7 @@ int main(void)
|
|
|
" lock <index> : get gun locked state\n"
|
|
|
" sysid : test system ID\n"
|
|
|
" self : self test state (x)\n"
|
|
|
- " version | v | -v : version of board (407 or relay or other)\n"
|
|
|
+ " ver| v | -v : version of board (407 or relay or other)\n"
|
|
|
" update : update firmware\n"
|
|
|
" ac : get ac relay state (x) \n"
|
|
|
" cable <index> <state> : set ground fault state\n"
|
|
@@ -1367,10 +1649,10 @@ int main(void)
|
|
|
" tempW : write connector header and Chiller temperature\r\n"
|
|
|
" tempR : print connector header and chiller temperature\r\n"
|
|
|
" OTP : Write OTP temperature\r\n"
|
|
|
- " chiller : set chiller on/off\r\n"
|
|
|
" netdump : show network package\r\n"
|
|
|
" candump : show can package\r\n"
|
|
|
" powerconsumption : Show Power Consumption\n"
|
|
|
+ " led : set led color\n"
|
|
|
"\r\n";
|
|
|
|
|
|
if (CreateAllCsuShareMemory() == FAIL) {
|
|
@@ -1442,7 +1724,7 @@ int main(void)
|
|
|
} else if (strcmp(newString[0], "self") == 0) {
|
|
|
// CSU 自我檢測狀態
|
|
|
RunSelfProc(newString[1]);
|
|
|
- } else if (strcmp(newString[0], "version") == 0 ||
|
|
|
+ } else if (strcmp(newString[0], "ver") == 0 ||
|
|
|
strcmp(newString[0], "v") == 0 ||
|
|
|
strcmp(newString[0], "-v") == 0) {
|
|
|
//if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0) {
|
|
@@ -1541,8 +1823,8 @@ int main(void)
|
|
|
resdGunAndChillerTemp();
|
|
|
} else if (strcmp(newString[0], "OTP") == 0) { //測試槍頭和水冷機溫度
|
|
|
writeOTPTemp();
|
|
|
- } else if (strcmp(newString[0], "chiller") == 0) { //測試槍頭和水冷機溫度
|
|
|
- writeChillerStatus(newString[1]);
|
|
|
+// } else if (strcmp(newString[0], "chiller") == 0) { //測試槍頭和水冷機溫度
|
|
|
+// writeChillerStatus(newString[1]);
|
|
|
} else if (strcmp(newString[0], "netdump") == 0) { //印出網路封包
|
|
|
showNetworkPage(newString[1]);
|
|
|
} else if (strcmp(newString[0], "candump") == 0) { //印出網路封包
|
|
@@ -1551,6 +1833,18 @@ int main(void)
|
|
|
setSystemTime(newString[1], newString[2]);
|
|
|
} else if (strcmp(newString[0], "powerconsumption") == 0) { // Power Consumption
|
|
|
ShowPowerConsumption(newString[1]);
|
|
|
+ } else if (strcmp(newString[0], "led") == 0) { // LED
|
|
|
+ setledcolor(newString[1]);
|
|
|
+ } else if (strcmp(newString[0], "btnl") == 0) {
|
|
|
+ ShmPrimaryMcuData->InputDet.bits.Button1 = BTN_PRESS;
|
|
|
+ sleep(1);
|
|
|
+ ShmPrimaryMcuData->InputDet.bits.Button1 = BTN_RELEASE;
|
|
|
+ } else if (strcmp(newString[0], "btnr") == 0) {
|
|
|
+ ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_PRESS;
|
|
|
+ sleep(1);
|
|
|
+ ShmPrimaryMcuData->InputDet.bits.Button2 = BTN_RELEASE;
|
|
|
+ } else if (strcmp(newString[0], "DcMeter") == 0) {
|
|
|
+
|
|
|
} else {
|
|
|
printf("%s\n", usageMsg);
|
|
|
}
|