WebService.c 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455
  1. #include <sys/time.h>
  2. #include <sys/timeb.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/types.h>
  6. #include <sys/ioctl.h>
  7. #include <sys/socket.h>
  8. #include <sys/ipc.h>
  9. #include <sys/shm.h>
  10. #include <sys/shm.h>
  11. #include <sys/mman.h>
  12. #include <linux/wireless.h>
  13. #include <arpa/inet.h>
  14. #include <netinet/in.h>
  15. #include <unistd.h>
  16. #include <stdarg.h>
  17. #include <stdio.h> /*標準輸入輸出定義*/
  18. #include <stdlib.h> /*標準函數庫定義*/
  19. #include <unistd.h> /*Unix 標準函數定義*/
  20. #include <fcntl.h> /*檔控制定義*/
  21. #include <termios.h> /*PPSIX 終端控制定義*/
  22. #include <errno.h> /*錯誤號定義*/
  23. #include <errno.h>
  24. #include <string.h>
  25. #include <time.h>
  26. #include <ctype.h>
  27. #include <ifaddrs.h>
  28. #include "../Projects/define.h"
  29. #include "json.h"
  30. //#include <json-c/json.h>
  31. #include <math.h>
  32. #define DEBUG_INFO(format, args...) StoreLogMsg("[%s:%d][%s][Info] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  33. #define DEBUG_WARN(format, args...) StoreLogMsg("[%s:%d][%s][Warn] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  34. #define DEBUG_ERROR(format, args...) StoreLogMsg("[%s:%d][%s][Error] "format, __FILE__, __LINE__, __FUNCTION__, ##args)
  35. #define Debug
  36. #define SystemLogMessage
  37. #define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
  38. #define PASS 1
  39. #define FAIL -1
  40. struct SysConfigAndInfo *ShmSysConfigAndInfo;
  41. struct StatusCodeData *ShmStatusCodeData;
  42. void trim(char *s);
  43. int mystrcmp(char *p1, char *p2);
  44. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
  45. void split(char **arr, char *str, const char *del);
  46. #ifdef SystemLogMessage
  47. int StoreLogMsg(const char *fmt, ...) {
  48. char Buf[4096 + 256];
  49. char buffer[4096];
  50. time_t CurrentTime;
  51. struct tm *tm;
  52. va_list args;
  53. va_start(args, fmt);
  54. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  55. va_end(args);
  56. memset(Buf, 0, sizeof(Buf));
  57. CurrentTime = time(NULL);
  58. tm = localtime(&CurrentTime);
  59. sprintf(Buf,
  60. "echo \"[%04d.%02d.%02d %02d:%02d:%02d] - %s\" >> /Storage/SystemLog/[%04d.%02d]SystemLog",
  61. tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour,
  62. tm->tm_min, tm->tm_sec, buffer, tm->tm_year + 1900, tm->tm_mon + 1);
  63. system(Buf);
  64. #ifdef Debug
  65. printf("[%04d.%02d.%02d %02d:%02d:%02d] - %s", tm->tm_year + 1900,
  66. tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec,
  67. buffer);
  68. #endif
  69. return rc;
  70. }
  71. #endif
  72. int DiffTimeb(struct timeb ST, struct timeb ET) {
  73. //return milli-second
  74. unsigned int StartTime, StopTime;
  75. StartTime = (unsigned int) ST.time;
  76. StopTime = (unsigned int) ET.time;
  77. return (StopTime - StartTime) * 1000 + ET.millitm - ST.millitm;
  78. }
  79. //=================================
  80. // Common routine
  81. //=================================
  82. void trim(char *s) {
  83. int i = 0, j, k, l = 0;
  84. while ((s[i] == ' ') || (s[i] == '\t') || (s[i] == '\n'))
  85. i++;
  86. j = strlen(s) - 1;
  87. while ((s[j] == ' ') || (s[j] == '\t') || (s[j] == '\n'))
  88. j--;
  89. if (i == 0 && j == strlen(s) - 1) {
  90. } else if (i == 0)
  91. s[j + 1] = '\0';
  92. else {
  93. for (k = i; k <= j; k++)
  94. s[l++] = s[k];
  95. s[l] = '\0';
  96. }
  97. }
  98. int mystrcmp(char *p1, char *p2) {
  99. while (*p1 == *p2) {
  100. if (*p1 == '\0' || *p2 == '\0')
  101. break;
  102. p1++;
  103. p2++;
  104. }
  105. if (*p1 == '\0' && *p2 == '\0')
  106. return (PASS);
  107. else
  108. return (FAIL);
  109. }
  110. void substr(char *dest, const char* src, unsigned int start, unsigned int cnt) {
  111. strncpy(dest, src + start, cnt);
  112. dest[cnt] = 0;
  113. }
  114. void split(char **arr, char *str, const char *del) {
  115. char *s = strtok(str, del);
  116. while (s != NULL) {
  117. *arr++ = s;
  118. s = strtok(NULL, del);
  119. }
  120. }
  121. int ConnectorType(char* connector){
  122. int* result;
  123. if(strcmp(connector, "0") == 0){
  124. result= 0;
  125. }
  126. else if(strcmp(connector, "U") == 0 || strcmp(connector, "E") == 0){
  127. result= 1;//CCS
  128. }
  129. else if(strcmp(connector, "G") == 0 || strcmp(connector, "D") == 0){
  130. result= 2;//GB
  131. }
  132. else if(strcmp(connector, "J") == 0){
  133. result= 3;//CHAdeMO
  134. }
  135. else if(strcmp(connector, "1") == 0 || strcmp(connector, "2") == 0 || strcmp(connector, "3") == 0 || strcmp(connector, "4") == 0 || strcmp(connector, "5") == 0 || strcmp(connector, "6") == 0){
  136. result= 4;//AC
  137. }
  138. else{
  139. }
  140. return result;
  141. }
  142. int ModelType(char* type,char* network){
  143. int result=0;
  144. if(strcmp(type, "A") == 0){
  145. if(strcmp(network, "0") == 0 || strcmp(network, "R") == 0 || strcmp(network, "B") == 0){
  146. result=0;
  147. }
  148. else if(strcmp(network, "E") == 0 || strcmp(network, "W") == 0 || strcmp(network, "T") == 0 || strcmp(network, "U") == 0){
  149. result=1;
  150. }
  151. }
  152. else if(strcmp(type, "D") == 0){
  153. result=2;
  154. }
  155. return result;
  156. }
  157. //==========================================
  158. // Init all share memory
  159. //==========================================
  160. int InitShareMemory() {
  161. int result = PASS;
  162. int MeterSMId;
  163. //creat ShmSysConfigAndInfo
  164. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey,
  165. sizeof(struct SysConfigAndInfo), 0777)) < 0) {
  166. #ifdef SystemLogMessage
  167. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  168. #endif
  169. result = FAIL;
  170. } else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0))
  171. == (void *) -1) {
  172. #ifdef SystemLogMessage
  173. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  174. #endif
  175. result = FAIL;
  176. } else {
  177. }
  178. //creat ShmStatusCodeData
  179. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData),
  180. 0777)) < 0) {
  181. #ifdef SystemLogMessage
  182. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  183. #endif
  184. result = FAIL;
  185. } else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1) {
  186. #ifdef SystemLogMessage
  187. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  188. #endif
  189. result = FAIL;
  190. } else {
  191. }
  192. return result;
  193. }
  194. int StoreUsrConfigData(struct SysConfigData *UsrData)
  195. {
  196. int fd,wrd;
  197. unsigned int i,Chk;
  198. unsigned char *ptr;
  199. Chk=0;
  200. ptr=(unsigned char *)UsrData;
  201. for(i=0;i<sizeof(struct SysConfigData)-4;i++)
  202. {
  203. Chk+=*(ptr+i);
  204. }
  205. UsrData->Checksum=Chk;
  206. fd = open("/dev/mtdblock10", O_RDWR);
  207. if (fd < 0)
  208. {
  209. #ifdef SystemLogMessage
  210. StoreLogMsg("[main]StoreUsrConfigData: open /dev/mtdblock10 NG");
  211. #endif
  212. return 0;
  213. }
  214. wrd=write(fd, UsrData, sizeof(struct SysConfigData));
  215. close(fd);
  216. if(wrd!=(sizeof(struct SysConfigData)))
  217. {
  218. #ifdef SystemLogMessage
  219. StoreLogMsg("[main]StoreUsrConfigData: write /dev/mtdblock10 NG");
  220. #endif
  221. return 0;
  222. }
  223. fd = open("/dev/mtdblock11", O_RDWR);
  224. if (fd < 0)
  225. {
  226. #ifdef SystemLogMessage
  227. StoreLogMsg("[main]StoreUsrConfigData: open /dev/mtdblock11(backup) NG");
  228. #endif
  229. return 0;
  230. }
  231. wrd=write(fd, UsrData, sizeof(struct SysConfigData));
  232. close(fd);
  233. if(wrd!=(sizeof(struct SysConfigData)))
  234. {
  235. #ifdef SystemLogMessage
  236. StoreLogMsg("[main]StoreUsrConfigData: write /dev/mtdblock11(backup) NG");
  237. #endif
  238. return 0;
  239. }
  240. InitShareMemory();
  241. return 1;
  242. }
  243. //================================================
  244. // Main process
  245. //================================================
  246. int main(int argc, char *argv[]) {
  247. if (InitShareMemory() == FAIL) {
  248. #ifdef SystemLogMessage
  249. DEBUG_ERROR("InitShareMemory NG\n");
  250. #endif
  251. if (ShmStatusCodeData != NULL) {
  252. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory = 1;
  253. }
  254. sleep(5);
  255. return 0;
  256. }
  257. //web page submit
  258. if ((argc == 3) & (strlen(argv[1]) == 1)) {
  259. struct SysConfigData SysConfig;
  260. unsigned char *ptr;
  261. ptr=malloc(sizeof(struct SysConfigData));
  262. if(ptr==NULL)
  263. {
  264. #ifdef SystemLogMessage
  265. DEBUG_ERROR("malloc for SysConfigData NG");
  266. #endif
  267. return 0;
  268. }
  269. memset(ptr,0,sizeof(struct SysConfigData));
  270. memset(&SysConfig,0,sizeof(struct SysConfigData));
  271. //web page submit system
  272. if (strcmp(argv[1], "1") == 0) {
  273. struct json_object *jobj = json_tokener_parse(argv[2]);
  274. json_object *val_obj = NULL;
  275. const char *SystemId=NULL;
  276. const char *SystemDateTime = NULL;
  277. const char *AcPhaseCount = NULL;
  278. const char *FactoryConfiguration = NULL;
  279. const char *AuthorisationMode = NULL;
  280. const char *DefaultLanguage = NULL;
  281. const char *RfidCardNumEndian = NULL;
  282. if( json_object_object_get_ex(jobj, "SystemId", &val_obj) ) {
  283. SystemId = json_object_get_string(val_obj);
  284. }
  285. if( json_object_object_get_ex(jobj, "SystemDateTime", &val_obj) ) {
  286. SystemDateTime = json_object_get_string(val_obj);
  287. }
  288. if( json_object_object_get_ex(jobj, "AcPhaseCount", &val_obj) ) {
  289. AcPhaseCount = json_object_get_string(val_obj);
  290. }
  291. if( json_object_object_get_ex(jobj, "FactoryConfiguration", &val_obj) ) {
  292. FactoryConfiguration = json_object_get_string(val_obj);
  293. }
  294. if( json_object_object_get_ex(jobj, "AuthorisationMode", &val_obj) ) {
  295. AuthorisationMode = json_object_get_string(val_obj);
  296. }
  297. if( json_object_object_get_ex(jobj, "DefaultLanguage", &val_obj) ) {
  298. DefaultLanguage = json_object_get_string(val_obj);
  299. }
  300. if( json_object_object_get_ex(jobj, "RfidCardNumEndian", &val_obj) ) {
  301. RfidCardNumEndian = json_object_get_string(val_obj);
  302. }
  303. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId,SystemId);
  304. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AcPhaseCount,AcPhaseCount);
  305. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration,FactoryConfiguration);
  306. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AuthorisationMode,AuthorisationMode);
  307. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.DefaultLanguage,DefaultLanguage);
  308. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian,RfidCardNumEndian);
  309. //Set default configuration
  310. strcpy((char *)&SysConfig.SystemId, SystemId);
  311. strcpy((char *)&SysConfig.AcPhaseCount, AcPhaseCount);
  312. strcpy((char *)&SysConfig.AuthorisationMode, AuthorisationMode);
  313. strcpy((char *)&SysConfig.DefaultLanguage, DefaultLanguage);
  314. strcpy((char *)&SysConfig.RfidCardNumEndian,RfidCardNumEndian);
  315. if(strlen(SystemDateTime)>0){
  316. char cmd[100];
  317. sprintf(cmd,"date -s '%s'",SystemDateTime);
  318. if(system(cmd)==0){
  319. system("hwclock -w");
  320. }
  321. }
  322. }
  323. if (strcmp(argv[1], "2") == 0) {
  324. struct json_object *jobj = json_tokener_parse(argv[2]);
  325. json_object *val_obj = NULL;
  326. const int *MaxChargingEnergy= 0;
  327. const int *MaxChargingPower = 0;
  328. const int *MaxChargingCurrent = 0;
  329. const int *MaxChargingDuration = 0;
  330. const char *PhaseLossPolicy = NULL;
  331. const char *LocalWhiteCard0 = NULL;
  332. const char *LocalWhiteCard1 = NULL;
  333. const char *LocalWhiteCard2 = NULL;
  334. const char *LocalWhiteCard3 = NULL;
  335. const char *LocalWhiteCard4 = NULL;
  336. const char *LocalWhiteCard5 = NULL;
  337. const char *LocalWhiteCard6 = NULL;
  338. const char *LocalWhiteCard7 = NULL;
  339. const char *LocalWhiteCard8 = NULL;
  340. const char *LocalWhiteCard9 = NULL;
  341. if( json_object_object_get_ex(jobj, "MaxChargingEnergy", &val_obj) ) {
  342. MaxChargingEnergy = json_object_get_int(val_obj);
  343. }
  344. if( json_object_object_get_ex(jobj, "MaxChargingPower", &val_obj) ) {
  345. MaxChargingPower = json_object_get_int(val_obj);
  346. }
  347. if( json_object_object_get_ex(jobj, "MaxChargingCurrent", &val_obj) ) {
  348. MaxChargingCurrent = json_object_get_int(val_obj);
  349. }
  350. if( json_object_object_get_ex(jobj, "MaxChargingDuration", &val_obj) ) {
  351. MaxChargingDuration = json_object_get_int(val_obj);
  352. }
  353. if( json_object_object_get_ex(jobj, "PhaseLossPolicy", &val_obj) ) {
  354. PhaseLossPolicy = json_object_get_string(val_obj);
  355. }
  356. if( json_object_object_get_ex(jobj, "LocalWhiteCard0", &val_obj) ) {
  357. LocalWhiteCard0 = json_object_get_string(val_obj);
  358. }
  359. if( json_object_object_get_ex(jobj, "LocalWhiteCard1", &val_obj) ) {
  360. LocalWhiteCard1 = json_object_get_string(val_obj);
  361. }
  362. if( json_object_object_get_ex(jobj, "LocalWhiteCard2", &val_obj) ) {
  363. LocalWhiteCard2 = json_object_get_string(val_obj);
  364. }
  365. if( json_object_object_get_ex(jobj, "LocalWhiteCard3", &val_obj) ) {
  366. LocalWhiteCard3 = json_object_get_string(val_obj);
  367. }
  368. if( json_object_object_get_ex(jobj, "LocalWhiteCard4", &val_obj) ) {
  369. LocalWhiteCard4 = json_object_get_string(val_obj);
  370. }
  371. if( json_object_object_get_ex(jobj, "LocalWhiteCard5", &val_obj) ) {
  372. LocalWhiteCard5 = json_object_get_string(val_obj);
  373. }
  374. if( json_object_object_get_ex(jobj, "LocalWhiteCard6", &val_obj) ) {
  375. LocalWhiteCard6 = json_object_get_string(val_obj);
  376. }
  377. if( json_object_object_get_ex(jobj, "LocalWhiteCard7", &val_obj) ) {
  378. LocalWhiteCard7 = json_object_get_string(val_obj);
  379. }
  380. if( json_object_object_get_ex(jobj, "LocalWhiteCard8", &val_obj) ) {
  381. LocalWhiteCard8 = json_object_get_string(val_obj);
  382. }
  383. if( json_object_object_get_ex(jobj, "LocalWhiteCard9", &val_obj) ) {
  384. LocalWhiteCard9 = json_object_get_string(val_obj);
  385. }
  386. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy = MaxChargingEnergy;
  387. ShmSysConfigAndInfo->SysConfig.MaxChargingPower = MaxChargingPower;
  388. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent = MaxChargingCurrent;
  389. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration = MaxChargingDuration;
  390. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy,PhaseLossPolicy);
  391. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0],LocalWhiteCard0);
  392. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1],LocalWhiteCard1);
  393. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2],LocalWhiteCard2);
  394. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3],LocalWhiteCard3);
  395. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4],LocalWhiteCard4);
  396. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5],LocalWhiteCard5);
  397. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6],LocalWhiteCard6);
  398. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7],LocalWhiteCard7);
  399. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8],LocalWhiteCard8);
  400. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9],LocalWhiteCard9);
  401. //Set default configuration
  402. SysConfig.MaxChargingEnergy = MaxChargingEnergy;
  403. SysConfig.MaxChargingPower = MaxChargingPower;
  404. SysConfig.MaxChargingCurrent = MaxChargingCurrent;
  405. SysConfig.MaxChargingDuration = MaxChargingDuration;
  406. strcpy((char *)&SysConfig.PhaseLossPolicy,PhaseLossPolicy);
  407. strcpy((char *)&SysConfig.LocalWhiteCard[0],LocalWhiteCard0);
  408. strcpy((char *)&SysConfig.LocalWhiteCard[1],LocalWhiteCard1);
  409. strcpy((char *)&SysConfig.LocalWhiteCard[2],LocalWhiteCard2);
  410. strcpy((char *)&SysConfig.LocalWhiteCard[3],LocalWhiteCard3);
  411. strcpy((char *)&SysConfig.LocalWhiteCard[4],LocalWhiteCard4);
  412. strcpy((char *)&SysConfig.LocalWhiteCard[5],LocalWhiteCard5);
  413. strcpy((char *)&SysConfig.LocalWhiteCard[6],LocalWhiteCard6);
  414. strcpy((char *)&SysConfig.LocalWhiteCard[7],LocalWhiteCard7);
  415. strcpy((char *)&SysConfig.LocalWhiteCard[8],LocalWhiteCard8);
  416. strcpy((char *)&SysConfig.LocalWhiteCard[9],LocalWhiteCard9);
  417. }
  418. if (strcmp(argv[1], "3") == 0) {
  419. struct json_object *jobj = json_tokener_parse(argv[2]);
  420. json_object *val_obj = NULL;
  421. const char *FtpServer=NULL;
  422. const char *Eth0DhcpClient=NULL;
  423. const char *Eth0IpAddress=NULL;
  424. const char *Eth0SubmaskAddress=NULL;
  425. const char *Eth0GatewayAddress=NULL;
  426. const char *Eth1DhcpClient=NULL;
  427. const char *Eth1IpAddress=NULL;
  428. const char *Eth1SubmaskAddress=NULL;
  429. const char *Eth1GatewayAddress=NULL;
  430. const char *WifiMode=NULL;
  431. const char *WifiSsid=NULL;
  432. const char *WifiPassword=NULL;
  433. const char *WifiDhcpServer=NULL;
  434. const char *WifiDhcpClient=NULL;
  435. const char *WifiIpAddress=NULL;
  436. const char *WifiSubmaskAddress=NULL;
  437. const char *WifiGatewayAddress=NULL;
  438. const char *TelcomApn=NULL;
  439. const char *TelcomChapPapId=NULL;
  440. const char *TelcomChapPapPwd=NULL;
  441. const char *TelcomIpAddress=NULL;
  442. if( json_object_object_get_ex(jobj, "FtpServer", &val_obj) ) {
  443. FtpServer = json_object_get_string(val_obj);
  444. }
  445. if( json_object_object_get_ex(jobj, "Eth0DhcpClient", &val_obj) ) {
  446. Eth0DhcpClient = json_object_get_string(val_obj);
  447. }
  448. if( json_object_object_get_ex(jobj, "Eth0IpAddress", &val_obj) ) {
  449. Eth0IpAddress = json_object_get_string(val_obj);
  450. }
  451. if( json_object_object_get_ex(jobj, "Eth0SubmaskAddress", &val_obj) ) {
  452. Eth0SubmaskAddress = json_object_get_string(val_obj);
  453. }
  454. if( json_object_object_get_ex(jobj, "Eth0GatewayAddress", &val_obj) ) {
  455. Eth0GatewayAddress = json_object_get_string(val_obj);
  456. }
  457. if( json_object_object_get_ex(jobj, "Eth1DhcpClient", &val_obj) ) {
  458. Eth1DhcpClient = json_object_get_string(val_obj);
  459. }
  460. if( json_object_object_get_ex(jobj, "Eth1IpAddress", &val_obj) ) {
  461. Eth1IpAddress = json_object_get_string(val_obj);
  462. }
  463. if( json_object_object_get_ex(jobj, "Eth1SubmaskAddress", &val_obj) ) {
  464. Eth1SubmaskAddress = json_object_get_string(val_obj);
  465. }
  466. if( json_object_object_get_ex(jobj, "Eth1GatewayAddress", &val_obj) ) {
  467. Eth1GatewayAddress = json_object_get_string(val_obj);
  468. }
  469. if( json_object_object_get_ex(jobj, "WifiMode", &val_obj) ) {
  470. WifiMode = json_object_get_string(val_obj);
  471. }
  472. if( json_object_object_get_ex(jobj, "WifiSsid", &val_obj) ) {
  473. WifiSsid = json_object_get_string(val_obj);
  474. }
  475. if( json_object_object_get_ex(jobj, "WifiPassword", &val_obj) ) {
  476. WifiPassword = json_object_get_string(val_obj);
  477. }
  478. if( json_object_object_get_ex(jobj, "WifiDhcpServer", &val_obj) ) {
  479. WifiDhcpServer = json_object_get_string(val_obj);
  480. }
  481. if( json_object_object_get_ex(jobj, "WifiDhcpClient", &val_obj) ) {
  482. WifiDhcpClient = json_object_get_string(val_obj);
  483. }
  484. if( json_object_object_get_ex(jobj, "WifiIpAddress", &val_obj) ) {
  485. WifiIpAddress = json_object_get_string(val_obj);
  486. }
  487. if( json_object_object_get_ex(jobj, "WifiSubmaskAddress", &val_obj) ) {
  488. WifiSubmaskAddress = json_object_get_string(val_obj);
  489. }
  490. if( json_object_object_get_ex(jobj, "WifiGatewayAddress", &val_obj) ) {
  491. WifiGatewayAddress = json_object_get_string(val_obj);
  492. }
  493. if( json_object_object_get_ex(jobj, "TelcomApn", &val_obj) ) {
  494. TelcomApn = json_object_get_string(val_obj);
  495. }
  496. if( json_object_object_get_ex(jobj, "TelcomChapPapId", &val_obj) ) {
  497. TelcomChapPapId = json_object_get_string(val_obj);
  498. }
  499. if( json_object_object_get_ex(jobj, "TelcomChapPapPwd", &val_obj) ) {
  500. TelcomChapPapPwd = json_object_get_string(val_obj);
  501. }
  502. if( json_object_object_get_ex(jobj, "TelcomIpAddress", &val_obj) ) {
  503. TelcomIpAddress = json_object_get_string(val_obj);
  504. }
  505. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.FtpServer,FtpServer);
  506. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,Eth0DhcpClient);
  507. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,Eth0IpAddress);
  508. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,Eth0SubmaskAddress);
  509. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress,Eth0GatewayAddress);
  510. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,Eth1DhcpClient);
  511. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,Eth1IpAddress);
  512. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress,Eth1SubmaskAddress);
  513. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress,Eth1GatewayAddress);
  514. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode,WifiMode);
  515. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid,WifiSsid);
  516. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword,WifiPassword);
  517. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,WifiDhcpServer);
  518. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,WifiDhcpClient);
  519. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress,WifiIpAddress);
  520. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress,WifiSubmaskAddress);
  521. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress,WifiGatewayAddress);
  522. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn,TelcomApn);
  523. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId,TelcomChapPapId);
  524. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd,TelcomChapPapPwd);
  525. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress,TelcomIpAddress);
  526. //Set default configuration
  527. strcpy((char *)&SysConfig.FtpServer, FtpServer);
  528. strcpy((char *)&SysConfig.Eth0Interface.EthDhcpClient, Eth0DhcpClient);
  529. strcpy((char *)&SysConfig.Eth0Interface.EthIpAddress, Eth0IpAddress);
  530. strcpy((char *)&SysConfig.Eth0Interface.EthSubmaskAddress, Eth0SubmaskAddress);
  531. strcpy((char *)&SysConfig.Eth0Interface.EthGatewayAddress, Eth0GatewayAddress);
  532. strcpy((char *)&SysConfig.Eth1Interface.EthDhcpClient, Eth1DhcpClient);
  533. strcpy((char *)&SysConfig.Eth1Interface.EthIpAddress, Eth1IpAddress);
  534. strcpy((char *)&SysConfig.Eth1Interface.EthSubmaskAddress, Eth1SubmaskAddress);
  535. strcpy((char *)&SysConfig.Eth1Interface.EthGatewayAddress, Eth1GatewayAddress);
  536. strcpy((char *)&SysConfig.AthInterface.WifiMode, WifiMode);
  537. strcpy((char *)&SysConfig.AthInterface.WifiSsid, WifiSsid);
  538. strcpy((char *)&SysConfig.AthInterface.WifiPassword, WifiPassword);
  539. strcpy((char *)&SysConfig.AthInterface.WifiDhcpServer, WifiDhcpServer);
  540. strcpy((char *)&SysConfig.AthInterface.WifiDhcpClient, WifiDhcpClient);
  541. strcpy((char *)&SysConfig.AthInterface.WifiIpAddress, WifiIpAddress);
  542. strcpy((char *)&SysConfig.AthInterface.WifiSubmaskAddress, WifiSubmaskAddress);
  543. strcpy((char *)&SysConfig.AthInterface.WifiGatewayAddress, WifiGatewayAddress);
  544. strcpy((char *)&SysConfig.TelecomInterface.TelcomApn, TelcomApn);
  545. strcpy((char *)&SysConfig.TelecomInterface.TelcomChapPapId, TelcomChapPapId);
  546. strcpy((char *)&SysConfig.TelecomInterface.TelcomChapPapPwd, TelcomChapPapPwd);
  547. strcpy((char *)&SysConfig.TelecomInterface.TelcomIpAddress, TelcomIpAddress);
  548. }
  549. if (strcmp(argv[1], "4") == 0) {
  550. struct json_object *jobj = json_tokener_parse(argv[2]);
  551. json_object *val_obj = NULL;
  552. const int *BackendConnTimeout=0;
  553. const char *OfflinePolicy=NULL;
  554. const int *OfflineMaxChargeEnergy=0;
  555. const int *OfflineMaxChargeDuration=0;
  556. const char *OcppServerURL=NULL;
  557. const char *ChargeBoxId=NULL;
  558. if( json_object_object_get_ex(jobj, "BackendConnTimeout", &val_obj) ) {
  559. //BackendConnTimeout = json_object_get_string(val_obj);
  560. BackendConnTimeout = json_object_get_int(val_obj);
  561. }
  562. if( json_object_object_get_ex(jobj, "OfflinePolicy", &val_obj) ) {
  563. OfflinePolicy = json_object_get_string(val_obj);
  564. }
  565. if( json_object_object_get_ex(jobj, "OfflineMaxChargeEnergy", &val_obj) ) {
  566. //OfflineMaxChargeEnergy = json_object_get_string(val_obj);
  567. OfflineMaxChargeEnergy = json_object_get_int(val_obj);
  568. }
  569. if( json_object_object_get_ex(jobj, "OfflineMaxChargeDuration", &val_obj) ) {
  570. //OfflineMaxChargeDuration = json_object_get_string(val_obj);
  571. OfflineMaxChargeDuration = json_object_get_int(val_obj);
  572. }
  573. if( json_object_object_get_ex(jobj, "OcppServerURL", &val_obj) ) {
  574. OcppServerURL = json_object_get_string(val_obj);
  575. }
  576. if( json_object_object_get_ex(jobj, "ChargeBoxId", &val_obj) ) {
  577. ChargeBoxId = json_object_get_string(val_obj);
  578. }
  579. ShmSysConfigAndInfo->SysConfig.BackendConnTimeout = BackendConnTimeout;
  580. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,OfflinePolicy);
  581. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy = OfflineMaxChargeEnergy;
  582. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration = OfflineMaxChargeDuration;
  583. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,OcppServerURL);
  584. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,ChargeBoxId);
  585. //Set default configuration
  586. SysConfig.BackendConnTimeout=(int)BackendConnTimeout;
  587. strcpy((char *)&SysConfig.OfflinePolicy, OfflinePolicy);
  588. SysConfig.OfflineMaxChargeEnergy=(int)OfflineMaxChargeEnergy;
  589. SysConfig.OfflineMaxChargeDuration=(int)OfflineMaxChargeDuration;
  590. strcpy((char *)&SysConfig.OcppServerURL, OcppServerURL);
  591. strcpy((char *)&SysConfig.ChargeBoxId, ChargeBoxId);
  592. }
  593. StoreUsrConfigData(&SysConfig);
  594. #ifdef SystemLogMessage
  595. DEBUG_INFO("WebServiceConfig update OK");
  596. #endif
  597. }
  598. if (argc == 2) { //init share memory for test
  599. if (strcmp(argv[1], "aaa") == 0) {
  600. struct SysConfigData SysConfig;
  601. //system
  602. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ModelName, "DWLU700111W1PH");
  603. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber, "SerialNumber");
  604. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemId, "1234567890");
  605. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.SystemDateTime, "SystemDateTime");
  606. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AcPhaseCount, "1");
  607. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration, "1");
  608. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AuthorisationMode, "1");
  609. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.DefaultLanguage, "a");
  610. ShmSysConfigAndInfo->SysInfo.InputVoltageR=0;
  611. ShmSysConfigAndInfo->SysInfo.InputVoltageS=0;
  612. ShmSysConfigAndInfo->SysInfo.InputVoltageT=0;
  613. ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed=0;
  614. ShmSysConfigAndInfo->SysInfo.PsuFanRotaSpeed=0;
  615. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian, "0");
  616. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower5V, "0");
  617. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower12V, "0");
  618. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower24V, "0");
  619. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower48V, "0");
  620. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CsuHwRev, "CsuHwRev");
  621. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev, "CsuBootLoadFwRev");
  622. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev, "CsuKernelFwRev");
  623. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev, "CsuRootFsFwRev");
  624. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev, "CsuPrimFwRev");
  625. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.LcmHwRev, "LcmHwRev");
  626. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.LcmFwRev, "LcmFwRev");
  627. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.PsuHwRev, "PsuHwRev");
  628. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev, "PsuPrimFwRev");
  629. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.PsuSecFwRev, "PsuSecFwRev");
  630. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPwrHwRev, "AuxPwrHwRev");
  631. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.AuxPwrFwRev, "AuxPwrFwRev");
  632. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FanModuleHwRev, "FanModuleHwRev");
  633. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FanModuleFwRev, "FanModuleFwRev");
  634. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev, "RelayModuleHwRev");
  635. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev, "RelayModuleFwRev");
  636. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, "TelcomModemFwRev");
  637. ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp=0;
  638. ShmSysConfigAndInfo->SysInfo.SystemCriticalTemp=0;
  639. ShmSysConfigAndInfo->SysInfo.CcsConnectorTemp=0;
  640. ShmSysConfigAndInfo->SysInfo.PsuAmbientTemp=0;
  641. ShmSysConfigAndInfo->SysConfig.AcPlugInTimes=0;
  642. ShmSysConfigAndInfo->SysConfig.GbPlugInTimes=0;
  643. ShmSysConfigAndInfo->SysConfig.Ccs1PlugInTime=0;
  644. ShmSysConfigAndInfo->SysConfig.Ccs2PlugInTimes=0;
  645. ShmSysConfigAndInfo->SysConfig.ChademoPlugInTimes=0;
  646. //Set default configuration
  647. strcpy(SysConfig.SystemId, "0987654321");
  648. strcpy(SysConfig.SystemDateTime, "2019-08-12 00:00:00");
  649. //charging
  650. ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy=0;
  651. ShmSysConfigAndInfo->SysConfig.MaxChargingPower=0;
  652. ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent= 0;
  653. ShmSysConfigAndInfo->SysConfig.MaxChargingDuration=0;
  654. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy, "1");
  655. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0], "111");
  656. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1], "222");
  657. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2], "333");
  658. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3], "444");
  659. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4], "555");
  660. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5], "666");
  661. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6], "777");
  662. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7], "888");
  663. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8], "999");
  664. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9], "aaa");
  665. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.UserId, "UserId");
  666. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingVoltage=(float) 64;
  667. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingCurrent=(double) 6553.5;
  668. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargingPower=0;
  669. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargedEnergy=0;
  670. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].PresentChargedDuration=0;
  671. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].RemainChargingDuration=0;
  672. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatteryMaxVoltage=0;
  673. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterytargetVoltage=0;
  674. ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterySoc=0;
  675. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].SystemStatus, "1");
  676. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].Index, "1");
  677. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].Type, "0");
  678. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].type_index, "1");
  679. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[0].EvBatterytargetCurrent, "1");
  680. //network
  681. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.InternetConn,"1");
  682. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.FtpServer,"FtpServer");
  683. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,"1");
  684. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress,"EthMacAddress");
  685. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress,"EthIpAddress");
  686. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress,"EthIpAddress");
  687. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress,"EthGatewayAddress");
  688. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,"1");
  689. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthMacAddress,"EthMacAddress");
  690. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress,"EthIpAddress");
  691. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress,"EthSubmaskAddress");
  692. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress,"EthGatewayAddress");
  693. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode,"1");
  694. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid,"WifiSsid");
  695. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword,"WifiSsid");
  696. ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi=0;
  697. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,"1");
  698. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,"1");
  699. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress,"WifiMacAddress");
  700. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress,"WifiIpAddress");
  701. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress,"WifiSubmaskAddress");
  702. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress,"WifiGatewayAddress");
  703. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn,"TelcomApn");
  704. ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi=0;
  705. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId,"TelcomChapPapId");
  706. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd,"TelcomChapPapPwd");
  707. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei,"TelcomModemImei");
  708. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi,"TelcomSimImsi");
  709. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus,"1");
  710. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode,"1");
  711. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress,"TelcomIpAddress");
  712. //backend
  713. ShmSysConfigAndInfo->SysConfig.BackendConnTimeout=0;
  714. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,"1");
  715. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy=0;
  716. ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration=0;
  717. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.OcppConnStatus,"1");
  718. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL,"OcppServerURL");
  719. strcpy((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId,"ChargeBoxId");
  720. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate,"0");
  721. StoreUsrConfigData(&SysConfig);
  722. #ifdef SystemLogMessage
  723. DEBUG_INFO("WebService initial OK");
  724. #endif
  725. }
  726. if (strcmp(argv[1], "log") == 0) {
  727. time_t tt = time(0); //獲取當前時間
  728. int year,month;
  729. char cmd[100];
  730. struct tm *pst = localtime(&tt); //把time_t類型轉換為struct tm類型
  731. year = pst->tm_year + 1900;
  732. month = pst->tm_mon + 1;
  733. sprintf(cmd,"cp /mnt/%04d-%02d.zip /var/www/log.zip",year,month);
  734. if(system("exec /root/logPackTools 'log'")==0){
  735. system(cmd);
  736. }
  737. }
  738. }
  739. //upgrade firmware
  740. if ((argc == 3) & (strcmp(argv[1], "upgrade") == 0)) {
  741. struct json_object *jobj;
  742. struct json_object *Result;
  743. struct json_object *Message;
  744. char cmd[100];
  745. jobj=json_object_new_object();
  746. //system
  747. //if((char)ShmSysConfigAndInfo->SysInfo.FirmwareUpdate == '0'){
  748. strcpy((char *)&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate, "1");
  749. Result = json_object_new_string("success");
  750. Message = json_object_new_string("file is uploaded");
  751. //}
  752. /*else{
  753. sprintf(cmd,"rm /mnt/%s",argv[2]);
  754. system(cmd);
  755. Result = json_object_new_string("error");
  756. Message = json_object_new_string("machine is busy");
  757. }*/
  758. json_object_object_add(jobj,"Result",Result);
  759. json_object_object_add(jobj,"Message",Message);
  760. printf("%s\n", json_object_to_json_string(jobj));
  761. }
  762. //web page query all
  763. if ((argc == 2) & (strcmp(argv[1], "query") == 0)) {
  764. char *IsAcDc[2];
  765. char *Connector1[2];
  766. char *Connector2[2];
  767. char *Connector3[2];
  768. char *Network[2];
  769. substr((char *)IsAcDc,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,0,1);
  770. substr((char *)Connector1,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,7,1);
  771. substr((char *)Connector2,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,8,1);
  772. substr((char *)Connector3,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,9,1);
  773. substr((char *)Network,(const char *)ShmSysConfigAndInfo->SysConfig.ModelName,10,1);
  774. int connectorType1,connectorType2,connectorType3;
  775. connectorType1=ConnectorType((char *)Connector1);
  776. connectorType2=ConnectorType((char *)Connector2);
  777. connectorType3=ConnectorType((char *)Connector3);
  778. // modelType=ModelType((char *)IsAcDc,(char *)Network);
  779. // printf("modelType:%d\n",modelType);
  780. struct json_object *jobj1;
  781. struct json_object *jobj2;
  782. struct json_object *jobj3;
  783. struct json_object *jobj4;
  784. // struct json_object *array_obj;
  785. //system
  786. struct json_object *ModelName;
  787. struct json_object *SerialNumber;
  788. struct json_object *SystemId;
  789. // struct json_object *SystemDateTime;
  790. struct json_object *AcPhaseCount;
  791. struct json_object *FactoryConfiguration;
  792. struct json_object *AuthorisationMode;
  793. struct json_object *DefaultLanguage;
  794. struct json_object *InputVoltageR;
  795. struct json_object *InputVoltageS;
  796. struct json_object *InputVoltageT;
  797. struct json_object *SystemFanRotaSpeed;
  798. struct json_object *PsuFanRotaSpeed;
  799. struct json_object *RfidCardNumEndian;
  800. struct json_object *AuxPower5V;
  801. struct json_object *AuxPower12V;
  802. struct json_object *AuxPower24V;
  803. struct json_object *AuxPower48V;
  804. struct json_object *CsuHwRev;
  805. struct json_object *CsuBootLoadFwRev;
  806. struct json_object *CsuKernelFwRev;
  807. struct json_object *CsuRootFsFwRev;
  808. struct json_object *CsuPrimFwRev;
  809. struct json_object *LcmHwRev;
  810. struct json_object *LcmFwRev;
  811. struct json_object *PsuHwRev;
  812. struct json_object *PsuPrimFwRev;
  813. struct json_object *PsuSecFwRev;
  814. struct json_object *AuxPwrHwRev;
  815. struct json_object *AuxPwrFwRev;
  816. struct json_object *FanModuleHwRev;
  817. struct json_object *FanModuleFwRev;
  818. struct json_object *RelayModuleHwRev;
  819. struct json_object *RelayModuleFwRev;
  820. struct json_object *TelcomModemFwRev;
  821. struct json_object *SystemAmbientTemp;
  822. struct json_object *SystemCriticalTemp;
  823. struct json_object *CcsConnectorTemp;
  824. struct json_object *PsuAmbientTemp;
  825. struct json_object *AcPlugInTimes;
  826. struct json_object *GbPlugInTimes;
  827. struct json_object *Ccs1PlugInTime;
  828. struct json_object *Ccs2PlugInTimes;
  829. struct json_object *ChademoPlugInTimes;
  830. struct json_object *FirmwareUpdate;
  831. //charging
  832. struct json_object *MaxChargingEnergy;
  833. struct json_object *MaxChargingPower;
  834. struct json_object *MaxChargingCurrent;
  835. struct json_object *MaxChargingDuration;
  836. struct json_object *PhaseLossPolicy;
  837. struct json_object *LocalWhiteCard[10];
  838. struct json_object *LocalWhiteCardArr= json_object_new_array();
  839. // struct json_object *CcsAuthentication;
  840. // struct json_object *AcCcsChargingMode;
  841. struct json_object *UserId;
  842. struct json_object *ChargingInfo1;
  843. struct json_object *ChargingInfo2;
  844. struct json_object *ChargingInfo3;
  845. struct json_object *PresentChargingVoltage[3];
  846. struct json_object *PresentChargingCurrent[3];
  847. struct json_object *PresentChargingPower[3];
  848. struct json_object *PresentChargedEnergy[3];
  849. struct json_object *PresentChargedDuration[3];
  850. struct json_object *RemainChargingDuration[3];
  851. struct json_object *EvBatteryMaxVoltage[3];
  852. struct json_object *EvBatterytargetVoltage[3];
  853. struct json_object *EvBatterySoc[3];
  854. struct json_object *SystemStatus[3];
  855. struct json_object *Index[3];
  856. struct json_object *Type[3];
  857. struct json_object *type_index[3];
  858. struct json_object *EvBatterytargetCurrent[3];
  859. //network
  860. struct json_object *InternetConn;
  861. struct json_object *FtpServer;
  862. struct json_object *Eth0DhcpClient;
  863. struct json_object *Eth0MacAddress;
  864. struct json_object *Eth0IpAddress;
  865. struct json_object *Eth0SubmaskAddress;
  866. struct json_object *Eth0GatewayAddress;
  867. struct json_object *Eth1DhcpClient;
  868. struct json_object *Eth1MacAddress;
  869. struct json_object *Eth1IpAddress;
  870. struct json_object *Eth1SubmaskAddress;
  871. struct json_object *Eth1GatewayAddress;
  872. struct json_object *WifiMode;
  873. struct json_object *WifiSsid;
  874. struct json_object *WifiPassword;
  875. struct json_object *WifiRssi;
  876. struct json_object *WifiDhcpServer;
  877. struct json_object *WifiDhcpClient;
  878. struct json_object *WifiMacAddress;
  879. struct json_object *WifiIpAddress;
  880. struct json_object *WifiSubmaskAddress;
  881. struct json_object *WifiGatewayAddress;
  882. struct json_object *WifiNetworkConn;
  883. struct json_object *TelcomApn;
  884. struct json_object *TelcomRssi;
  885. struct json_object *TelcomChapPapId;
  886. struct json_object *TelcomChapPapPwd;
  887. struct json_object *TelcomModemImei;
  888. struct json_object *TelcomSimImsi;
  889. // struct json_object *TelcomSimIccid;
  890. struct json_object *TelcomSimStatus;
  891. struct json_object *TelcomModemMode;
  892. struct json_object *TelcomIpAddress;
  893. struct json_object *TelcomNetworkConn;
  894. //backend
  895. struct json_object *BackendConnTimeout;
  896. struct json_object *OfflinePolicy;
  897. struct json_object *OfflineMaxChargeEnergy;
  898. struct json_object *OfflineMaxChargeDuration;
  899. struct json_object *OcppConnStatus;
  900. struct json_object *OcppServerURL;
  901. struct json_object *ChargeBoxId;
  902. // array_obj = json_object_new_array();
  903. jobj1=json_object_new_object();
  904. jobj2=json_object_new_object();
  905. jobj3=json_object_new_object();
  906. jobj4=json_object_new_object();
  907. //system
  908. ModelName = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.ModelName);
  909. SerialNumber = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.SerialNumber);
  910. SystemId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.SystemId);
  911. // SystemDateTime = json_object_new_string(ShmSysConfigAndInfo->SysConfig.SystemDateTime);
  912. AcPhaseCount = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.AcPhaseCount,1);
  913. FactoryConfiguration = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.FactoryConfiguration,1);
  914. AuthorisationMode = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.AuthorisationMode,1);
  915. DefaultLanguage = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.DefaultLanguage,1);
  916. InputVoltageR = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageR);
  917. InputVoltageS = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageS);
  918. InputVoltageT = json_object_new_double(ShmSysConfigAndInfo->SysInfo.InputVoltageT);
  919. SystemFanRotaSpeed = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemFanRotaSpeed);
  920. PsuFanRotaSpeed = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.PsuFanRotaSpeed);
  921. RfidCardNumEndian = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.RfidCardNumEndian,1);
  922. AuxPower5V = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower5V,1);
  923. AuxPower12V = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower12V,1);
  924. AuxPower24V = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower24V,1);
  925. AuxPower48V = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AuxPower48V,1);
  926. CsuHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.CsuHwRev);
  927. CsuBootLoadFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.CsuBootLoadFwRev);
  928. CsuKernelFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.CsuKernelFwRev);
  929. CsuRootFsFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.CsuRootFsFwRev);
  930. CsuPrimFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.CsuPrimFwRev);
  931. LcmHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.LcmHwRev);
  932. LcmFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.LcmFwRev);
  933. PsuHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.PsuHwRev);
  934. PsuPrimFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.PsuPrimFwRev);
  935. PsuSecFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.PsuSecFwRev);
  936. AuxPwrHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.AuxPwrHwRev);
  937. AuxPwrFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.AuxPwrFwRev);
  938. FanModuleHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.FanModuleHwRev);
  939. FanModuleFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.FanModuleFwRev);
  940. RelayModuleHwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.RelayModuleHwRev);
  941. RelayModuleFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.RelayModuleFwRev);
  942. TelcomModemFwRev = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev);
  943. SystemAmbientTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemAmbientTemp);
  944. SystemCriticalTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.SystemCriticalTemp);
  945. CcsConnectorTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.CcsConnectorTemp);
  946. PsuAmbientTemp = json_object_new_int((int)ShmSysConfigAndInfo->SysInfo.PsuAmbientTemp);
  947. AcPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.AcPlugInTimes);
  948. GbPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.GbPlugInTimes);
  949. Ccs1PlugInTime = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.Ccs1PlugInTime);
  950. Ccs2PlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.Ccs2PlugInTimes);
  951. ChademoPlugInTimes = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.ChademoPlugInTimes);
  952. FirmwareUpdate = json_object_new_string((char *)&ShmSysConfigAndInfo->SysInfo.FirmwareUpdate);
  953. //charging
  954. int CcsGunQty=0;
  955. int GbGunQty=0;
  956. int CHAdeMOGunQty=0;
  957. int AcGunQty=0;
  958. ChargingInfo1=json_object_new_object();
  959. ChargingInfo2=json_object_new_object();
  960. ChargingInfo3=json_object_new_object();
  961. MaxChargingEnergy = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingEnergy);
  962. MaxChargingPower = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingPower);
  963. MaxChargingCurrent = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
  964. MaxChargingDuration = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.MaxChargingDuration);
  965. PhaseLossPolicy = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.PhaseLossPolicy,1);
  966. LocalWhiteCard[0] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[0]);
  967. LocalWhiteCard[1] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[1]);
  968. LocalWhiteCard[2] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[2]);
  969. LocalWhiteCard[3] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[3]);
  970. LocalWhiteCard[4] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[4]);
  971. LocalWhiteCard[5] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[5]);
  972. LocalWhiteCard[6] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[6]);
  973. LocalWhiteCard[7] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[7]);
  974. LocalWhiteCard[8] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[8]);
  975. LocalWhiteCard[9] = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.LocalWhiteCard[9]);
  976. UserId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.UserId);
  977. if(connectorType1 != 0){
  978. if(connectorType1 == 1){//CCS
  979. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  980. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  981. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  982. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  983. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  984. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  985. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  986. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  987. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  988. SystemStatus[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  989. Index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  990. Type[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  991. type_index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  992. EvBatterytargetCurrent[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  993. CcsGunQty++;
  994. }
  995. else if(connectorType1 == 2){//GB
  996. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  997. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  998. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  999. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  1000. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  1001. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  1002. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  1003. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  1004. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  1005. SystemStatus[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].SystemStatus,1);
  1006. Index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Index,1);
  1007. Type[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Type,1);
  1008. type_index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].type_index,1);
  1009. EvBatterytargetCurrent[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetCurrent,1);
  1010. GbGunQty++;
  1011. }
  1012. else if(connectorType1 == 3){//CHAdeMO
  1013. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  1014. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  1015. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  1016. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  1017. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  1018. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  1019. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  1020. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  1021. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  1022. SystemStatus[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].SystemStatus,1);
  1023. Index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Index,1);
  1024. Type[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Type,1);
  1025. type_index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].type_index,1);
  1026. EvBatterytargetCurrent[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  1027. CHAdeMOGunQty++;
  1028. }
  1029. else if(connectorType1 == 4){//AC
  1030. PresentChargingVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
  1031. PresentChargingCurrent[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
  1032. PresentChargingPower[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
  1033. PresentChargedEnergy[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
  1034. PresentChargedDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
  1035. RemainChargingDuration[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
  1036. EvBatteryMaxVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
  1037. EvBatterytargetVoltage[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
  1038. EvBatterySoc[0] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
  1039. SystemStatus[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus,1);
  1040. Index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index,1);
  1041. Type[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type,1);
  1042. type_index[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index,1);
  1043. EvBatterytargetCurrent[0] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent,1);
  1044. AcGunQty++;
  1045. }
  1046. }
  1047. if(connectorType2 != 0){
  1048. if(connectorType2 == 1){//CCS
  1049. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  1050. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  1051. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  1052. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  1053. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  1054. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  1055. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  1056. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  1057. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  1058. SystemStatus[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  1059. Index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  1060. Type[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  1061. type_index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  1062. EvBatterytargetCurrent[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  1063. CcsGunQty++;
  1064. }
  1065. else if(connectorType2 == 2){//GB
  1066. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  1067. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  1068. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  1069. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  1070. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  1071. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  1072. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  1073. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  1074. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  1075. SystemStatus[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].SystemStatus,1);
  1076. Index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Index,1);
  1077. Type[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Type,1);
  1078. type_index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].type_index,1);
  1079. EvBatterytargetCurrent[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetCurrent,1);
  1080. GbGunQty++;
  1081. }
  1082. else if(connectorType2 == 3){//CHAdeMO
  1083. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  1084. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  1085. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  1086. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  1087. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  1088. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  1089. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  1090. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  1091. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  1092. SystemStatus[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].SystemStatus,1);
  1093. Index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Index,1);
  1094. Type[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Type,1);
  1095. type_index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].type_index,1);
  1096. EvBatterytargetCurrent[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  1097. CHAdeMOGunQty++;
  1098. }
  1099. else if(connectorType2 == 4){//AC
  1100. PresentChargingVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
  1101. PresentChargingCurrent[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
  1102. PresentChargingPower[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
  1103. PresentChargedEnergy[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
  1104. PresentChargedDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
  1105. RemainChargingDuration[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
  1106. EvBatteryMaxVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
  1107. EvBatterytargetVoltage[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
  1108. EvBatterySoc[1] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
  1109. SystemStatus[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus,1);
  1110. Index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index,1);
  1111. Type[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type,1);
  1112. type_index[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index,1);
  1113. EvBatterytargetCurrent[1] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent,1);
  1114. AcGunQty++;
  1115. }
  1116. }
  1117. if(connectorType3 != 0){
  1118. if(connectorType3 == 1){//CCS
  1119. PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingVoltage);
  1120. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingCurrent);
  1121. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargingPower);
  1122. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedEnergy);
  1123. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].PresentChargedDuration);
  1124. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].RemainChargingDuration);
  1125. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatteryMaxVoltage);
  1126. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetVoltage);
  1127. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterySoc);
  1128. SystemStatus[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].SystemStatus,1);
  1129. Index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Index,1);
  1130. Type[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].Type,1);
  1131. type_index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].type_index,1);
  1132. EvBatterytargetCurrent[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.CcsChargingData[CcsGunQty].EvBatterytargetCurrent,1);
  1133. CcsGunQty++;
  1134. }
  1135. else if(connectorType3 == 2){//GB
  1136. PresentChargingVoltage[2]= json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingVoltage);
  1137. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingCurrent);
  1138. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargingPower);
  1139. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedEnergy);
  1140. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].PresentChargedDuration);
  1141. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].RemainChargingDuration);
  1142. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatteryMaxVoltage);
  1143. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetVoltage);
  1144. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterySoc);
  1145. SystemStatus[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].SystemStatus,1);
  1146. Index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Index,1);
  1147. Type[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].Type,1);
  1148. type_index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].type_index,1);
  1149. EvBatterytargetCurrent[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.GbChargingData[GbGunQty].EvBatterytargetCurrent,1);
  1150. GbGunQty++;
  1151. }
  1152. else if(connectorType3 == 3){//CHAdeMO
  1153. PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingVoltage);
  1154. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingCurrent);
  1155. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargingPower);
  1156. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedEnergy);
  1157. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].PresentChargedDuration);
  1158. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].RemainChargingDuration);
  1159. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatteryMaxVoltage);
  1160. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetVoltage);
  1161. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterySoc);
  1162. SystemStatus[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].SystemStatus,1);
  1163. Index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Index,1);
  1164. Type[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].Type,1);
  1165. type_index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].type_index,1);
  1166. EvBatterytargetCurrent[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.ChademoChargingData[CHAdeMOGunQty].EvBatterytargetCurrent,1);
  1167. CHAdeMOGunQty++;
  1168. }
  1169. else if(connectorType3 == 4){//AC
  1170. PresentChargingVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingVoltage);
  1171. PresentChargingCurrent[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingCurrent);
  1172. PresentChargingPower[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargingPower);
  1173. PresentChargedEnergy[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedEnergy);
  1174. PresentChargedDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].PresentChargedDuration);
  1175. RemainChargingDuration[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].RemainChargingDuration);
  1176. EvBatteryMaxVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatteryMaxVoltage);
  1177. EvBatterytargetVoltage[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetVoltage);
  1178. EvBatterySoc[2] = json_object_new_double(ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterySoc);
  1179. SystemStatus[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].SystemStatus,1);
  1180. Index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Index,1);
  1181. Type[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].Type,1);
  1182. type_index[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].type_index,1);
  1183. EvBatterytargetCurrent[2] = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.AcChargingData[AcGunQty].EvBatterytargetCurrent,1);
  1184. AcGunQty++;
  1185. }
  1186. }
  1187. //network
  1188. InternetConn = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.InternetConn,1);
  1189. FtpServer = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.FtpServer);
  1190. Eth0DhcpClient = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthDhcpClient,1);
  1191. Eth0MacAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthMacAddress);
  1192. Eth0IpAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthIpAddress);
  1193. Eth0SubmaskAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthSubmaskAddress);
  1194. Eth0GatewayAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth0Interface.EthGatewayAddress);
  1195. Eth1DhcpClient = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthDhcpClient,1);
  1196. Eth1MacAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthMacAddress);
  1197. Eth1IpAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthIpAddress);
  1198. Eth1SubmaskAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthSubmaskAddress);
  1199. Eth1GatewayAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.Eth1Interface.EthGatewayAddress);
  1200. WifiMode = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode,1);
  1201. WifiSsid = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSsid);
  1202. WifiPassword = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiPassword);
  1203. WifiRssi = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.AthInterface.WifiRssi);
  1204. WifiDhcpServer = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpServer,1);
  1205. WifiDhcpClient = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient,1);
  1206. WifiMacAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMacAddress);
  1207. WifiIpAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiIpAddress);
  1208. WifiSubmaskAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiSubmaskAddress);
  1209. WifiGatewayAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiGatewayAddress);
  1210. WifiNetworkConn = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn);
  1211. TelcomApn = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomApn);
  1212. TelcomRssi = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi);
  1213. TelcomChapPapId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapId);
  1214. TelcomChapPapPwd = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomChapPapPwd);
  1215. TelcomModemImei = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei);
  1216. TelcomSimImsi = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi);
  1217. //TelcomSimIccid = json_object_new_string(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid);
  1218. TelcomSimStatus = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus,1);
  1219. TelcomModemMode = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode,1);
  1220. TelcomIpAddress = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomIpAddress);
  1221. TelcomNetworkConn = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomNetworkConn);
  1222. //backend
  1223. BackendConnTimeout = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.BackendConnTimeout);
  1224. OfflinePolicy = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysConfig.OfflinePolicy,1);
  1225. OfflineMaxChargeEnergy = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeEnergy);
  1226. OfflineMaxChargeDuration = json_object_new_int((int)ShmSysConfigAndInfo->SysConfig.OfflineMaxChargeDuration);
  1227. OcppConnStatus = json_object_new_string_len((char *)&ShmSysConfigAndInfo->SysInfo.OcppConnStatus,1);
  1228. OcppServerURL = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.OcppServerURL);
  1229. ChargeBoxId = json_object_new_string((char *)&ShmSysConfigAndInfo->SysConfig.ChargeBoxId);
  1230. //system
  1231. json_object_object_add(jobj1,"ModelName",ModelName);
  1232. json_object_object_add(jobj1,"SerialNumber",SerialNumber);
  1233. json_object_object_add(jobj1,"SystemId",SystemId);
  1234. // json_object_object_add(jobj1,"SystemDateTime",SystemDateTime);
  1235. json_object_object_add(jobj1,"AcPhaseCount",AcPhaseCount);
  1236. json_object_object_add(jobj1,"FactoryConfiguration",FactoryConfiguration);
  1237. json_object_object_add(jobj1,"AuthorisationMode",AuthorisationMode);
  1238. json_object_object_add(jobj1,"DefaultLanguage",DefaultLanguage);
  1239. json_object_object_add(jobj1,"InputVoltageR",InputVoltageR);
  1240. json_object_object_add(jobj1,"InputVoltageS",InputVoltageS);
  1241. json_object_object_add(jobj1,"InputVoltageT",InputVoltageT);
  1242. json_object_object_add(jobj1,"SystemFanRotaSpeed",SystemFanRotaSpeed);
  1243. json_object_object_add(jobj1,"PsuFanRotaSpeed",PsuFanRotaSpeed);
  1244. json_object_object_add(jobj1,"RfidCardNumEndian",RfidCardNumEndian);
  1245. json_object_object_add(jobj1,"AuxPower5V",AuxPower5V);
  1246. json_object_object_add(jobj1,"AuxPower12V",AuxPower12V);
  1247. json_object_object_add(jobj1,"AuxPower24V",AuxPower24V);
  1248. json_object_object_add(jobj1,"AuxPower48V",AuxPower48V);
  1249. json_object_object_add(jobj1,"CsuHwRev",CsuHwRev);
  1250. json_object_object_add(jobj1,"CsuBootLoadFwRev",CsuBootLoadFwRev);
  1251. json_object_object_add(jobj1,"CsuKernelFwRev",CsuKernelFwRev);
  1252. json_object_object_add(jobj1,"CsuRootFsFwRev",CsuRootFsFwRev);
  1253. json_object_object_add(jobj1,"CsuPrimFwRev",CsuPrimFwRev);
  1254. json_object_object_add(jobj1,"LcmHwRev",LcmHwRev);
  1255. json_object_object_add(jobj1,"LcmFwRev",LcmFwRev);
  1256. json_object_object_add(jobj1,"PsuHwRev",PsuHwRev);
  1257. json_object_object_add(jobj1,"PsuPrimFwRev",PsuPrimFwRev);
  1258. json_object_object_add(jobj1,"PsuSecFwRev",PsuSecFwRev);
  1259. json_object_object_add(jobj1,"AuxPwrHwRev",AuxPwrHwRev);
  1260. json_object_object_add(jobj1,"AuxPwrFwRev",AuxPwrFwRev);
  1261. json_object_object_add(jobj1,"FanModuleHwRev",FanModuleHwRev);
  1262. json_object_object_add(jobj1,"FanModuleFwRev",FanModuleFwRev);
  1263. json_object_object_add(jobj1,"RelayModuleHwRev",RelayModuleHwRev);
  1264. json_object_object_add(jobj1,"RelayModuleFwRev",RelayModuleFwRev);
  1265. json_object_object_add(jobj1,"TelcomModemFwRev",TelcomModemFwRev);
  1266. json_object_object_add(jobj1,"SystemAmbientTemp",SystemAmbientTemp);
  1267. json_object_object_add(jobj1,"SystemCriticalTemp",SystemCriticalTemp);
  1268. json_object_object_add(jobj1,"CcsConnectorTemp",CcsConnectorTemp);
  1269. json_object_object_add(jobj1,"PsuAmbientTemp",PsuAmbientTemp);
  1270. json_object_object_add(jobj1,"AcPlugInTimes",AcPlugInTimes);
  1271. json_object_object_add(jobj1,"GbPlugInTimes",GbPlugInTimes);
  1272. json_object_object_add(jobj1,"Ccs1PlugInTimes",Ccs1PlugInTime);
  1273. json_object_object_add(jobj1,"Ccs2PlugInTimes",Ccs2PlugInTimes);
  1274. json_object_object_add(jobj1,"ChademoPlugInTimes",ChademoPlugInTimes);
  1275. json_object_object_add(jobj1,"FirmwareUpdate",FirmwareUpdate);
  1276. printf("%s\n", json_object_to_json_string(jobj1));
  1277. json_object_put(jobj1);
  1278. //charging
  1279. json_object_object_add(jobj2,"MaxChargingEnergy",MaxChargingEnergy);
  1280. json_object_object_add(jobj2,"MaxChargingPower",MaxChargingPower);
  1281. json_object_object_add(jobj2,"MaxChargingCurrent",MaxChargingCurrent);
  1282. json_object_object_add(jobj2,"MaxChargingDuration",MaxChargingDuration);
  1283. json_object_object_add(jobj2,"PhaseLossPolicy",PhaseLossPolicy);
  1284. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[0]);
  1285. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[1]);
  1286. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[2]);
  1287. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[3]);
  1288. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[4]);
  1289. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[5]);
  1290. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[6]);
  1291. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[7]);
  1292. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[8]);
  1293. json_object_array_add(LocalWhiteCardArr,LocalWhiteCard[9]);
  1294. json_object_object_add(jobj2,"LocalWhiteCard",LocalWhiteCardArr);
  1295. // json_object_object_add(jobj2,"CcsAuthentication",CcsAuthentication);
  1296. // json_object_object_add(jobj2,"AcCcsChargingMode",AcCcsChargingMode);
  1297. json_object_object_add(jobj2,"UserId",UserId);
  1298. if(connectorType1 != 0){
  1299. json_object_object_add(ChargingInfo1,"PresentChargingVoltage",PresentChargingVoltage[0]);
  1300. json_object_object_add(ChargingInfo1,"PresentChargingCurrent",PresentChargingCurrent[0]);
  1301. json_object_object_add(ChargingInfo1,"PresentChargingPower",PresentChargingPower[0]);
  1302. json_object_object_add(ChargingInfo1,"PresentChargedEnergy",PresentChargedEnergy[0]);
  1303. json_object_object_add(ChargingInfo1,"PresentChargedDuration",PresentChargedDuration[0]);
  1304. json_object_object_add(ChargingInfo1,"RemainChargingDuration",RemainChargingDuration[0]);
  1305. json_object_object_add(ChargingInfo1,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[0]);
  1306. json_object_object_add(ChargingInfo1,"EvBatterytargetVoltage",EvBatterytargetVoltage[0]);
  1307. json_object_object_add(ChargingInfo1,"EvBatterySoc",EvBatterySoc[0]);
  1308. json_object_object_add(ChargingInfo1,"SystemStatus",SystemStatus[0]);
  1309. json_object_object_add(ChargingInfo1,"Index",Index[0]);
  1310. json_object_object_add(ChargingInfo1,"Type",Type[0]);
  1311. json_object_object_add(ChargingInfo1,"type_index",type_index[0]);
  1312. json_object_object_add(ChargingInfo1,"EvBatterytargetCurrent",EvBatterytargetCurrent[0]);
  1313. json_object_object_add(jobj2,"ChargingInfo1",ChargingInfo1);
  1314. }
  1315. if(connectorType2 != 0){
  1316. json_object_object_add(ChargingInfo2,"PresentChargingVoltage",PresentChargingVoltage[1]);
  1317. json_object_object_add(ChargingInfo2,"PresentChargingCurrent",PresentChargingCurrent[1]);
  1318. json_object_object_add(ChargingInfo2,"PresentChargingPower",PresentChargingPower[1]);
  1319. json_object_object_add(ChargingInfo2,"PresentChargedEnergy",PresentChargedEnergy[1]);
  1320. json_object_object_add(ChargingInfo2,"PresentChargedDuration",PresentChargedDuration[1]);
  1321. json_object_object_add(ChargingInfo2,"RemainChargingDuration",RemainChargingDuration[1]);
  1322. json_object_object_add(ChargingInfo2,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[1]);
  1323. json_object_object_add(ChargingInfo2,"EvBatterytargetVoltage",EvBatterytargetVoltage[1]);
  1324. json_object_object_add(ChargingInfo2,"EvBatterySoc",EvBatterySoc[1]);
  1325. json_object_object_add(ChargingInfo2,"SystemStatus",SystemStatus[1]);
  1326. json_object_object_add(ChargingInfo2,"Index",Index[1]);
  1327. json_object_object_add(ChargingInfo2,"Type",Type[1]);
  1328. json_object_object_add(ChargingInfo2,"type_index",type_index[1]);
  1329. json_object_object_add(ChargingInfo2,"EvBatterytargetCurrent",EvBatterytargetCurrent[1]);
  1330. json_object_object_add(jobj2,"ChargingInfo2",ChargingInfo2);
  1331. }
  1332. if(connectorType3 != 0){
  1333. json_object_object_add(ChargingInfo3,"PresentChargingVoltage",PresentChargingVoltage[2]);
  1334. json_object_object_add(ChargingInfo3,"PresentChargingCurrent",PresentChargingCurrent[2]);
  1335. json_object_object_add(ChargingInfo3,"PresentChargingPower",PresentChargingPower[2]);
  1336. json_object_object_add(ChargingInfo3,"PresentChargedEnergy",PresentChargedEnergy[2]);
  1337. json_object_object_add(ChargingInfo3,"PresentChargedDuration",PresentChargedDuration[2]);
  1338. json_object_object_add(ChargingInfo3,"RemainChargingDuration",RemainChargingDuration[2]);
  1339. json_object_object_add(ChargingInfo3,"EvBatteryMaxVoltage",EvBatteryMaxVoltage[2]);
  1340. json_object_object_add(ChargingInfo3,"EvBatterytargetVoltage",EvBatterytargetVoltage[2]);
  1341. json_object_object_add(ChargingInfo3,"EvBatterySoc",EvBatterySoc[2]);
  1342. json_object_object_add(ChargingInfo3,"SystemStatus",SystemStatus[2]);
  1343. json_object_object_add(ChargingInfo3,"Index",Index[2]);
  1344. json_object_object_add(ChargingInfo3,"Type",Type[2]);
  1345. json_object_object_add(ChargingInfo3,"type_index",type_index[2]);
  1346. json_object_object_add(ChargingInfo3,"EvBatterytargetCurrent",EvBatterytargetCurrent[2]);
  1347. json_object_object_add(jobj2,"ChargingInfo3",ChargingInfo3);
  1348. }
  1349. printf("%s\n", json_object_to_json_string(jobj2));
  1350. json_object_put(jobj2);
  1351. //network
  1352. json_object_object_add(jobj3,"InternetConn",InternetConn);
  1353. json_object_object_add(jobj3,"FtpServer",FtpServer);
  1354. json_object_object_add(jobj3,"Eth0DhcpClient",Eth0DhcpClient);
  1355. json_object_object_add(jobj3,"Eth0MacAddress",Eth0MacAddress);
  1356. json_object_object_add(jobj3,"Eth0IpAddress",Eth0IpAddress);
  1357. json_object_object_add(jobj3,"Eth0SubmaskAddress",Eth0SubmaskAddress);
  1358. json_object_object_add(jobj3,"Eth0GatewayAddress",Eth0GatewayAddress);
  1359. json_object_object_add(jobj3,"Eth1DhcpClient",Eth1DhcpClient);
  1360. json_object_object_add(jobj3,"Eth1MacAddress",Eth1MacAddress);
  1361. json_object_object_add(jobj3,"Eth1IpAddress",Eth1IpAddress);
  1362. json_object_object_add(jobj3,"Eth1SubmaskAddress",Eth1SubmaskAddress);
  1363. json_object_object_add(jobj3,"Eth1GatewayAddress",Eth1GatewayAddress);
  1364. json_object_object_add(jobj3,"WifiMode",WifiMode);
  1365. json_object_object_add(jobj3,"WifiSsid",WifiSsid);
  1366. json_object_object_add(jobj3,"WifiPassword",WifiPassword);
  1367. json_object_object_add(jobj3,"WifiRssi",WifiRssi);
  1368. json_object_object_add(jobj3,"WifiDhcpServer",WifiDhcpServer);
  1369. json_object_object_add(jobj3,"WifiDhcpClient",WifiDhcpClient);
  1370. json_object_object_add(jobj3,"WifiMacAddress",WifiMacAddress);
  1371. json_object_object_add(jobj3,"WifiIpAddress",WifiIpAddress);
  1372. json_object_object_add(jobj3,"WifiSubmaskAddress",WifiSubmaskAddress);
  1373. json_object_object_add(jobj3,"WifiGatewayAddress",WifiGatewayAddress);
  1374. json_object_object_add(jobj3,"WifiNetworkConn",WifiNetworkConn);
  1375. json_object_object_add(jobj3,"TelcomApn",TelcomApn);
  1376. json_object_object_add(jobj3,"TelcomRssi",TelcomRssi);
  1377. json_object_object_add(jobj3,"TelcomChapPapId",TelcomChapPapId);
  1378. json_object_object_add(jobj3,"TelcomChapPapPwd",TelcomChapPapPwd);
  1379. json_object_object_add(jobj3,"TelcomModemImei",TelcomModemImei);
  1380. json_object_object_add(jobj3,"TelcomSimImsi",TelcomSimImsi);
  1381. json_object_object_add(jobj3,"TelcomSimStatus",TelcomSimStatus);
  1382. json_object_object_add(jobj3,"TelcomModemMode",TelcomModemMode);
  1383. json_object_object_add(jobj3,"TelcomIpAddress",TelcomIpAddress);
  1384. json_object_object_add(jobj3,"TelcomNetworkConn",TelcomNetworkConn);
  1385. printf("%s\n", json_object_to_json_string(jobj3));
  1386. json_object_put(jobj3);
  1387. //backend
  1388. json_object_object_add(jobj4,"BackendConnTimeout",BackendConnTimeout);
  1389. json_object_object_add(jobj4,"OfflinePolicy",OfflinePolicy);
  1390. json_object_object_add(jobj4,"OfflineMaxChargeEnergy",OfflineMaxChargeEnergy);
  1391. json_object_object_add(jobj4,"OfflineMaxChargeDuration",OfflineMaxChargeDuration);
  1392. json_object_object_add(jobj4,"OcppConnStatus",OcppConnStatus);
  1393. json_object_object_add(jobj4,"OcppServerURL",OcppServerURL);
  1394. json_object_object_add(jobj4,"ChargeBoxId",ChargeBoxId);
  1395. printf("%s\n", json_object_to_json_string(jobj4));
  1396. json_object_put(jobj4);
  1397. }
  1398. // for(;;)
  1399. // {
  1400. // }
  1401. return FAIL;
  1402. }