123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- #if 0
- #include <stdio.h> /*標準輸入輸出定義*/
- #include <stdlib.h> /*標準函數庫定義*/
- #include <string.h>
- #include <stdint.h>
- #include "../Config.h"
- #include "../Log/log.h"
- #include "../Define/define.h"
- #include "../ShareMemory/shmMem.h"
- #include "../timeout.h"
- #include "../CSU/main.h"
- #include "SelectGun.h"
- int WaitAuthorPageState(void)
- {
- int ret = FAIL;
- struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
- #if !defined DD360Audi
- return PASS;
- #endif
- if (pSysInfo->SystemPage != _LCM_AUTHORIZING &&
- pSysInfo->SystemPage != _LCM_AUTHORIZ_COMP &&
- pSysInfo->SystemPage != _LCM_AUTHORIZ_FAIL) {
- ret = PASS;
- }
- return ret;
- }
- void destroySelGun(uint8_t curGun)
- {
- uint8_t i = 0;
- #if !defined DD360Audi
- return;
- #endif
- struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
- struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- struct OCPP16Data *ShmOCPP16Data = (struct OCPP16Data *)GetShmOCPP16Data();
-
- if (curGun == DESTROY_ALL_SEL) {
- pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
- pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
- log_info("destroy all gun = %d, %d",
- pSelectGunInfo->SelGunInfo.LeftGun,
- pSelectGunInfo->SelGunInfo.RightGun);
- for (i = 0; i < pSysConfig->TotalConnectorCount; i++) {
- StopGunInfoTimeoutDet(i);
- memset(&pSelectGunInfo->PricesInfo[i], 0, sizeof(PricesInfo));
- }
- pSysInfo->CurGunSelected = 0;
- strcpy((char *)pSysConfig->UserId, "");
-
- return;
- }
-
- if ((curGun == LEFT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.LeftGun != SEL_GUN_RELEASE)) {
- if (pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM ||
- pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR) {
- pSysInfo->SystemPage = _LCM_SELECT_GUN;
- }
- pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_RELEASE;
- StopGunInfoTimeoutDet(LEFT_GUN_NUM);
- if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
- ClearAuthorizedFlag();
- }
- log_info("destroy left gun, cur page = %d", pSysInfo->SystemPage);
-
- log_info("clear left balance");
- memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
- pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
-
- }
- if ((curGun == RIGHT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.RightGun != SEL_GUN_RELEASE)) {
- if (pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM ||
- pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR) {
- pSysInfo->SystemPage = _LCM_SELECT_GUN;
- }
- pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_RELEASE;
- StopGunInfoTimeoutDet(RIGHT_GUN_NUM);
- if (ShmOCPP16Data->SpMsg.bits.AuthorizeConf != NO) {
- ClearAuthorizedFlag();
- }
- log_info("destroy right gun, cur page = %d", pSysInfo->SystemPage);
-
- log_info("clear right balance");
- memset(&pSelectGunInfo->PricesInfo[curGun], 0, sizeof(PricesInfo));
- pSelectGunInfo->PricesInfo[curGun].Balance = FAIL_BALANCE_PRICES;
-
- }
- }
- int waitRightGunPlugIt(uint8_t curGun)
- {
- #if !defined DD360Audi
- return;
- #endif
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- if ((curGun == RIGHT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_ATHOR)) {
- return PASS;
- }
- return FAIL;
- }
- int waitLeftGunPlugIt(uint8_t curGun)
- {
- #if !defined DD360Audi
- return;
- #endif
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- if ((curGun == LEFT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_ATHOR)) {
- return PASS;
- }
- return FAIL;
- }
- void setSelGunWaitToAuthor(uint8_t curSel)
- {
- #if !defined DD360Audi
- return;
- #endif
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- if (curSel == LEFT_GUN_NUM && pSelectGunInfo->SelGunInfo.LeftGun == SEL_GUN_CONFIRM) {
- pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_ATHOR;
-
- StopGunInfoTimeoutDet(curSel);
- } else if (curSel == RIGHT_GUN_NUM && pSelectGunInfo->SelGunInfo.RightGun == SEL_GUN_CONFIRM) {
- pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_ATHOR;
-
- StopGunInfoTimeoutDet(curSel);
- }
- }
- int getConfirmSelectedGun(uint8_t curSel)
- {
- #if !defined DD360Audi
- return;
- #endif
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- if (((curSel == LEFT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.LeftGun >= SEL_GUN_CONFIRM)) ||
- ((curSel == RIGHT_GUN_NUM) && (pSelectGunInfo->SelGunInfo.RightGun >= SEL_GUN_CONFIRM))) {
- return PASS;
- }
- return FAIL;
- }
- void confirmSelGun(uint8_t selGun)
- {
- #if !defined DD360Audi
- return;
- #endif
- struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
- SelectGunInfo *pSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- if (selGun == LEFT_GUN_NUM) {
- pSelectGunInfo->SelGunInfo.LeftGun = SEL_GUN_CONFIRM;
- StopGunInfoTimeoutDet(selGun);
-
- } else if (selGun == RIGHT_GUN_NUM) {
- pSelectGunInfo->SelGunInfo.RightGun = SEL_GUN_CONFIRM;
- StopGunInfoTimeoutDet(selGun);
-
- }
- pSysInfo->SystemPage = _LCM_IDLE;
- StartGunInfoTimeoutDet(selGun, Timeout_SelectGun);
- }
- #endif
|