123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #include <sys/time.h>
- #include <sys/timeb.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <sys/ioctl.h>
- #include <sys/socket.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <sys/shm.h>
- #include <sys/mman.h>
- #include <linux/wireless.h>
- #include <arpa/inet.h>
- #include <netinet/in.h>
- #include <unistd.h>
- #include <stdarg.h>
- #include <stdio.h> /*標準輸入輸出定義*/
- #include <stdlib.h> /*標準函數庫定義*/
- #include <stdint.h>
- #include <unistd.h> /*Unix 標準函數定義*/
- #include <fcntl.h> /*檔控制定義*/
- #include <termios.h> /*PPSIX 終端控制定義*/
- #include <errno.h> /*錯誤號定義*/
- #include <errno.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #include <ifaddrs.h>
- #include <math.h>
- #include <stdbool.h>
- #include "./ShareMemory/shmMem.h"
- #include "./Define/define.h"
- #include "./SelectGun/SelectGun.h"
- #include "Config.h"
- #include "simulation.h"
- static struct SysConfigData *pSysConfig = NULL;
- static struct SysInfoData *pSysInfo = NULL;
- static struct FaultCodeData *pFaultCode = NULL;
- static struct AlarmCodeData *pAlarmCode = NULL;
- static struct CHAdeMOData *ShmCHAdeMOData = NULL;
- static struct GBTData *ShmGBTData = NULL;
- static struct CcsData *ShmCcsData = NULL;
- static DcCommonInfo *ShmDcCommonData = NULL;
- static SelectGunInfo *ShmSelectGunInfo = NULL;
- struct ChargingInfoData *pDcChargingInfo = NULL;
- static struct WARNING_CODE_INFO *pSysWarning = NULL;
- void SetFaultTest()
- {
- pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning = NO;
- pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault = NO;
- pSysWarning->Level = WARN_LV_NL;
- }
- void SetSelfTest(bool status)
- {
- uint8_t index = 0;
- struct SysConfigData *pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
- struct SysInfoData *pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
- struct WARNING_CODE_INFO *pSysWarning = (struct WARNING_CODE_INFO *)GetShmSysWarningInfo();
- struct PsuData *ShmPsuData = (struct PsuData *)GetShmPsuData();
- struct CHAdeMOData *ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
- struct GBTData *ShmGBTData = (struct GBTData *)GetShmGBTData();
- struct CcsData *ShmCcsData = (struct CcsData *)GetShmCcsData();
- struct PrimaryMcuData *ShmPrimaryMcuData = (struct PrimaryMcuData *)GetShmPrimaryMcuData();
- struct FanModuleData *ShmFanModuleData = (struct FanModuleData *)GetShmFanModuleData();
- struct RelayModuleData *ShmRelayModuleData = (struct RelayModuleData *)GetShmRelayModuleData();
- ShmRelayModuleData->SelfTest_Comp = status;
- if (status) {
- strcpy((char*)pSysInfo->RelayModuleFwRev,SIM_VERSION);
- strcpy((char*)pSysInfo->FanModuleFwRev,SIM_VERSION);
- strcpy((char*)ShmPrimaryMcuData->version,SIM_VERSION);
- for (index = 0; index < pSysConfig->TotalConnectorCount; index++) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(index);
- if (pDcChargingInfo->Type == _Type_Chademo) {
- strcpy((char*)ShmCHAdeMOData->evse[pDcChargingInfo->type_index].version,SIM_VERSION);
- } else if (pDcChargingInfo->Type == _Type_GB) {
- strcpy((char*)ShmGBTData->evse[pDcChargingInfo->type_index].version,SIM_VERSION);
- } else if (pDcChargingInfo->Type == _Type_CCS_2) {
- strcpy((char*)ShmCcsData->V2GMessage_DIN70121[pDcChargingInfo->type_index].version,SIM_VERSION);
- }
- ShmDcCommonData->GunRelayWeldingOccur[index] = false;
- }
- }
- }
- void main()
- {
- uint8_t gunIndex = 0;
- if (CreateAllCsuShareMemory() == FAIL) {
- printf("create share memory error");
- return FAIL;
- }
- MappingGunChargingInfo("Simulation Task");
- pSysConfig = (struct SysConfigData *)GetShmSysConfigData();
- pSysInfo = (struct SysInfoData *)GetShmSysInfoData();
- pAlarmCode = (struct AlarmCodeData *)GetShmAlarmCodeData();
- pFaultCode = (struct FaultCodeData *)GetShmFaultCodeData();
- ShmDcCommonData = (DcCommonInfo *)GetShmDcCommonData();
- ShmCHAdeMOData = (struct CHAdeMOData *)GetShmCHAdeMOData();
- ShmGBTData = (struct GBTData *)GetShmGBTData();
- ShmCcsData = (struct CcsData *)GetShmCcsData();
- ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
- SetSelfTest(SELFTESTRESULT);
- while (1) {
- for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++) {
- pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);
- switch (pDcChargingInfo->SystemStatus) {
- case S_IDLE:
- // Authorizing data
- strcpy((char *)&pSysConfig->UserId, USER_ID);
- break;
- case S_REASSIGN_CHECK:
- break;
- case S_REASSIGN:
- break;
- case S_PREPARNING:
- break;
- case S_PREPARING_FOR_EV:
- break;
- case S_PREPARING_FOR_EVSE:
- break;
- case S_CCS_PRECHARGE_ST0:
- case S_CCS_PRECHARGE_ST1:
- break;
- case S_CHARGING:
- break;
- case S_TERMINATING:
- break;
- case S_COMPLETE:
- break;
- case S_ALARM:
- break;
- case S_FAULT:
- SetFaultTest();
- break;
- case S_RESERVATION:
- break;
- case S_BOOKING:
- break;
- case S_MAINTAIN:
- break;
- case S_DEBUG:
- break;
- case S_UPDATE:
- break;
- }
- }
- usleep(100);
- }
- return;
- }
|