|
@@ -1124,7 +1124,7 @@ void GetPsuInformation(char *v1, char *v2, char *v3)
|
|
|
}
|
|
|
else if(strcmp(v1, "ver") == 0)
|
|
|
{
|
|
|
- for (int i = 0; i < ShmPsuData->SystemPresentPsuQuantity; i++)
|
|
|
+ for (int i = 0; i < ShmPsuData->SystemInitialPsuQuantity; i++)
|
|
|
{
|
|
|
printf("Psu Index = %d, PriVersion = %s, SecVersion = %s \n",
|
|
|
i, ShmPsuData->PsuVersion[i].FwPrimaryVersion, ShmPsuData->PsuVersion[i].FwSecondVersion);
|
|
@@ -1218,539 +1218,6 @@ void GetConnectorCapInfo(char *v1)
|
|
|
_chargingData[_GunIndex]->RealMaxCurrent);
|
|
|
}
|
|
|
|
|
|
-void RunUnconditionalChargeIndex1(char *v1, char *v2, char *v3)
|
|
|
-{
|
|
|
- int _GunIndex = atoi(v1);
|
|
|
- float _Voltage = atof(v2);
|
|
|
- float _Current = atof(v3);
|
|
|
- unsigned char PreviousSystemStatus = 0xff;
|
|
|
-
|
|
|
- if (!FindChargingInfoData(_GunIndex, &_chargingData[0]))
|
|
|
- {
|
|
|
- printf ("FindChargingInfoData error\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- printf ("ReqVoltage = %f, ReqCurrent = %f\n", _Voltage, _Current);
|
|
|
-
|
|
|
- if(_Voltage > 1000 || _Voltage < 50)
|
|
|
- {
|
|
|
- printf ("Input Voltage over range\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-// if(_Current > 100 || _Current < 2){
|
|
|
-//
|
|
|
-// printf ("Input Current over range\n");
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
- //測試期間先跳過自我測試 _STEST_COMPLETE = 0xfe
|
|
|
- //ShmSysConfigAndInfo->SysInfo.SelfTestSeq = 0xfe;
|
|
|
-
|
|
|
- //kill ev task
|
|
|
- system("killall Module_EvComm");
|
|
|
-
|
|
|
- //_Voltage = (_Voltage * 10);
|
|
|
- //_Current = (_Current * 10);
|
|
|
-
|
|
|
- //system(STTY_US TTY_PATH);
|
|
|
-
|
|
|
- while(true)
|
|
|
- {
|
|
|
- //fix gun 1
|
|
|
- ShmSysConfigAndInfo->SysInfo.CurGunSelected = _GunIndex;
|
|
|
-
|
|
|
- switch(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- case S_IDLE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_IDLE]\n");
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x01;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARNING;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case S_PREPARNING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_PREPARNIN]\n");
|
|
|
-
|
|
|
- //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
|
|
|
- printf ("wait find module\n");
|
|
|
-
|
|
|
- }
|
|
|
- //main 會在此階段判斷以下資料跳到下一個 state
|
|
|
- //用來得知 AC 是否有搭上 (搭上模組的資訊才會出來) 因為每次 AC_Contactor
|
|
|
-
|
|
|
-
|
|
|
- //ShmPsuData->SystemPresentPsuQuantity;
|
|
|
- //ShmPsuData->PsuGroup[gun_index].GroupPresentPsuQuantity;
|
|
|
- //ShmPsuData->PsuGroup[gun_index].GroupAvailablePower;
|
|
|
- //_chargingData[gun_index]->AvailableChargingPower;
|
|
|
-
|
|
|
- //等待 AC Relay 搭上且找到模組 (main 在此 statue 其它 task 會去做完)
|
|
|
- //sleep(10);
|
|
|
-
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_PREPARING_FOR_EV:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_PREPARING_FOR_EV]\n");
|
|
|
- printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage * 10,_Current * 10);
|
|
|
-
|
|
|
- }
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
|
- //確定模組己升壓完成
|
|
|
- //if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage <= (3000+500) &&
|
|
|
- // _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage >= (3000-500) )
|
|
|
- {
|
|
|
- printf ("Precharge Done = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
|
|
|
- //EV done
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_PREPARING_FOR_EVSE;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
-
|
|
|
- case S_PREPARING_FOR_EVSE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_PREPARING_FOR_EVSE]\n");
|
|
|
-
|
|
|
- }
|
|
|
- //printf ("tar vol = %d \n", _Voltage);
|
|
|
- //printf ("tar cur = %d \n", _Current);
|
|
|
-
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->Type = 9;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = 500;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = 2;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- //printf ("tar vol_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage);
|
|
|
- // printf ("tar cur_ = %d \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent);
|
|
|
-
|
|
|
- //****** 注意~此行為是防止 K1K2 先開導到無法升壓 ( Relay Board 在此 state 還未搭上 K1K2 )
|
|
|
- //確定模組己升壓完成
|
|
|
- //if(_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x01 ||
|
|
|
- // _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x03)
|
|
|
- //{
|
|
|
- //printf ("First Ground Fault State (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
- printf ("Wait K1K2 = %f \n", _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage);
|
|
|
- sleep(5);
|
|
|
- //EV done
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_CHARGING;
|
|
|
- //}
|
|
|
- //else if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus > 0x02)
|
|
|
- //{
|
|
|
- // printf ("First Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
- // _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
- //}
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_CHARGING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterySoc = 50;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _Voltage;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _Current;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_CHARGING]\n");
|
|
|
- }
|
|
|
-
|
|
|
- //ev task do this
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingPower =
|
|
|
- ((float)((_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingVoltage) * (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->PresentChargingCurrent)) / 1000);
|
|
|
-
|
|
|
- if (_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus == 0x02){
|
|
|
- printf ("Charging Ground Fault check Fail (%d)\n",_chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->GroundFaultStatus);
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_TERMINATING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
- system("/root/Module_EvComm &");
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_TERMINATING]\n");
|
|
|
- //無阻塞偵測 keybaord 結束
|
|
|
- system(STTY_DEF TTY_PATH);
|
|
|
- }
|
|
|
-
|
|
|
- sleep(3);
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_COMPLETE;
|
|
|
- return;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_COMPLETE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus != _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus = _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge - S_COMPLETE]\n");
|
|
|
- }
|
|
|
- sleep(3);
|
|
|
- return;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- char word[128];
|
|
|
- char newString[7][10];
|
|
|
- int i,j,ctr;
|
|
|
-
|
|
|
- memset(word, 0x00, sizeof(word));
|
|
|
- get_char(word);
|
|
|
-
|
|
|
- if (strlen(word) == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- j=0; ctr=0;
|
|
|
- strcpy(newString[1], "-1");
|
|
|
- strcpy(newString[2], "-1");
|
|
|
- for (i = 0; i <= (strlen(word)); i++)
|
|
|
- {
|
|
|
- if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
|
|
|
- {
|
|
|
- newString[ctr][j] = '\0';
|
|
|
- ctr++;
|
|
|
- j = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- newString[ctr][j] = word[i];
|
|
|
- j++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(strcmp(newString[0], "chg") == 0)
|
|
|
- {
|
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
|
|
|
- continue;
|
|
|
- if (strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
|
|
|
- continue;
|
|
|
-
|
|
|
- float _vol = atof(newString[1]);
|
|
|
- float _cur = atof(newString[2]);
|
|
|
-
|
|
|
- if (_cur <= 0 || _cur <= 0)
|
|
|
- continue;
|
|
|
-
|
|
|
- printf("vol = %f, cur = %f \n", _vol, _cur);
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetVoltage = _vol;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->EvBatterytargetCurrent = _cur;
|
|
|
- }
|
|
|
- else if (strcmp(newString[0], "c") == 0)
|
|
|
- {
|
|
|
- printf("stop \n\r");
|
|
|
- ShmSysConfigAndInfo->SysInfo.StartToChargingFlag = 0x00;
|
|
|
- _chargingData[ShmSysConfigAndInfo->SysInfo.CurGunSelected]->SystemStatus = S_TERMINATING;
|
|
|
- }
|
|
|
-
|
|
|
- usleep(100000);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void RunUnconditionalCharge(char *v1, char *v2, char *v3, char *v4)
|
|
|
-{
|
|
|
- float _Voltage[2], _Current[2];
|
|
|
-
|
|
|
- _Voltage[0] = atof(v1);
|
|
|
- _Current[0] = atof(v2);
|
|
|
- _Voltage[1] = atof(v3);
|
|
|
- _Current[1] = atof(v4);
|
|
|
-
|
|
|
- unsigned char PreviousSystemStatus[2] = {0xff, 0xff};
|
|
|
-
|
|
|
- if(!FindChargingInfoData(0, &_chargingData[0]))
|
|
|
- {
|
|
|
- printf ("FindChargingInfoData 0 error\n");
|
|
|
- return;
|
|
|
- }
|
|
|
- if(!FindChargingInfoData(1, &_chargingData[0]))
|
|
|
- {
|
|
|
- printf ("FindChargingInfoData 1 error\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- printf ("Gun 1: ReqVoltage = %f, ReqCurrent = %f\n", _Voltage[0], _Current[0]);
|
|
|
- printf ("Gun 2: ReqVoltage = %f, ReqCurrent = %f\n", _Voltage[1], _Current[1]);
|
|
|
-
|
|
|
- if(_Voltage[0] > 1000 || _Voltage[0] < 50 || _Voltage[1] > 1000 || _Voltage[1] < 50)
|
|
|
- {
|
|
|
- printf ("Input Voltage over range\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //kill ev task
|
|
|
- system("killall Module_EvComm");
|
|
|
-
|
|
|
- while(true)
|
|
|
- {
|
|
|
- if(_chargingData[0]->SystemStatus == S_IDLE && _chargingData[1]->SystemStatus == S_IDLE)
|
|
|
- {
|
|
|
- _chargingData[0]->SystemStatus = S_REASSIGN_CHECK;
|
|
|
- _chargingData[1]->SystemStatus = S_REASSIGN_CHECK;
|
|
|
- ShmSysConfigAndInfo->SysInfo.MainChargingMode = _MAIN_CHARGING_MODE_AVER;
|
|
|
- ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_NONE;
|
|
|
- }
|
|
|
-
|
|
|
- if(_chargingData[0]->SystemStatus == S_COMPLETE && _chargingData[1]->SystemStatus == S_COMPLETE)
|
|
|
- {
|
|
|
- system(STTY_DEF TTY_PATH);
|
|
|
- sleep(5);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for(int i = 0; i < 2; i++)
|
|
|
- {
|
|
|
- switch(_chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- case S_IDLE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
- printf ("[UnconditionalCharge (%d) - S_IDLE]\n", i);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_PREPARNING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_PREPARNIN]\n", i);
|
|
|
- printf ("wait find module\n");
|
|
|
- }
|
|
|
-
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[i]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[i]->Type = 9;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_PREPARING_FOR_EV:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_PREPARING_FOR_EV]\n", i);
|
|
|
- printf ("ReqVoltage = %f, ReqCurrent = %f \n", _Voltage[i] * 10,_Current[i] * 10);
|
|
|
- }
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[i]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[i]->Type = 9;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[i]->EvBatterySoc = 50;
|
|
|
- _chargingData[i]->EvBatterytargetVoltage = 500;
|
|
|
- _chargingData[i]->EvBatterytargetCurrent = 2;
|
|
|
- _chargingData[i]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- printf ("Precharge Done = %f \n", _chargingData[i]->PresentChargingVoltage);
|
|
|
- _chargingData[i]->SystemStatus = S_PREPARING_FOR_EVSE;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_PREPARING_FOR_EVSE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_PREPARING_FOR_EVSE]\n", i);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- //清除 main timeout 機制
|
|
|
- _chargingData[i]->TimeoutFlag = 0;
|
|
|
- //不論是什麼 type 的槍都固意設成 Chademo 不跑 Prechage step
|
|
|
- _chargingData[i]->Type = 9;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[i]->EvBatterySoc = 50;
|
|
|
- _chargingData[i]->EvBatterytargetVoltage = 500;
|
|
|
- _chargingData[i]->EvBatterytargetCurrent = 2;
|
|
|
- _chargingData[i]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- printf ("Wait K1K2 = %f \n", _chargingData[i]->PresentChargingVoltage);
|
|
|
- sleep(5);
|
|
|
- //EV done
|
|
|
- _chargingData[i]->SystemStatus = S_CHARGING;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_CHARGING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
-
|
|
|
- //充電電壓電流
|
|
|
- _chargingData[i]->EvBatterySoc = 50;
|
|
|
- _chargingData[i]->EvBatterytargetVoltage = _Voltage[i];
|
|
|
- _chargingData[i]->EvBatterytargetCurrent = _Current[i];
|
|
|
- _chargingData[i]->AvailableChargingCurrent = 1000;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_CHARGING]\n", i);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_TERMINATING:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
- system("/root/Module_EvComm &");
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_TERMINATING]\n", i);
|
|
|
- }
|
|
|
-
|
|
|
- sleep(3);
|
|
|
- _chargingData[i]->SystemStatus = S_COMPLETE;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case S_COMPLETE:
|
|
|
- {
|
|
|
- if(PreviousSystemStatus[i] != _chargingData[i]->SystemStatus)
|
|
|
- {
|
|
|
- PreviousSystemStatus[i] = _chargingData[i]->SystemStatus;
|
|
|
-
|
|
|
- printf ("[UnconditionalCharge (%d) - S_COMPLETE]\n", i);
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- char word[128];
|
|
|
- char newString[7][10];
|
|
|
- int i,j,ctr;
|
|
|
-
|
|
|
- memset(word, 0x00, sizeof(word));
|
|
|
- get_char(word);
|
|
|
-
|
|
|
- if (strlen(word) == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- j=0; ctr=0;
|
|
|
- strcpy(newString[1], "-1");
|
|
|
- strcpy(newString[2], "-1");
|
|
|
- for (i = 0; i <= (strlen(word)); i++)
|
|
|
- {
|
|
|
- if (word[i] == ' ' || word[i] == '\0' || word[i] == 10)
|
|
|
- {
|
|
|
- newString[ctr][j] = '\0';
|
|
|
- ctr++;
|
|
|
- j = 0;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- newString[ctr][j] = word[i];
|
|
|
- j++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(strcmp(newString[0], "chg") == 0)
|
|
|
- {
|
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0)
|
|
|
- continue;
|
|
|
- if (strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
|
|
|
- continue;
|
|
|
- if (strcmp(newString[3], "-1") == 0 || strcmp(newString[3], "") == 0)
|
|
|
- continue;
|
|
|
-
|
|
|
- int _gun = atoi(newString[1]);
|
|
|
- float _vol = atof(newString[2]);
|
|
|
- float _cur = atof(newString[3]);
|
|
|
-
|
|
|
- if(_gun >= 2 || _gun < 0)
|
|
|
- continue;
|
|
|
- if (_cur <= 0 || _cur <= 0)
|
|
|
- continue;
|
|
|
-
|
|
|
- printf("gun %d: vol = %f, cur = %f \n", _gun + 1, _vol, _cur);
|
|
|
- _chargingData[_gun]->EvBatterytargetVoltage = _vol;
|
|
|
- _chargingData[_gun]->EvBatterytargetCurrent = _cur;
|
|
|
- }
|
|
|
- else if (strcmp(newString[0], "c") == 0)
|
|
|
- {
|
|
|
- printf("stop \n\r");
|
|
|
- _chargingData[0]->SystemStatus = S_TERMINATING;
|
|
|
- _chargingData[1]->SystemStatus = S_TERMINATING;
|
|
|
- }
|
|
|
-
|
|
|
- usleep(100000);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void SetWiringInfo(char *v1, char *v2)
|
|
|
{
|
|
|
int dispenser = atoi(v1);
|
|
@@ -2828,17 +2295,41 @@ void SetGunStartCharging(char *inputCmd, unsigned int opt, unsigned char isWeb)
|
|
|
printf("\r\n");
|
|
|
}
|
|
|
|
|
|
+void GenerateManualStop(int gunIndex, bool isAlarm, char *alarmCode)
|
|
|
+{
|
|
|
+ if(isAlarm)
|
|
|
+ {
|
|
|
+ if(!_chargingData[gunIndex]->ChargingStopFlag.bits.AlarmStop)
|
|
|
+ {
|
|
|
+ if(strncmp((char *)_chargingData[gunIndex]->ConnectorAlarmCode, "", 6) == EQUAL)
|
|
|
+ {
|
|
|
+ memcpy((char *)_chargingData[gunIndex]->ConnectorAlarmCode, alarmCode, 6);
|
|
|
+ }
|
|
|
+ _chargingData[gunIndex]->ChargingStopFlag.bits.AlarmStop = true;
|
|
|
+ printf("Set Gun %d Stop Charging(ManualAlarm)\r\n", gunIndex + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(!_chargingData[gunIndex]->ChargingStopFlag.bits.ManualStop)
|
|
|
+ {
|
|
|
+ _chargingData[gunIndex]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
+ printf("Set Gun %d Stop Charging(ManualStop)\r\n", gunIndex + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// v1: gun
|
|
|
void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
{
|
|
|
int totalCnt = 0, maxPara = 0;
|
|
|
|
|
|
- maxPara = 1;
|
|
|
+ maxPara = 2;
|
|
|
totalCnt = GetSubCommand(inputCmd);
|
|
|
|
|
|
- if(totalCnt < maxPara)
|
|
|
+ if(totalCnt > maxPara || totalCnt == 0)
|
|
|
{
|
|
|
- printf("Input cmd fail ------ gunchg [gun 1-4]\r\n\r\n");
|
|
|
+ printf("Input cmd fail ------ gunstp [gun 1-4] [status code]\r\n\r\n");
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -2854,6 +2345,19 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ bool isAlarmStop = false;
|
|
|
+ char manualAlarm[7];
|
|
|
+
|
|
|
+ if(totalCnt == 2)
|
|
|
+ {
|
|
|
+ if((strlen(&MultiSubCmd[1][0]) == 6) && atoi(&MultiSubCmd[1][0]) != 0)
|
|
|
+ {
|
|
|
+ memset(manualAlarm, 0x00, sizeof(manualAlarm));
|
|
|
+ memcpy(manualAlarm, &MultiSubCmd[1][0], 6);
|
|
|
+ isAlarmStop = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
bool wait = true;
|
|
|
int time = 0;
|
|
|
struct timespec _Wait_time;
|
|
@@ -2895,11 +2399,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_REASSIGN_CHECK, Wait For Request Charging\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2909,11 +2409,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_REASSIGN, Wait For Grouping\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2923,11 +2419,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_PREPARNING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2937,11 +2429,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_PREPARING_FOR_EV\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2951,11 +2439,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_PREPARING_FOR_EVSE, Wait For EVSE\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -2965,11 +2449,7 @@ void SetGunStopCharging(char *inputCmd, unsigned int opt)
|
|
|
printf("Gun %d S_CHARGING\r\n", gun);
|
|
|
PreviousSystemStatus = _chargingData[gun - 1]->SystemStatus;
|
|
|
|
|
|
- if(!_chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop)
|
|
|
- {
|
|
|
- _chargingData[gun - 1]->ChargingStopFlag.bits.ManualStop = true;
|
|
|
- printf("Set Gun %d Stop Charging(ManualStop)\r\n", gun);
|
|
|
- }
|
|
|
+ GenerateManualStop(gun - 1, isAlarmStop, manualAlarm);
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -3178,7 +2658,7 @@ void ShowStatus(void)
|
|
|
}
|
|
|
printf("\r\n");
|
|
|
|
|
|
- printf("\r\nPower Cabinet Role: %s, Switch Value: %d",
|
|
|
+ printf("\r\nPower Cabinet Role: %s, Switch Value: %d, ",
|
|
|
ShmChargerInfo->Control.CabinetSwitch <= _CROLE_SLAVE ? str_cabinet_role[ShmChargerInfo->Control.CabinetSwitch] : "Unknown",
|
|
|
ShmChargerInfo->Control.CabinetSwitch);
|
|
|
printf("\r\nStatus Code Len = %d", ShmSysConfigAndInfo->SysWarningInfo.WarningCount);
|
|
@@ -5078,13 +4558,18 @@ void RelayReadCmd(char *inputCmd, unsigned int opt)
|
|
|
|
|
|
}
|
|
|
|
|
|
+void RelayStatusCmd(char *inputCmd, unsigned int opt)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
void OutputRelayAutoTest(void)
|
|
|
{
|
|
|
int MaxGunCount = 0;
|
|
|
struct timespec _Loop_time;
|
|
|
int time = 0;
|
|
|
|
|
|
- MaxGunCount = MAX_GUN_QUANTITY;
|
|
|
+ MaxGunCount = ShmChargerInfo->Control.MaxConnector;
|
|
|
|
|
|
for(int i = 0; i < MaxGunCount; i++)
|
|
|
{
|
|
@@ -5172,7 +4657,14 @@ void ParallelRelayAutoTest(void)
|
|
|
struct timespec _Loop_time;
|
|
|
int time = 0;
|
|
|
|
|
|
- ParallelRelayCount = PARALLEL_RELAY_COUNT;
|
|
|
+ if(ShmChargerInfo->Control.MaxConnector == GENERAL_GUN_QUANTITY)
|
|
|
+ {
|
|
|
+ ParallelRelayCount = ShmChargerInfo->Control.SysCtrl.bits.Enable6ParallelRelay == 1 ? PARALLEL_RELAY_COUNT : 3;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ParallelRelayCount = 1;
|
|
|
+ }
|
|
|
|
|
|
for(int i = 0; i < ParallelRelayCount; i++)
|
|
|
{
|
|
@@ -5265,6 +4757,12 @@ void RelayCmd(char *inputCmd, unsigned int opt)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if(strcmp(subMain, "status") == EQUAL)
|
|
|
+ {
|
|
|
+ RelayStatusCmd(subSub, opt);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if(strcmp(subMain, "autotest") == EQUAL)
|
|
|
{
|
|
|
RelayAutoTest(subSub);
|
|
@@ -5637,36 +5135,6 @@ int main(void)
|
|
|
{
|
|
|
GetOrClearId(newString[1]);
|
|
|
}
|
|
|
-#if 0
|
|
|
- else if(strcmp(newString[0], "strchg") == 0)
|
|
|
- {
|
|
|
- //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
|
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
|
|
|
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0)
|
|
|
- {
|
|
|
- printf ("Input cmd fail ------ strchg [vol 150-1000] [cru 2-100]\n");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 槍狀態
|
|
|
- RunUnconditionalChargeIndex1(newString[1], newString[2], newString[3]);
|
|
|
- }
|
|
|
- else if(strcmp(newString[0], "str2chg") == 0)
|
|
|
- {
|
|
|
- //如果連一個參數都沒有 (此命令不理會) 加上判斷第二參數
|
|
|
- if (strcmp(newString[1], "-1") == 0 || strcmp(newString[1], "") == 0 ||
|
|
|
- strcmp(newString[2], "-1") == 0 || strcmp(newString[2], "") == 0 ||
|
|
|
- strcmp(newString[3], "-1") == 0 || strcmp(newString[3], "") == 0 ||
|
|
|
- strcmp(newString[4], "-1") == 0 || strcmp(newString[4], "") == 0)
|
|
|
- {
|
|
|
- printf ("Input cmd fail ------ strchg [vol 150-1000] [cru 2-100]\n");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- // 槍狀態
|
|
|
- RunUnconditionalCharge(newString[1], newString[2], newString[3], newString[4]);
|
|
|
- }
|
|
|
-#endif
|
|
|
else if(strcmp(newString[0], "wiring") == 0)
|
|
|
{
|
|
|
if(strcmp(newString[1], "-1") != 0 && strcmp(newString[1], "") != 0 &&
|