tool.c 72 KB

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