WebService.c 77 KB

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