|
@@ -54,108 +54,6 @@ uint8_t Door_count = 0;
|
|
|
uint8_t EmgBtn_flag = 0;
|
|
|
uint8_t Door_flag = 0;
|
|
|
|
|
|
-//struct ChargingInfoData *ChargingData[CHAdeMO_QUANTITY + CCS_QUANTITY + GB_QUANTITY];
|
|
|
-
|
|
|
-//------------------------------------------------------------------------------
|
|
|
-/*int StoreLogMsg(const char *fmt, ...)
|
|
|
-{
|
|
|
- char Buf[4096 + 256];
|
|
|
- char buffer[4096];
|
|
|
- va_list args;
|
|
|
- struct timeb SeqEndTime;
|
|
|
- struct tm *tm;
|
|
|
-
|
|
|
- va_start(args, fmt);
|
|
|
- int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
|
|
|
- va_end(args);
|
|
|
-
|
|
|
- memset(Buf, 0, sizeof(Buf));
|
|
|
- ftime(&SeqEndTime);
|
|
|
- SeqEndTime.time = time(NULL);
|
|
|
- tm = localtime(&SeqEndTime.time);
|
|
|
-
|
|
|
- if (pSysConfig->SwitchDebugFlag == YES) {
|
|
|
- sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
|
|
|
- tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
|
|
|
- printf("%s ", Buf);
|
|
|
- } else {
|
|
|
- sprintf(Buf, "echo \"%04d-%02d-%02d %02d:%02d:%02d:%03d - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
|
|
|
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm,
|
|
|
- buffer,
|
|
|
- tm->tm_year + 1900, tm->tm_mon + 1);
|
|
|
- system(Buf);
|
|
|
- }
|
|
|
-
|
|
|
- return rc;
|
|
|
-}
|
|
|
-*/
|
|
|
-
|
|
|
-#if 0 //non use
|
|
|
-int DiffTimeb(struct timeb ST, struct timeb ET)
|
|
|
-{
|
|
|
- //return milli-second
|
|
|
- unsigned int StartTime, StopTime;
|
|
|
-
|
|
|
- StartTime = (unsigned int)ST.time;
|
|
|
- StopTime = (unsigned int)ET.time;
|
|
|
- return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
|
|
|
-}
|
|
|
-
|
|
|
-//=================================
|
|
|
-// Common routine
|
|
|
-//=================================
|
|
|
-char *getTimeString(void)
|
|
|
-{
|
|
|
- char *result = malloc(21);
|
|
|
- time_t timep;
|
|
|
- struct tm *p;
|
|
|
- time(&timep);
|
|
|
- p = gmtime(&timep);
|
|
|
-
|
|
|
- sprintf(result, "[%04d-%02d-%02d %02d:%02d:%02d]",
|
|
|
- (1900 + p->tm_year),
|
|
|
- (1 + p->tm_mon),
|
|
|
- p->tm_mday,
|
|
|
- p->tm_hour,
|
|
|
- p->tm_hour,
|
|
|
- p->tm_sec);
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-#endif //0
|
|
|
-
|
|
|
-//==========================================
|
|
|
-// Init all share memory
|
|
|
-//==========================================
|
|
|
-/*int InitShareMemory()
|
|
|
-{
|
|
|
- int result = PASS;
|
|
|
- int MeterSMId;
|
|
|
-
|
|
|
- //creat ShmSysConfigAndInfo
|
|
|
- if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0) {
|
|
|
- result = FAIL;
|
|
|
- } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- //creat ShmStatusCodeData
|
|
|
- if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0) {
|
|
|
- result = FAIL;
|
|
|
- } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- //creat ShmStatusCodeData
|
|
|
- if ((MeterSMId = shmget(ShmPrimaryMcuKey, sizeof(struct PrimaryMcuData), 0777)) < 0) {
|
|
|
- result = FAIL;
|
|
|
- } else if ((ShmPrimaryMcuData = shmat(MeterSMId, NULL, 0)) == (void *) - 1) {
|
|
|
- result = FAIL;
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-*/
|
|
|
|
|
|
//================================================
|
|
|
// Function
|
|
@@ -186,7 +84,8 @@ void GetInputGpioStatus(int fd)
|
|
|
}
|
|
|
|
|
|
ShmPrimaryMcuData->InputDet.bits.SpdDetec = gpio_in.SPD;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Ac_Drop = ~gpio_in.AC_Drop; // Chiller Alarm ping
|
|
|
+ //log_info("gpio_in.AC_Drop:%d", gpio_in.AC_Drop);
|
|
|
+ ShmPrimaryMcuData->InputDet.bits.Ac_Drop = gpio_in.AC_Drop; // Chiller Alarm ping
|
|
|
|
|
|
#ifdef DD360ComBox
|
|
|
EmgBtn_flag = 0;
|
|
@@ -226,7 +125,7 @@ void GetInputGpioStatus(int fd)
|
|
|
ShmPrimaryMcuData->InputDet.bits.Button1 = gpio_in.Button[0];
|
|
|
ShmPrimaryMcuData->InputDet.bits.Button2 = gpio_in.Button[1];
|
|
|
|
|
|
-#if defined DD360 || defined DD360Audi || defined DD360ComBox
|
|
|
+//#if defined DD360 || defined DD360Audi || defined DD360ComBox
|
|
|
if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
|
|
|
(strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
|
|
|
(strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0) ||
|
|
@@ -288,56 +187,8 @@ void GetInputGpioStatus(int fd)
|
|
|
ShmPrimaryMcuData->InputDet.bits.Key3 = ~gpio_in.Key[3] & 0x01;
|
|
|
|
|
|
return;
|
|
|
-#endif //defined DD360 || defined DD360Audi || defined DD360ComBox
|
|
|
-
|
|
|
- static uint8_t _curDeviceStatus[3] = {0};
|
|
|
- static uint8_t _reCheckCount[3] = {0};
|
|
|
-
|
|
|
- //DS60-120 add
|
|
|
- if (_curDeviceStatus[_PRIMARY_CHECK_TAG_AC_CONTACT] != gpio_in.AC_Connector) {
|
|
|
- if (_reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT] >= 3) {
|
|
|
- _curDeviceStatus[_PRIMARY_CHECK_TAG_AC_CONTACT] = gpio_in.AC_Connector;
|
|
|
- pSysInfo->AcContactorStatus =
|
|
|
- ShmPrimaryMcuData->InputDet.bits.AcContactorDetec =
|
|
|
- gpio_in.AC_Connector;
|
|
|
- } else {
|
|
|
- _reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT]++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- _reCheckCount[_PRIMARY_CHECK_TAG_AC_CONTACT] = 0;
|
|
|
- }
|
|
|
|
|
|
- if (_curDeviceStatus[_PRIMARY_CHECK_TAG_MAIN_BREAKER] != gpio_in.AC_MainBreaker) {
|
|
|
- if (_reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER] >= 3) {
|
|
|
- _curDeviceStatus[_PRIMARY_CHECK_TAG_MAIN_BREAKER] = gpio_in.AC_MainBreaker;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
|
|
|
- } else {
|
|
|
- _reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER]++;
|
|
|
- }
|
|
|
- } else {
|
|
|
- _reCheckCount[_PRIMARY_CHECK_TAG_MAIN_BREAKER] = 0;
|
|
|
- }
|
|
|
- //pSysInfo->AcContactorStatus = ShmPrimaryMcuData->InputDet.bits.AcContactorDetec = gpio_in.AC_Connector;
|
|
|
- //ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec = gpio_in.AC_MainBreaker;
|
|
|
-
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key0 = gpio_in.Key[0] & 0x01;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key1 = gpio_in.Key[1] & 0x01;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key2 = gpio_in.Key[2] & 0x01;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key3 = gpio_in.Key[3] & 0x01;
|
|
|
- ShmPrimaryMcuData->InputDet.bits.DoorOpen = gpio_in.Door_Open;
|
|
|
-
|
|
|
- /*printf(" gpio_in.Key[0]~ gpio_in.Key[3]=%d, %d, %d, %d",
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key0 , ShmPrimaryMcuData->InputDet.bits.Key1,
|
|
|
- ShmPrimaryMcuData->InputDet.bits.Key2,ShmPrimaryMcuData->InputDet.bits.Key3);
|
|
|
- printf("pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning=%d", pAlarmCode->AlarmEvents.bits.CcsLiquidChillerWaterLevelWarning);
|
|
|
- printf("pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault=%d", pFaultCode->FaultEvents.bits.CcsLiquidChillerWaterLevelFault);
|
|
|
- */
|
|
|
- //log_info("left = %d ", ShmPrimaryMcuData->InputDet.bits.Button1);
|
|
|
- //log_info("right = %d ", ShmPrimaryMcuData->InputDet.bits.Button2);
|
|
|
- //log_info("pSysInfo->AcContactorStatus = %d ", pSysInfo->AcContactorStatus);
|
|
|
- if (ShmPrimaryMcuData->InputDet.bits.AcMainBreakerDetec == YES) {
|
|
|
- log_error("AC Mainbreaker occur. ");
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
static void checkChillerStatus(Gpio_out *gpio)
|
|
@@ -347,17 +198,18 @@ static void checkChillerStatus(Gpio_out *gpio)
|
|
|
struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
static ChillerInfo fChillerInfo[2] = {0}, *pChillerInfo = NULL;
|
|
|
static ChillerInfo _chiller;
|
|
|
- struct FanModuleData* ShmFanModuleData = (struct FanModuleData*)GetShmFanModuleData();;
|
|
|
+ struct FanModuleData* ShmFanModuleData = (struct FanModuleData*)GetShmFanModuleData();
|
|
|
+ DcCommonInfo* ShmDcCommonData = (DcCommonInfo*)GetShmDcCommonData();
|
|
|
Gpio_out *pGpio = (Gpio_out *)gpio;
|
|
|
|
|
|
- if ((strncmp((char *)&pSysConfig->ModelName[7], "V", 1) == 0) ||
|
|
|
- (strncmp((char *)&pSysConfig->ModelName[7], "F", 1) == 0)) {
|
|
|
+ if ((strncmp((char*)&pSysConfig->ModelName[7], "V", 1) == 0) ||
|
|
|
+ (strncmp((char*)&pSysConfig->ModelName[7], "F", 1) == 0)) {
|
|
|
chillerCount++;
|
|
|
ShmDcCommonData->pGunInfo[0].withChiller = TRUE;
|
|
|
}
|
|
|
|
|
|
- if ((strncmp((char *)&pSysConfig->ModelName[9], "V", 1) == 0) ||
|
|
|
- (strncmp((char *)&pSysConfig->ModelName[9], "F", 1) == 0)) {
|
|
|
+ if ((strncmp((char*)&pSysConfig->ModelName[9], "V", 1) == 0) ||
|
|
|
+ (strncmp((char*)&pSysConfig->ModelName[9], "F", 1) == 0)) {
|
|
|
chillerCount++;
|
|
|
ShmDcCommonData->pGunInfo[1].withChiller = TRUE;
|
|
|
}
|
|
@@ -382,28 +234,30 @@ static void checkChillerStatus(Gpio_out *gpio)
|
|
|
//10分鐘後停止
|
|
|
if ((time((time_t *)NULL) - pChillerInfo->ChillerOnTime) >= 600) {
|
|
|
pChillerInfo->ChillerSwitch = NO;
|
|
|
+ ShmDcCommonData->FanOnTime = time((time_t*)NULL);
|
|
|
}
|
|
|
} else {
|
|
|
pChillerInfo->ChillerSwitch = NO;
|
|
|
+ ShmFanModuleData->SetFan1Speed = 0;
|
|
|
}
|
|
|
}
|
|
|
// 檢查Chiller溫度點,若小於零下時開啟heater,大於10度時關閉heater
|
|
|
- if (pDcChargingInfo->ChillerTemp < 60) {
|
|
|
+ if (pDcChargingInfo->ChillerTemp < 70) {
|
|
|
pGpio->AC_Breaker = YES;
|
|
|
- } else if(pDcChargingInfo->ChillerTemp > 70) {
|
|
|
+ } else if(pDcChargingInfo->ChillerTemp > 75) {
|
|
|
pGpio->AC_Breaker = NO;
|
|
|
}
|
|
|
- //log_info("Set Heater %s", pGpio->AC_Breaker ? "ON" : "OFF");
|
|
|
+ //log_info("Gun%d Set Heater %s", gunIndex, pGpio->AC_Breaker ? "ON" : "OFF");
|
|
|
}
|
|
|
uint8_t _chillerNeedOn = NO;
|
|
|
for (gunIndex = 0; gunIndex < pSysConfig->TotalConnectorCount; gunIndex++)
|
|
|
{
|
|
|
- pChillerInfo = (ChillerInfo *)&fChillerInfo[gunIndex];
|
|
|
- if(pChillerInfo->ChillerSwitch == YES) {
|
|
|
+ pChillerInfo = (ChillerInfo*)&fChillerInfo[gunIndex];
|
|
|
+ if (pChillerInfo->ChillerSwitch == YES) {
|
|
|
_chillerNeedOn = YES;
|
|
|
+ ShmFanModuleData->SetFan1Speed = 7000;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/*
|
|
|
if (ShmDcCommonData->debugflag == YES)
|
|
|
_chillerNeedOn = ShmDcCommonData->chillerCtrl;
|
|
@@ -451,7 +305,7 @@ void SetOutputGpio(int fd, uint8_t outputValue)
|
|
|
|
|
|
checkChillerStatus(&gpio);
|
|
|
|
|
|
- //gpio.AC_Breaker = 0x00;
|
|
|
+ //gpio.AC_Breaker = 0x01;
|
|
|
|
|
|
Config_Gpio_Output(fd, OP_ADDR_IO_EXTEND, &gpio);
|
|
|
}
|
|
@@ -541,48 +395,17 @@ unsigned long GetTimeoutValue(struct timeval _sour_time)
|
|
|
|
|
|
return 1000000 * (_end_time.tv_sec - _sour_time.tv_sec) + _end_time.tv_usec - _sour_time.tv_usec;
|
|
|
}
|
|
|
+unsigned long GetClockTimeoutValue(struct timespec _start_time)
|
|
|
+{
|
|
|
+ struct timespec ts_end;
|
|
|
+ unsigned long ret = 0;
|
|
|
+
|
|
|
+ clock_gettime(CLOCK_MONOTONIC, &ts_end);
|
|
|
|
|
|
-//int FindChargingInfoData(uint8_t target, struct ChargingInfoData **chargingData)
|
|
|
-//{
|
|
|
-// for (uint8_t index = 0; index < CHAdeMO_QUANTITY; index++) {
|
|
|
-// if (pSysInfo->ChademoChargingData[index].Index == target) {
|
|
|
-// chargingData[target] = &pSysInfo->ChademoChargingData[index];
|
|
|
-// return 1;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// for (uint8_t index = 0; index < CCS_QUANTITY; index++) {
|
|
|
-// if (pSysInfo->CcsChargingData[index].Index == target) {
|
|
|
-// chargingData[target] = &pSysInfo->CcsChargingData[index];
|
|
|
-// return 1;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// for (uint8_t index = 0; index < GB_QUANTITY; index++) {
|
|
|
-// if (pSysInfo->GbChargingData[index].Index == target) {
|
|
|
-// chargingData[target] = &pSysInfo->GbChargingData[index];
|
|
|
-// return 1;
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// return 0;
|
|
|
-//}
|
|
|
-
|
|
|
-//void Initialization() //DS60-120 add
|
|
|
-//{
|
|
|
-// bool isPass = false;
|
|
|
-// while (!isPass) {
|
|
|
-// isPass = true;
|
|
|
-// for (uint8_t _index = 0; _index < gun_count; _index++) {
|
|
|
-// if (!FindChargingInfoData(_index, &ChargingData[0])) {
|
|
|
-// log_error("EvComm (main) : FindChargingInfoData false ");
|
|
|
-// isPass = false;
|
|
|
-// break;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// sleep(1);
|
|
|
-// }
|
|
|
-//}
|
|
|
+ ret = ((unsigned long)(ts_end.tv_sec - _start_time.tv_sec) * 1000000) + ((unsigned long)((ts_end.tv_nsec / 1000) - (_start_time.tv_nsec / 1000)));
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
|
|
|
static bool IsPrimaryProcessNeedPause(void)
|
|
|
{
|