Browse Source

2021.03.23 / Jerry Wang

Actions:
1. Modify rated current API.

Files:
1. EVSE/Modularization/Module_RatedCurrent.c
2. EVSE/Modularization/Makefile
Jerry_Wang 4 years ago
parent
commit
9b92b998f2

+ 6 - 6
EVSE/Modularization/Makefile

@@ -7,7 +7,7 @@ Lib_SQLite3 = "-L../../../Modularization/ocppfiles" -lsqlite3
 all: clean Module_RFIDLib Module_Wifi WebServiceLib Ocpp16 \
 		Phihong_PsuCommObj Module_4g Module_UpgradeLib Infypwr_PsuCommObj \
 			Module_EventLogging Module_ProduceUtils Module_PhBackend \
-				Ocpp20 Module_InitUpgrade Module_RatingCurrentLib
+				Ocpp20 Module_InitUpgrade Module_RatedCurrentLib
 
 
 clean:
@@ -31,11 +31,11 @@ Module_ProduceUtils:
 	rm -f Module_ProduceUtils.o
 	mv -f Module_ProduceUtils ../rootfs/root
 
-Module_RatingCurrentLib:
-	rm -f libModule_RatingCurrent.a
-	$(CC) -D $(Project) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_RatingCurrent.o Module_RatingCurrent.c
-	$(AR) -r libModule_RatingCurrent.a Module_RatingCurrent.o
-	rm -f Module_RatingCurrent.o
+Module_RatedCurrentLib:
+	rm -f libModule_RatedCurrent.a
+	$(CC) -D $(Project) -O0 -g3 -Wall -c -fmessage-length=0 -o Module_RatedCurrent.o Module_RatedCurrent.c
+	$(AR) -r libModule_RatedCurrent.a Module_RatedCurrent.o
+	rm -f Module_RatedCurrent.o
 
 Module_RFIDLib:
 	rm -f libModule_RFID.a

+ 527 - 0
EVSE/Modularization/Module_RatedCurrent.c

@@ -0,0 +1,527 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdarg.h>
+#include <time.h>
+
+#include <sys/timeb.h>
+
+#include "Module_RatedCurrent.h"
+
+//------------------------------------------------------------------------------
+#define PASS                                    (1)
+#define FAIL                                    (-1)
+
+#define log_info(format, args...)               StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_warn(format, args...)               StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+#define log_error(format, args...)              StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
+
+//------------------------------------------------------------------------------
+static SymStruct modelTable[] = {
+    { "AC", MODEL_AC },
+    { "AW", MODEL_AW },
+    { "AP", MODEL_AP },
+    { "DW", MODEL_DW },
+    { "DS", MODEL_DS },
+    { "DM", MODEL_DM },
+    { "DR", MODEL_DR },
+    //{ "DM", MODEL_DM },
+    { "DD", MODEL_DD },
+    { "DO", MODEL_DO },
+};
+
+static SymStruct regulationTable[] = {
+    {"E", REG_CE},
+    {"U", REG_UL},
+    {"G", REG_GB},
+    {"C", REG_CNS},
+    {"J", REG_JARI},
+    {"T", REG_TR25},
+    {"K", REG_KC},
+    {"B", REG_B},
+    {"Z", REG_Z},
+    {"M", REG_M},
+    {"P", REG_P},
+    {"I", REG_I},
+    {"F", REG_F},
+    {"L", REG_L},
+};
+
+static SymStruct powerTable[] = {
+    {"30", POWER_30W},
+    {"60", POWER_60W},
+    {"90", POWER_90W},
+    {"12", POWER_120W},
+    {"15", POWER_150W},
+    {"18", POWER_180W},
+    {"24", POWER_240W},
+    {"36", POWER_360W},
+    {"48", POWER_480W},
+    {"72", POWER_720W},
+};
+
+static SymStruct gunTypeTable[] = {
+    {"0", GUN_TYPE_0},
+    {"1", GUN_TYPE_1},
+    {"2", GUN_TYPE_2},
+    {"3", GUN_TYPE_3},
+    {"4", GUN_TYPE_4},
+    {"5", GUN_TYPE_5},
+    {"6", GUN_TYPE_6},
+    {"7", GUN_TYPE_7},
+    {"8", GUN_TYPE_8},
+    {"J", GUN_TYPE_J},
+    {"U", GUN_TYPE_U},
+    {"V", GUN_TYPE_V},
+    {"E", GUN_TYPE_E},
+    {"F", GUN_TYPE_F},
+    {"G", GUN_TYPE_G},
+};
+
+//------------------------------------------------------------------------------
+static int StoreLogMsg(const char *fmt, ...)
+{
+    char Buf[4096 + 256] = {0};
+    char buffer[4096] = {0};
+    int rc = 0;
+    va_list args;
+    struct timeb  SeqEndTime;
+    struct tm *tm;
+
+    va_start(args, fmt);
+    rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
+    va_end(args);
+
+    ftime(&SeqEndTime);
+    SeqEndTime.time = time(NULL);
+    tm = localtime(&SeqEndTime.time);
+
+    //if (ShmSysConfigAndInfo->SysConfig.SwitchDebugFlag == YES) {
+    //    sprintf(Buf, "%02d:%02d:%02d:%03d - %s",
+    //            tm->tm_hour, tm->tm_min, tm->tm_sec, SeqEndTime.millitm, buffer);
+    //    printf("%s \n", 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;
+}
+
+static int keyfromstring(char *key, SymStruct *table, int tableCount)
+{
+    int i = 0;
+    //int loop = sizeof(table) / sizeof(SymStruct);
+    SymStruct *sym = NULL;
+
+    for (i = 0; i < tableCount; i++) {
+        sym = (SymStruct *)&table[i];
+        if (strcmp(sym->key, key) == 0) {
+            //printf("val = %x\r\n", sym->val);
+            return sym->val;
+        }
+    }
+
+    return BADKEY;
+}
+
+//------------------------------------------------------------------------------
+static uint16_t exchangeRatingCur(uint32_t key)
+{
+    switch (key) {
+    //60A J
+    case DW_CE_30_J:
+    case DM_CE_30_J:
+
+    case DW_CE_30_E:
+    case DM_CE_30_E:
+        return RC_60A; //rating current 60A
+
+    //65A U
+    case DW_UL_30_U:
+    case DM_UL_30_U:
+
+    case DW_CNS_30_U:
+    case DM_CNS_30_U:
+        return RC_65A;
+
+    //80A J
+    case DW_UL_30_J:
+    case DM_UL_30_J:
+    case DW_CNS_30_J:
+    case DM_CNS_30_J:
+
+    //80A G
+    case DM_CNS_30_G:
+    case DS_UL_30_G:
+
+    //80A M
+    case DW_CE_30_M:
+    case DM_CE_30_M:
+
+    //80A N
+    case DW_UL_30_N:
+    case DM_UL_30_N:
+    case DW_CNS_30_N:
+    case DM_CNS_30_N:
+        return RC_80A; //rating current 80A
+
+    //125A J
+    case DS_CE_60_J:
+    case DS_CE_90_J:
+    case DS_CE_120_J:
+    case DS_CE_150_J:
+    case DS_CE_180_J:
+
+    case DS_UL_60_J:
+    case DS_UL_90_J:
+    case DS_UL_120_J:
+    case DS_UL_150_J:
+    case DS_UL_180_J:
+
+    case DS_CNS_60_J:
+    case DS_CNS_90_J:
+    case DS_CNS_120_J:
+    case DS_CNS_150_J:
+    case DS_CNS_180_J:
+
+    //125A U
+    case DS_UL_60_U:
+
+    case DS_CNS_60_U:
+
+    //125A E
+    case DS_CE_60_E:
+        return RC_125A; //rating current 125A
+
+    //200A U
+    case DS_UL_90_U:
+    case DS_UL_120_U:
+    case DS_UL_150_U:
+    case DS_UL_180_U:
+    case DD_UL_360_U:
+
+    case DS_CNS_90_U:
+    case DS_CNS_120_U:
+    case DS_CNS_150_U:
+    case DS_CNS_180_U:
+    case DD_CNS_360_U:
+
+    //200A E
+    case DS_CE_90_E:
+    case DS_CE_120_E:
+    case DS_CE_150_E:
+    case DS_CE_180_E:
+
+    //200A K
+    case DS_CE_90_K:
+    case DS_CE_120_K:
+    case DS_CE_150_K:
+    case DS_CE_180_K:
+
+    case DD_CE_360_K:
+
+    case DS_UL_90_K:
+    case DS_UL_120_K:
+    case DS_UL_150_K:
+    case DS_UL_180_K:
+
+    case DD_UL_360_K:
+        return RC_200A; //rating current 200A
+
+    //250A G
+    case DS_CNS_120_G:
+        return RC_250A;
+
+    //300A T
+    case DS_CE_90_T:
+    case DS_CE_120_T:
+    case DS_CE_150_T:
+    case DS_CE_180_T:
+
+    case DD_CE_360_T:
+
+    case DS_UL_90_T:
+    case DS_UL_120_T:
+    case DS_UL_150_T:
+    case DS_UL_180_T:
+
+    case DD_UL_360_T:
+
+    case DS_CNS_90_T:
+    case DS_CNS_120_T:
+    case DS_CNS_150_T:
+    case DS_CNS_180_T:
+
+    case DD_CNS_360_T:
+
+    //300A D
+    case DS_CE_90_D:
+    case DS_CE_120_D:
+    case DS_CE_150_D:
+    case DS_CE_180_D:
+    case DD_CE_360_D:
+
+    case DS_UL_90_D:
+    case DS_UL_120_D:
+    case DS_UL_150_D:
+    case DS_UL_180_D:
+
+    case DD_UL_360_D:
+
+    case DS_CNS_90_D:
+    case DS_CNS_120_D:
+    case DS_CNS_150_D:
+    case DS_CNS_180_D:
+
+    case DD_CNS_360_D:
+        return RC_300A;
+
+    //500A V
+    case DD_UL_360_V:
+
+    case DD_CNS_360_V:
+
+    case DO_UL_360_V:
+    case DO_CNS_360_V:
+
+    //500A F
+    case DD_CE_360_F:
+    case DO_CE_360_F:
+
+    //P
+    case DD_CE_360_P:
+
+    case DD_UL_360_R:
+    case DD_CNS_360_R:
+        return RC_500A; //rating current 500A
+
+    default:
+        return RC_0A; //rating current 200A
+    }
+}
+
+static void exchangeGunTypeAndVolValue(uint8_t key, GunTypeAndVolInfo *gunAndVol)
+{
+    GunTypeAndVolInfo *pGunAndVol = (GunTypeAndVolInfo *)gunAndVol;
+
+    switch (key) {
+    case GUN_TYPE_0:// : none
+    case GUN_TYPE_1:// : IEC 62196-2 Type 1/SAE J1772 Plug
+    case GUN_TYPE_2:// : IEC 62196-2 Type 1/SAE J1772 Socket
+    case GUN_TYPE_3:// : IEC 62196-2 Type 2 Plug
+    case GUN_TYPE_4:// : IEC 62196-2 Type 2 Socket
+    case GUN_TYPE_5:// : GB/T AC Plug
+    case GUN_TYPE_6:// : GB/T AC Socket
+    case GUN_TYPE_7:// :CCS2 AC Plug
+        pGunAndVol->GunType = Gun_Type_AC;
+        pGunAndVol->GunVoltage = VOL_CHADEMO;
+        break;
+
+    case GUN_TYPE_8:// :Type E socket
+        break;
+
+    case GUN_TYPE_J:// : CHAdeMO
+        pGunAndVol->GunType = Gun_Type_Chademo;
+        pGunAndVol->GunVoltage = VOL_CHADEMO;
+        break;
+
+    case GUN_TYPE_U:// : Natural cooling CCS1 combo
+    case GUN_TYPE_V:// : Liquid cooling CCS1 combo
+    case GUN_TYPE_E:// : Natural cooling CCS2 combo
+    case GUN_TYPE_F:// : Liquid cooling CCS2 combo
+        pGunAndVol->GunType = Gun_Type_CCS_2;
+        pGunAndVol->GunVoltage = VOL_CCS;
+        break;
+
+    case GUN_TYPE_G:// : GBT DC
+        pGunAndVol->GunType = Gun_Type_GB;
+        pGunAndVol->GunVoltage = VOL_GBT;
+        break;
+    }
+}
+
+static int exchangePowerValue(uint8_t key)
+{
+    switch (key) {
+    case POWER_30W:
+        return 300;
+
+    case POWER_60W:
+        return 600;
+
+    case POWER_90W:
+        return 900;
+
+    case POWER_120W:
+        return 1200;
+
+    case POWER_150W:
+        return 1500;
+
+    case POWER_180W:
+        return 1800;
+
+    case POWER_240W:
+        return 2400;
+
+    case POWER_360W:
+        return 3600;
+
+    case POWER_480W:
+        return 4800;
+
+    case POWER_720W:
+        return 7200;
+
+    default:
+        return 600;
+        break;
+    }
+}
+
+/**
+ * [RatedCurrentParsing : Parsing Rating Current]
+ * @param  pModuleName  [description]
+ * @param  pDestStruct  [save parameter structure array]
+ * @param  parsingCount [parameter structure array count, array 0, 1 for DC Gun, 2 for AC Gun]
+ * @return              [return -1 is module name format non match.]
+ */
+int RatedCurrentParsing(char *pModuleName, void *pDestStruct)
+{
+    uint8_t gunTypeIndex = 0;
+
+    uint8_t modelKey = 0;
+    uint8_t reguKey = 0;
+    uint8_t powerKey = 0;
+    uint8_t gunTypeKey = 0;
+    uint16_t powerVal = 0;
+    uint16_t ratingCurVal = 0;
+    int i = 0;
+    uint32_t ret = 0;
+    char model[2] = {'\0'};
+    char regulation[1] = {'\0'};
+    char power[2] = {'\0'};
+    char gunType[1] = {'\0'};
+    ParsingRatedCur *pParsingInfo = NULL;
+    GunRateCurInfo *pGunRateCurInfo = NULL;
+    GunTypeAndVolInfo fGunAndVol = {0};
+
+    if (pModuleName == NULL || pDestStruct == NULL) {
+        log_error("Failed to parse source data\r\n");
+        return FAIL;
+    }
+
+    pParsingInfo = (ParsingRatedCur *)pDestStruct;
+
+    strncpy(model, &pModuleName[0], 2);
+    model[2] = '\0';
+    strncpy(regulation, &pModuleName[3], 1);
+    regulation[1] = '\0';
+    strncpy(power, &pModuleName[4], 2);
+    power[2] = '\0';
+
+
+    pParsingInfo->GetGunCount = 0;
+    for (i = 0; i < sizeof(pParsingInfo->ParsingInfo) / sizeof(GunRateCurInfo); i++) {
+        pGunRateCurInfo = (GunRateCurInfo *)&pParsingInfo->ParsingInfo[pParsingInfo->GetGunCount];
+
+        if (i == 0) {
+            gunTypeIndex = DC_ONE;
+        } else if (i == 1) {
+            gunTypeIndex = AC_ONE;
+        } else if (i == 2) {
+            gunTypeIndex = DC_SEC;
+        }
+
+        strncpy(gunType, &pModuleName[gunTypeIndex], 1);
+        gunType[1] = '\0';
+
+        modelKey = keyfromstring(&model[0], &modelTable[0], sizeof(modelTable) / sizeof(SymStruct));
+        reguKey = keyfromstring(&regulation[0], &regulationTable[0], sizeof(regulationTable) / sizeof(SymStruct));
+        powerKey = keyfromstring(&power[0], &powerTable[0], sizeof(powerTable) / sizeof(SymStruct));
+        if ((gunTypeKey = keyfromstring(&gunType[0], &gunTypeTable[0], sizeof(gunTypeTable) / sizeof(SymStruct))) == GUN_TYPE_0) {
+            log_error("The type of gun is none\r\n");
+            continue;
+        }
+
+        ret = 0;
+        ret = ((modelKey << 24) | (reguKey << 16) | (powerKey << 8) | gunTypeKey);
+        ratingCurVal = exchangeRatingCur(ret);
+        if (ratingCurVal == RC_0A) {
+            log_error("Model name format none match\r\n");
+            continue;
+            //return FAIL;
+        }
+
+        memset((uint8_t *)&fGunAndVol, 0, sizeof(GunTypeAndVolInfo));
+        exchangeGunTypeAndVolValue(gunTypeKey, &fGunAndVol);
+        powerVal = exchangePowerValue(powerKey);
+
+        pGunRateCurInfo->GunType = fGunAndVol.GunType;
+        pGunRateCurInfo->Current = ratingCurVal;
+        pGunRateCurInfo->Voltage = fGunAndVol.GunVoltage;
+        pGunRateCurInfo->Power = powerVal;
+
+        pParsingInfo->GetGunCount++;
+
+        //log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
+        //         i,
+        //         pGunRateCurInfo->GunType,
+        //         pGunRateCurInfo->Current,
+        //         pGunRateCurInfo->Voltage,
+        //         pGunRateCurInfo->Power);
+
+    }
+
+    return PASS;
+}
+
+//------------------------------------------------------------------------------
+//Test function
+//------------------------------------------------------------------------------
+void TestParsingRatingCurrent(void)
+{
+    uint8_t i = 0;
+    ParsingRatedCur fParsingRateCur = {0};
+
+    RatedCurrentParsing("DDYC362V0UE2AD", &fParsingRateCur);
+    log_info("Get gun = %d\r\n", fParsingRateCur.GetGunCount);
+    for (i = 0; i < fParsingRateCur.GetGunCount; i++) {
+        log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
+                 i,
+                 fParsingRateCur.ParsingInfo[i].GunType,
+                 fParsingRateCur.ParsingInfo[i].Current,
+                 fParsingRateCur.ParsingInfo[i].Voltage,
+                 fParsingRateCur.ParsingInfo[i].Power);
+    }
+    //log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
+    //         0,
+    //         fGunRateCurInfo[0].GunType,
+    //         fGunRateCurInfo[0].Current,
+    //         fGunRateCurInfo[0].Voltage,
+    //         fGunRateCurInfo[0].Power);
+
+    RatedCurrentParsing("DMYE301E00D2PH", &fParsingRateCur);
+    log_info("Get gun = %d\r\n", fParsingRateCur.GetGunCount);
+    for (i = 0; i < fParsingRateCur.GetGunCount; i++) {
+        log_info("%d GunType = %d, Rating current = %d, Vol = %d, Power = %d\r\n",
+                 i,
+                 fParsingRateCur.ParsingInfo[i].GunType,
+                 fParsingRateCur.ParsingInfo[i].Current,
+                 fParsingRateCur.ParsingInfo[i].Voltage,
+                 fParsingRateCur.ParsingInfo[i].Power);
+    }
+}

+ 303 - 0
EVSE/Modularization/Module_RatedCurrent.h

@@ -0,0 +1,303 @@
+#ifndef _MODULE_NAME_PARSING_H_
+#define _MODULE_NAME_PARSING_H_
+
+#define BADKEY                                  (-1)
+
+//------------------------------------------------------------------------------
+// model type key
+//------------------------------------------------------------------------------
+#define MODEL_AC                                (0x01) //Ac EVse Cordset
+#define MODEL_AW                                (0x02) //Ac EVse Wallmount
+#define MODEL_AP                                (0x03) //Ac EVse Pedestal
+#define MODEL_DW                                (0x04) //Dc EVse Wallmount
+#define MODEL_DS                                (0x05) //Dc EVse Standalone
+#define MODEL_DM                                (0x06) //Dc EVse Moveable (Battery equipped)
+#define MODEL_DR                                (0x07) //Dc EVse Power Rack (without cabinet)
+//#define MODEL_DM                                (0x08) //Dc EVse Moveable (移動)
+#define MODEL_DD                                (0x09) //Dc EVse Dispenser
+#define MODEL_DO                                (0x0A) //Dc EVse Output power cabinet
+
+//------------------------------------------------------------------------------
+// regulation key
+//------------------------------------------------------------------------------
+#define REG_CE                                  (0x01) // CE / European Market
+#define REG_UL                                  (0x02) // UL / North America Market
+#define REG_GB                                  (0x03) // GB / China Market
+#define REG_CNS                                 (0x04) // CNS / Taiwan Market
+#define REG_JARI                                (0x05) // JARI / Japan Market
+#define REG_TR25                                (0x06) // TR25 / Singapor Market
+#define REG_KC                                  (0x07) // KC / Korea Market
+#define REG_B                                   (0x08) // British / UK Market
+#define REG_Z                                   (0x09) // EV ready / French Market
+#define REG_M                                   (0x0A) // E + MID Meter
+#define REG_P                                   (0x0B) // E + PTB certification
+#define REG_I                                   (0x0C) // Z + TIC Meter pcb
+#define REG_F                                   (0x0D) // Z + MID Meter
+#define REG_L                                   (0x0E) // U + UL meter
+
+//------------------------------------------------------------------------------
+// rate power key
+//------------------------------------------------------------------------------
+#define POWER_30W                               (0x01)
+#define POWER_60W                               (0x02)
+#define POWER_90W                               (0x03)
+#define POWER_120W                              (0x04)
+#define POWER_150W                              (0x05)
+#define POWER_180W                              (0x06)
+#define POWER_240W                              (0x07)
+#define POWER_360W                              (0x08)
+#define POWER_480W                              (0x09)
+#define POWER_720W                              (0x0A)
+
+//------------------------------------------------------------------------------
+// gun type key
+//------------------------------------------------------------------------------
+#define GUN_TYPE_0                              (0x00) //none
+#define GUN_TYPE_1                              (0x01) //IEC 62196-2 Type 1/SAE J1772 Plug
+#define GUN_TYPE_2                              (0x02) //IEC 62196-2 Type 1/SAE J1772 Socket
+#define GUN_TYPE_3                              (0x03) //IEC 62196-2 Type 2 Plug
+#define GUN_TYPE_4                              (0x04) //IEC 62196-2 Type 2 Socket
+#define GUN_TYPE_5                              (0x05) //GB/T AC Plug
+#define GUN_TYPE_6                              (0x06) //GB/T AC Socket
+#define GUN_TYPE_7                              (0x07) //CS2 AC Plug
+#define GUN_TYPE_8                              (0x08) //Type E socket
+#define GUN_TYPE_J                              (0x09) //CHAdeMO
+#define GUN_TYPE_U                              (0x0A) //Natural cooling CCS1 combo
+#define GUN_TYPE_V                              (0x0B) //Liquid cooling CCS1 combo
+#define GUN_TYPE_E                              (0x0C) //Natural cooling CCS2 combo
+#define GUN_TYPE_F                              (0x0D) //Liquid cooling CCS2 combo
+#define GUN_TYPE_G                              (0x0E) //GBT DC
+#define GUN_TYPE_T                              (0x0F) //Rema CCS1
+#define GUN_TYPE_D                              (0x10) //Rema CCS2
+#define GUN_TYPE_K                              (0x11) //CHAdeMO 200A/500V
+#define GUN_TYPE_M                              (0x12) //CCS2 80A
+#define GUN_TYPE_N                              (0x13) //CCS1 80A
+#define GUN_TYPE_P                              (0x14) //Phoenix CCS2 500A 水冷
+#define GUN_TYPE_R                              (0x15) //Phoenix CCS1 500A 水冷
+
+//------------------------------------------------------------------------------
+// rating current parameters
+//------------------------------------------------------------------------------
+#define RC_0A                                   (0)
+#define RC_60A                                  (600)
+#define RC_65A                                  (650)
+#define RC_80A                                  (800)
+#define RC_125A                                 (1250)
+#define RC_200A                                 (2000)
+#define RC_250A                                 (2500)
+#define RC_300A                                 (3000)
+#define RC_500A                                 (5000)
+
+//------------------------------------------------------------------------------
+// maximum voltage parameters
+//------------------------------------------------------------------------------
+#define VOL_CHADEMO                             (5000)
+#define VOL_CCS                                 (9500)
+#define VOL_GBT                                 (7500)
+
+#define DC_ONE                                  (7)
+#define DC_SEC                                  (9)
+#define AC_ONE                                  (8)
+
+//------------------------------------------------------------------------------
+// power parameters
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// rating current case
+//------------------------------------------------------------------------------
+//J
+#define DW_CE_30_J                              ((uint32_t)((MODEL_DW << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+#define DM_CE_30_J                              ((uint32_t)((MODEL_DM << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+
+#define DW_UL_30_J                              ((uint32_t)((MODEL_DW << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+#define DM_UL_30_J                              ((uint32_t)((MODEL_DM << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+
+#define DW_CNS_30_J                             ((uint32_t)((MODEL_DW << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+#define DM_CNS_30_J                             ((uint32_t)((MODEL_DM << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_J))
+
+#define DS_CE_60_J                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_60W << 8) | GUN_TYPE_J))
+#define DS_CE_90_J                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_90W << 8) | GUN_TYPE_J))
+#define DS_CE_120_J                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_120W << 8) | GUN_TYPE_J))
+#define DS_CE_150_J                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_J))
+#define DS_CE_180_J                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_J))
+
+#define DS_UL_60_J                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_60W << 8) | GUN_TYPE_J))
+#define DS_UL_90_J                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_J))
+#define DS_UL_120_J                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_120W << 8) | GUN_TYPE_J))
+#define DS_UL_150_J                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_J))
+#define DS_UL_180_J                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_J))
+
+#define DS_CNS_60_J                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_60W << 8) | GUN_TYPE_J))
+#define DS_CNS_90_J                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_J))
+#define DS_CNS_120_J                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_120W << 8) | GUN_TYPE_J))
+#define DS_CNS_150_J                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_J))
+#define DS_CNS_180_J                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_J))
+
+//U
+#define DW_UL_30_U                              ((uint32_t)((MODEL_DW << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_U))
+#define DM_UL_30_U                              ((uint32_t)((MODEL_DM << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_U))
+
+#define DW_CNS_30_U                             ((uint32_t)((MODEL_DW << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_U))
+#define DM_CNS_30_U                             ((uint32_t)((MODEL_DM << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_U))
+
+#define DS_UL_60_U                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_60W << 8) | GUN_TYPE_U))
+#define DS_UL_90_U                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_U))
+#define DS_UL_120_U                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_120W << 8) | GUN_TYPE_U))
+#define DS_UL_150_U                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_U))
+#define DS_UL_180_U                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_U))
+
+#define DD_UL_360_U                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_U))
+
+#define DS_CNS_60_U                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_60W << 8) | GUN_TYPE_U))
+#define DS_CNS_90_U                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_U))
+#define DS_CNS_120_U                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_120W << 8) | GUN_TYPE_U))
+#define DS_CNS_150_U                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_U))
+#define DS_CNS_180_U                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_U))
+
+#define DD_CNS_360_U                             ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_U))
+
+//V
+#define DD_UL_360_V                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+
+#define DD_CNS_360_V                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+
+#define DO_UL_360_V                             ((uint32_t)((MODEL_DO << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+
+#define DO_CNS_360_V                            ((uint32_t)((MODEL_DO << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_V))
+
+//E
+#define DW_CE_30_E                              ((uint32_t)((MODEL_DW << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_E))
+#define DM_CE_30_E                              ((uint32_t)((MODEL_DM << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_E))
+
+#define DS_CE_60_E                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_60W << 8) | GUN_TYPE_E))
+#define DS_CE_90_E                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_90W << 8) | GUN_TYPE_E))
+#define DS_CE_120_E                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_120W << 8) | GUN_TYPE_E))
+#define DS_CE_150_E                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_E))
+#define DS_CE_180_E                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_E))
+
+//F
+#define DD_CE_360_F                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_F))
+
+#define DO_CE_360_F                             ((uint32_t)((MODEL_DO << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_F))
+
+//G
+#define DM_CNS_30_G                             ((uint32_t)((MODEL_DM << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_G))
+
+#define DS_UL_30_G                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_G))
+#define DS_CNS_120_G                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_120W << 8) | GUN_TYPE_G))
+
+//T
+#define DS_CE_90_T                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_90W << 8) | GUN_TYPE_T))
+#define DS_CE_120_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_120W << 8) | GUN_TYPE_T))
+#define DS_CE_150_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_T))
+#define DS_CE_180_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_T))
+
+#define DD_CE_360_T                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_T))
+
+#define DS_UL_90_T                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_T))
+#define DS_UL_120_T                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_120W << 8) | GUN_TYPE_T))
+#define DS_UL_150_T                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_T))
+#define DS_UL_180_T                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_T))
+
+#define DD_UL_360_T                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_T))
+
+#define DS_CNS_90_T                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_T))
+#define DS_CNS_120_T                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_120W << 8) | GUN_TYPE_T))
+#define DS_CNS_150_T                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_T))
+#define DS_CNS_180_T                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_T))
+
+#define DD_CNS_360_T                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_T))
+
+//D
+#define DS_CE_90_D                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_90W << 8) | GUN_TYPE_D))
+#define DS_CE_120_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_120W << 8) | GUN_TYPE_D))
+#define DS_CE_150_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_D))
+#define DS_CE_180_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_D))
+
+#define DD_CE_360_D                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_D))
+
+#define DS_UL_90_D                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_D))
+#define DS_UL_120_D                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_120W << 8) | GUN_TYPE_D))
+#define DS_UL_150_D                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_D))
+#define DS_UL_180_D                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_D))
+
+#define DD_UL_360_D                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_D))
+
+#define DS_CNS_90_D                             ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_90W << 8) | GUN_TYPE_D))
+#define DS_CNS_120_D                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_120W << 8) | GUN_TYPE_D))
+#define DS_CNS_150_D                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_150W << 8) | GUN_TYPE_D))
+#define DS_CNS_180_D                            ((uint32_t)((MODEL_DS << 24) | (REG_CNS << 16) | (POWER_180W << 8) | GUN_TYPE_D))
+
+#define DD_CNS_360_D                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_D))
+
+//K
+#define DS_CE_90_K                              ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_90W << 8) | GUN_TYPE_K))
+#define DS_CE_120_K                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_120W << 8) | GUN_TYPE_K))
+#define DS_CE_150_K                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_150W << 8) | GUN_TYPE_K))
+#define DS_CE_180_K                             ((uint32_t)((MODEL_DS << 24) | (REG_CE << 16) | (POWER_180W << 8) | GUN_TYPE_K))
+
+#define DD_CE_360_K                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_K))
+
+#define DS_UL_90_K                              ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_90W << 8) | GUN_TYPE_K))
+#define DS_UL_120_K                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_120W << 8) | GUN_TYPE_K))
+#define DS_UL_150_K                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_150W << 8) | GUN_TYPE_K))
+#define DS_UL_180_K                             ((uint32_t)((MODEL_DS << 24) | (REG_UL << 16) | (POWER_180W << 8) | GUN_TYPE_K))
+
+#define DD_UL_360_K                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_K))
+
+//M
+#define DW_CE_30_M                              ((uint32_t)((MODEL_DW << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_M))
+#define DM_CE_30_M                              ((uint32_t)((MODEL_DM << 24) | (REG_CE << 16) | (POWER_30W << 8) | GUN_TYPE_M))
+
+//N
+#define DW_UL_30_N                              ((uint32_t)((MODEL_DW << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_N))
+#define DM_UL_30_N                              ((uint32_t)((MODEL_DM << 24) | (REG_UL << 16) | (POWER_30W << 8) | GUN_TYPE_N))
+
+#define DW_CNS_30_N                             ((uint32_t)((MODEL_DW << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_N))
+#define DM_CNS_30_N                             ((uint32_t)((MODEL_DM << 24) | (REG_CNS << 16) | (POWER_30W << 8) | GUN_TYPE_N))
+
+//P
+#define DD_CE_360_P                             ((uint32_t)((MODEL_DD << 24) | (REG_CE << 16) | (POWER_360W << 8) | GUN_TYPE_P))
+
+//R
+#define DD_UL_360_R                             ((uint32_t)((MODEL_DD << 24) | (REG_UL << 16) | (POWER_360W << 8) | GUN_TYPE_R))
+
+#define DD_CNS_360_R                            ((uint32_t)((MODEL_DD << 24) | (REG_CNS << 16) | (POWER_360W << 8) | GUN_TYPE_R))
+
+//------------------------------------------------------------------------------
+typedef enum EnGunType {
+    Gun_Type_Chademo = 0,
+    Gun_Type_CCS_2,
+    Gun_Type_GB,
+    Gun_Type_AC,
+} GunType;
+
+typedef struct StSymStruct {
+    char *key;
+    int val;
+} SymStruct;
+
+typedef struct StGunTypeAndVolInfo {
+    uint8_t GunType;
+    uint16_t GunVoltage;
+} GunTypeAndVolInfo;
+
+typedef struct StGunRateCurInfo {
+    uint8_t GunType;
+    uint16_t Current;       //* 0.1A
+    uint16_t Voltage;       //* 0.1V
+    uint16_t Power;
+    uint8_t Reserved;
+} GunRateCurInfo;
+
+typedef struct StParsingRatingCur {
+    uint8_t GetGunCount;
+    GunRateCurInfo ParsingInfo[3];
+} ParsingRatedCur;
+
+//------------------------------------------------------------------------------
+int RatedCurrentParsing(char *pModuleName, void *pDestStruct);
+void TestParsingRatingCurrent(void);
+
+#endif /* _MODULE_NAME_PARSING_H_ */

+ 10 - 8
EVSE/Projects/DD360Audi/Apps/Makefile

@@ -16,14 +16,16 @@ Internal485ProtocolLib = -L $(ModularizationPath)/Internal485Protocol -lInternal
 
 #define library variable
 Lib_Module_RFID = "-L$(ModularizationPath)" -lModule_RFID
+RFID_H = -include$(ModularizationPath)/Module_RFID.h
+
 Lib_Module_Upgrade = "-L$(ModularizationPath)" -lModule_Upgrade
-Lib_SQLite3 = "-L$(ModularizationPath)/ocppfiles" -lsqlite3
-#Lib_Module_RatingCurrent = "-L$(ModularizationPath)" -lModule_RatingCurrent
+ModuleUpgrade_H = -include$(ModularizationPath)/Module_Upgrade.h
 
+Lib_SQLite3 = "-L$(ModularizationPath)/ocppfiles" -lsqlite3
 SQLite3_H = -include$(ModularizationPath)/ocppfiles/sqlite3.h
-ModuleUpgrade_H = -include$(ModularizationPath)/Module_Upgrade.h
-RFID_H = -include$(ModularizationPath)/Module_RFID.h
-#RatingCurrent_H = -include$(ModularizationPath)/Module_RatingCurrent.h
+
+Lib_Module_RatedCurrent = "-L$(ModularizationPath)" -lModule_RatedCurrent
+RatedCurrent_H = -include$(ModularizationPath)/Module_RatedCurrent.h
 
 InfypwrPsuComm_H = -include$(ModularizationPath)/Infypwr_PsuCommObj.h
 InfypwrPsuComm_A = $(ModularizationPath)/libInfypwr_PsuCommObj.a
@@ -39,9 +41,9 @@ apps: MainTask DoCommTask EvCommTask \
 LOG_INC = Log
 
 MainTask:
-	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o main.o ReMain.c
-	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(CFLAGS) -o timeout.o timeout.c
-	$(CC) $(TFLAGS) -o main main.o timeout.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatingCurrent)
+	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -o main.o ReMain.c
+	$(CC) -D $(Project) -includeConfig.h $(SQLite3_H) $(ModuleUpgrade_H) $(RFID_H) $(RatedCurrent_H) $(CFLAGS) -o timeout.o timeout.c
+	$(CC) $(TFLAGS) -o main main.o timeout.o ${Lib_Module_RFID} ${Lib_Module_Upgrade} ${Lib_SQLite3} $(Lib_Module_RatedCurrent)
 
 DoCommTask:
 	$(CC) -D $(Project) -includeConfig.h $(CFLAGS) -o DoComm.o ReDoComm.c

BIN
EVSE/Projects/DD360Audi/Images/ramdisk.gz


BIN
EVSE/Projects/DD360Audi/output/DoComm


BIN
EVSE/Projects/DD360Audi/output/FactoryConfig


BIN
EVSE/Projects/DD360Audi/output/Module_EvComm


BIN
EVSE/Projects/DD360Audi/output/Module_EventLogging


BIN
EVSE/Projects/DD360Audi/output/Module_InternalComm


BIN
EVSE/Projects/DD360Audi/output/Module_LcmControl


BIN
EVSE/Projects/DD360Audi/output/Module_PrimaryComm


BIN
EVSE/Projects/DD360Audi/output/ReadCmdline


BIN
EVSE/Projects/DD360Audi/output/main