Module_PhBackend.c 140 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123
  1. /*
  2. * Module_PhBackend.c
  3. *
  4. * Created on: 2020/06/11
  5. * Author: foluswen
  6. */
  7. #include "Module_PhBackend.h"
  8. #include "Module_RatedCurrent.h"
  9. ParsingRatedCur modelnameInfo = {0};
  10. int StoreLogMsg(const char *fmt, ...)
  11. {
  12. char Buf[65536+256];
  13. char buffer[65536];
  14. //char Buf[4096+256];
  15. //char buffer[4096];
  16. time_t CurrentTime;
  17. struct tm *tm;
  18. struct timeval tv;
  19. va_list args;
  20. va_start(args, fmt);
  21. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  22. va_end(args);
  23. memset(Buf,0,sizeof(Buf));
  24. CurrentTime = time(NULL);
  25. tm=localtime(&CurrentTime);
  26. gettimeofday(&tv, NULL); // get microseconds, 10^-6
  27. sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s\" >> /Storage/SystemLog/[%04d.%02d]Module_PhBackendLog",
  28. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec/1000,
  29. buffer,
  30. tm->tm_year+1900,tm->tm_mon+1);
  31. system((const char*)Buf);
  32. #ifdef ConsloePrintLog
  33. printf("[%04d.%02d.%02d %02d:%02d:%02d.%03ld]%s", tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec/1000, buffer);
  34. #endif
  35. return rc;
  36. }
  37. uint8_t split(char *src, const char *separator, char **dest)
  38. {
  39. char *pNext;
  40. int count = 0;
  41. if (src == NULL || strlen(src) == 0)
  42. return count;
  43. if (separator == NULL || strlen(separator) == 0)
  44. return count;
  45. pNext = (char *)strtok(src,separator);
  46. while(pNext != NULL)
  47. {
  48. *dest++ = pNext;
  49. ++count;
  50. pNext = (char *)strtok(NULL,separator);
  51. }
  52. return count;
  53. }
  54. int decTobcd(int dec)
  55. {
  56. return (dec/10 * 16)+ (dec%10);
  57. }
  58. //==========================================
  59. // Init all share memory
  60. //==========================================
  61. int InitShareMemory()
  62. {
  63. int result = PASS;
  64. int MeterSMId;
  65. //creat ShmSysConfigAndInfo
  66. if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
  67. {
  68. #ifdef SystemLogMessage
  69. DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
  70. #endif
  71. result = FAIL;
  72. }
  73. else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  74. {
  75. #ifdef SystemLogMessage
  76. DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
  77. #endif
  78. result = FAIL;
  79. }
  80. else
  81. {}
  82. //creat ShmStatusCodeData
  83. if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
  84. {
  85. #ifdef SystemLogMessage
  86. DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
  87. #endif
  88. result = FAIL;
  89. }
  90. else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
  91. {
  92. #ifdef SystemLogMessage
  93. DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
  94. #endif
  95. result = FAIL;
  96. }
  97. else
  98. {}
  99. return result;
  100. }
  101. uint8_t checksum_valid(struct Message *message)
  102. {
  103. uint8_t chksum = 0;
  104. for(uint16_t idx=6;idx<(message->buffer[2] | ((uint16_t)message->buffer[3]<<8));idx++)
  105. chksum += message->buffer[idx];
  106. chksum += 11;
  107. return ((chksum&0xff)==message->buffer[(message->buffer[2] | ((uint16_t)message->buffer[3]<<8))-1]?PASS:FAIL);
  108. }
  109. uint8_t checksum_cal(struct Message *message)
  110. {
  111. uint8_t chksum = 0;
  112. for(uint16_t idx=6;idx<(message->size-1);idx++)
  113. chksum += message->buffer[idx];
  114. chksum += 11;
  115. return (chksum & 0xff);
  116. }
  117. void showCmdRaw(struct Message *message, uint8_t isTx)
  118. {
  119. if(isTx)
  120. DEBUG_INFO("%s -----> Server\n", ShmSysConfigAndInfo->SysConfig.SystemId);
  121. else
  122. DEBUG_INFO("%s <----- Server\n", ShmSysConfigAndInfo->SysConfig.SystemId);
  123. DEBUG_INFO("- CMD_%04d ------------------------------------\n", (message->buffer[6] | ((uint16_t)message->buffer[7]<<8)));
  124. DEBUG_INFO("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
  125. DEBUG_INFO("-----------------------------------------------\n");
  126. for(uint8_t idx=0;idx<((message->size/16)+1);idx++)
  127. {
  128. DEBUG_INFO("%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", message->buffer[idx*16+0],
  129. message->buffer[idx*16+1],
  130. message->buffer[idx*16+2],
  131. message->buffer[idx*16+3],
  132. message->buffer[idx*16+4],
  133. message->buffer[idx*16+5],
  134. message->buffer[idx*16+6],
  135. message->buffer[idx*16+7],
  136. message->buffer[idx*16+8],
  137. message->buffer[idx*16+9],
  138. message->buffer[idx*16+10],
  139. message->buffer[idx*16+11],
  140. message->buffer[idx*16+12],
  141. message->buffer[idx*16+13],
  142. message->buffer[idx*16+14],
  143. message->buffer[idx*16+15]);
  144. }
  145. DEBUG_INFO("-----------------------------------------------\n");
  146. }
  147. void handle_cmd_1001(struct Message *in, struct Message *out)
  148. {
  149. uint32_t startAddr;
  150. uint32_t offset = 0;
  151. uint8_t count;
  152. uint32_t value;
  153. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  154. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  155. if(in->buffer[12])
  156. DEBUG_INFO("CMD Type: Set\n");
  157. else
  158. DEBUG_INFO("CMD Type: Query\n");
  159. startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
  160. count = in->buffer[17];
  161. if(in->buffer[12])
  162. {
  163. for(int idx=startAddr;idx<(startAddr+count);idx++)
  164. {
  165. value = in->buffer[20+(offset*4)] | ((uint32_t)in->buffer[21+(offset*4)]<<8) | ((uint32_t)in->buffer[22+(offset*4)]<<16) | ((uint32_t)in->buffer[23+(offset*4)]<<24);
  166. switch(idx)
  167. {
  168. case 1:
  169. DEBUG_INFO("Sign in interval: %d\n", value);
  170. offset++;
  171. break;
  172. case 2:
  173. DEBUG_INFO("Charger type: %d\n", value);
  174. offset++;
  175. break;
  176. case 3:
  177. DEBUG_INFO("Charger gun count: %d\n", value);
  178. offset++;
  179. break;
  180. case 4:
  181. DEBUG_INFO("Communication No: %d\n", value);
  182. offset++;
  183. break;
  184. case 5:
  185. offset++;
  186. break;
  187. case 6:
  188. offset++;
  189. break;
  190. case 7:
  191. offset++;
  192. break;
  193. case 8:
  194. offset++;
  195. break;
  196. case 9:
  197. offset++;
  198. break;
  199. case 10:
  200. offset++;
  201. break;
  202. case 11:
  203. offset++;
  204. break;
  205. case 12:
  206. offset++;
  207. break;
  208. case 13:
  209. offset++;
  210. break;
  211. case 14:
  212. offset++;
  213. break;
  214. case 15:
  215. offset++;
  216. break;
  217. case 16:
  218. offset++;
  219. break;
  220. case 17:
  221. offset++;
  222. break;
  223. case 18:
  224. offset++;
  225. break;
  226. case 19:
  227. offset++;
  228. break;
  229. case 20:
  230. DEBUG_INFO("Report interval: %d\n", value);
  231. offset++;
  232. break;
  233. case 21:
  234. DEBUG_INFO("Heart beat interval: %d\n", value);
  235. backend_info.interval_heartbeat = value;
  236. offset++;
  237. break;
  238. case 22:
  239. DEBUG_INFO("Heart beat overtime count: %d\n", value);
  240. backend_info.retry_heartbeat = value;
  241. offset++;
  242. break;
  243. case 23:
  244. DEBUG_INFO("Status report interval: %d\n", value);
  245. backend_info.interval_status = value;
  246. offset++;
  247. break;
  248. case 24:
  249. offset++;
  250. break;
  251. case 25:
  252. offset++;
  253. break;
  254. case 26:
  255. offset++;
  256. break;
  257. case 27:
  258. DEBUG_INFO("Service price: %.2f\n", (value/100.0));
  259. offset++;
  260. break;
  261. case 28:
  262. DEBUG_INFO("Charging price: %.2f\n", (value/100.0));
  263. offset++;
  264. break;
  265. case 29:
  266. offset++;
  267. break;
  268. case 30:
  269. offset++;
  270. break;
  271. case 31:
  272. offset++;
  273. break;
  274. case 32:
  275. offset++;
  276. break;
  277. case 33:
  278. offset++;
  279. break;
  280. case 34:
  281. offset++;
  282. break;
  283. case 35:
  284. offset++;
  285. break;
  286. }
  287. }
  288. }
  289. create_Cmd_1002(out, in->buffer[12], startAddr, count);
  290. }
  291. void handle_cmd_1003(struct Message *in, struct Message *out)
  292. {
  293. uint32_t startAddr;
  294. uint8_t data[in->size-11-9];
  295. uint8_t *server_info[3];
  296. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  297. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  298. if(in->buffer[12])
  299. DEBUG_INFO("CMD Type: Set\n");
  300. else
  301. DEBUG_INFO("CMD Type: Query\n");
  302. startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
  303. memcpy(&data[0], &in->buffer[19], ARRAY_SIZE(data));
  304. switch(startAddr)
  305. {
  306. case 1:
  307. break;
  308. case 2:
  309. DEBUG_INFO("Server time: %02X%02X-%02X-%02X %02X:%02X:%02X\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
  310. break;
  311. case 3:
  312. break;
  313. case 4:
  314. break;
  315. case 5:
  316. break;
  317. case 6:
  318. break;
  319. case 7:
  320. break;
  321. case 8:
  322. break;
  323. case 9:
  324. break;
  325. case 10:
  326. break;
  327. case 11:
  328. memset(server_addr, 0x00, ARRAY_SIZE(server_addr));
  329. memcpy(&server_addr[0], &in->buffer[19], 128);
  330. split((char*)server_addr, ":", (char**)server_info);
  331. message_header = strtol((char*)server_info[2], NULL, 16);
  332. server_port = atoi((char*)server_info[1]);
  333. sprintf((char*)server_addr, "%s", (char*)server_info[0]);
  334. DEBUG_INFO("Server address: %s\n", server_addr);
  335. DEBUG_INFO("Server port: %d\n", server_port);
  336. DEBUG_INFO("Message header: %04X\n", message_header);
  337. break;
  338. case 12:
  339. DEBUG_INFO("Customer ID: %s\n", data);
  340. break;
  341. }
  342. create_Cmd_1004(out, in->buffer[12], startAddr, &data[0], ARRAY_SIZE(data));
  343. }
  344. void handle_cmd_1005(struct Message *in, struct Message *out)
  345. {
  346. uint32_t startAddr;
  347. uint32_t offset = 0;
  348. uint8_t count;
  349. uint32_t value;
  350. uint8_t gun_index;
  351. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  352. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  353. gun_index = in->buffer[12];
  354. startAddr = in->buffer[13] | ((uint32_t)in->buffer[14]<<8) | ((uint32_t)in->buffer[15]<<16) | ((uint32_t)in->buffer[16]<<24);
  355. count = in->buffer[17];
  356. for(int idx=startAddr;idx<(startAddr+count);idx++)
  357. {
  358. value = in->buffer[20+(offset*4)] | ((uint32_t)in->buffer[21+(offset*4)]<<8) | ((uint32_t)in->buffer[22+(offset*4)]<<16) | ((uint32_t)in->buffer[23+(offset*4)]<<24);
  359. switch(idx)
  360. {
  361. case 1:
  362. if(value == 0x55)
  363. {
  364. DEBUG_INFO("Charger start.\n");
  365. }
  366. offset++;
  367. break;
  368. case 2:
  369. if(value == 0x55)
  370. {
  371. DEBUG_INFO("Charger stop.\n");
  372. }
  373. offset++;
  374. break;
  375. case 3:
  376. if(value == 0)
  377. {
  378. DEBUG_INFO("Charge soon.\n");
  379. }
  380. else if(value ==1)
  381. {
  382. DEBUG_INFO("Charge reserve.\n");
  383. }
  384. offset++;
  385. break;
  386. case 4:
  387. if(value == 0)
  388. {
  389. DEBUG_INFO("BMS control charging.\n");
  390. }
  391. else if(value == 1)
  392. {
  393. DEBUG_INFO("Directly charging.\n");
  394. }
  395. offset++;
  396. break;
  397. case 5:
  398. if(value == 0x55)
  399. {
  400. }
  401. offset++;
  402. break;
  403. case 6:
  404. if(value == 0x55)
  405. {
  406. }
  407. offset++;
  408. break;
  409. case 7:
  410. if(value == 0x55)
  411. {
  412. }
  413. offset++;
  414. break;
  415. case 8:
  416. if(value == 0x55)
  417. {
  418. }
  419. offset++;
  420. break;
  421. case 9:
  422. if(value == 0x55)
  423. {
  424. }
  425. offset++;
  426. break;
  427. case 10:
  428. if(value == 0x55)
  429. {
  430. }
  431. offset++;
  432. break;
  433. case 11:
  434. if(value == 0x55)
  435. {
  436. }
  437. offset++;
  438. break;
  439. case 12:
  440. if(value == 0x55)
  441. {
  442. }
  443. offset++;
  444. break;
  445. case 13:
  446. if(value == 0x55)
  447. {
  448. }
  449. offset++;
  450. break;
  451. case 14:
  452. if(value == 0x55)
  453. {
  454. }
  455. offset++;
  456. break;
  457. case 15:
  458. if(value == 0x55)
  459. {
  460. }
  461. offset++;
  462. break;
  463. case 16:
  464. if(value == 0x55)
  465. {
  466. }
  467. offset++;
  468. break;
  469. case 17:
  470. if(value == 0x55)
  471. {
  472. DEBUG_INFO("Upload log request.\n");
  473. system("/usr/bin/run_tmate_restart.sh");
  474. }
  475. offset++;
  476. break;
  477. case 18:
  478. if(value == 0x55)
  479. {
  480. }
  481. offset++;
  482. break;
  483. case 19:
  484. if(value == 0x55)
  485. {
  486. DEBUG_INFO("Disable charger.\n");
  487. }
  488. offset++;
  489. break;
  490. case 20:
  491. if(value == 0x55)
  492. {
  493. DEBUG_INFO("Enable charger.\n");
  494. }
  495. offset++;
  496. break;
  497. }
  498. }
  499. create_Cmd_1006(out, gun_index, startAddr, count, true);
  500. }
  501. void handle_cmd_1101(struct Message *in)
  502. {
  503. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  504. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  505. backend_info.sn_heartbeat = (in->buffer[12] | ((uint16_t)in->buffer[13]<<8));
  506. backend_info.counter_heartbeat_retry = 0;
  507. }
  508. void handle_cmd_1103(struct Message *in)
  509. {
  510. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  511. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  512. DEBUG_INFO("Connector id: %d\n", in->buffer[12]);
  513. }
  514. void handle_cmd_1105(struct Message *in)
  515. {
  516. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  517. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  518. DEBUG_INFO("Charger sign in OK.\n");
  519. backend_info.isSignin = ON;
  520. backend_info.st_hearbeat = time((time_t*)NULL);
  521. backend_info.counter_heartbeat_retry = 0;
  522. backend_info.interval_heartbeat = 10;
  523. backend_info.interval_status = 30;
  524. }
  525. void handle_cmd_2303(struct Message *in, struct Message *out)
  526. {
  527. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  528. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  529. create_Cmd_2304(out);
  530. }
  531. void handle_cmd_2305(struct Message *in, struct Message *out)
  532. {
  533. DEBUG_INFO("User ID: %d\n", (in->buffer[8] | ((uint16_t)in->buffer[9]<<8)));
  534. DEBUG_INFO("CMD SN: %d\n", (in->buffer[10] | ((uint16_t)in->buffer[11]<<8)));
  535. create_Cmd_2306(out);
  536. }
  537. void create_Cmd_1002(struct Message *out, uint8_t cmd_type, uint32_t address, uint32_t count)
  538. {
  539. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  540. out->size = 9 + 43 + (count*4);
  541. // Message header
  542. out->buffer[0x00] = (message_header>>8) & 0xff;
  543. out->buffer[0x01] = (message_header>>0) & 0xff;
  544. // Message length
  545. out->buffer[0x02] = (out->size>>0) & 0xff;
  546. out->buffer[0x03] = (out->size>>8) & 0xff;
  547. // Message protocol version
  548. out->buffer[0x04] = PROTOCOL_VER;
  549. // Message server command serial number
  550. out->buffer[0x05] = server_cmd_sn & 0xff;
  551. // Message command
  552. out->buffer[0x06] = (1002>>0) & 0xff;
  553. out->buffer[0x07] = (1002>>8) & 0xff;
  554. // Message user id
  555. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  556. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  557. // Message server command serial number
  558. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  559. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  560. // Charger ID
  561. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
  562. // Command type (0:Check 1:Set)
  563. out->buffer[0x2c] = cmd_type;
  564. // Start adress
  565. out->buffer[0x2d] = (address>>0) & 0xff;
  566. out->buffer[0x2e] = (address>>8) & 0xff;
  567. out->buffer[0x2f] = (address>>16) & 0xff;
  568. out->buffer[0x30] = (address>>24) & 0xff;
  569. // Count
  570. out->buffer[0x31] = count;
  571. // Result (0:Success 1:Fail)
  572. out->buffer[0x31] = 0x00;
  573. memset(&out->buffer[0x32], 0x00, (count*4));
  574. // Checksum
  575. out->buffer[out->size-1] = checksum_cal(out);
  576. showCmdRaw(out, true);
  577. }
  578. void create_Cmd_1004(struct Message *out, uint8_t cmd_type, uint32_t address, uint8_t *data, uint8_t data_len)
  579. {
  580. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  581. out->size = 9 + 42 + data_len;
  582. // Message header
  583. out->buffer[0x00] = (message_header>>8) & 0xff;
  584. out->buffer[0x01] = (message_header>>0) & 0xff;
  585. // Message length
  586. out->buffer[0x02] = (out->size>>0) & 0xff;
  587. out->buffer[0x03] = (out->size>>8) & 0xff;
  588. // Message protocol version
  589. out->buffer[0x04] = PROTOCOL_VER;
  590. // Message server command serial number
  591. out->buffer[0x05] = server_cmd_sn & 0xff;
  592. // Message command
  593. out->buffer[0x06] = (1004>>0) & 0xff;
  594. out->buffer[0x07] = (1004>>8) & 0xff;
  595. // Message user id
  596. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  597. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  598. // Message server command serial number
  599. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  600. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  601. // Charger ID
  602. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
  603. // Command type (0:Check 1:Set)
  604. out->buffer[0x2c] = cmd_type;
  605. // Start adress
  606. out->buffer[0x2d] = (address>>0) & 0xff;
  607. out->buffer[0x2e] = (address>>8) & 0xff;
  608. out->buffer[0x2f] = (address>>16) & 0xff;
  609. out->buffer[0x30] = (address>>24) & 0xff;
  610. // Result (0:Success 1:Fail)
  611. out->buffer[0x31] = 0x00;
  612. // Result data
  613. memcpy(&out->buffer[0x32], &data[0], data_len);
  614. // Checksum
  615. out->buffer[out->size-1] = checksum_cal(out);
  616. showCmdRaw(out, true);
  617. }
  618. void create_Cmd_1006(struct Message *out, uint8_t gun_index, uint32_t address, uint8_t count, uint8_t isExecuted)
  619. {
  620. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  621. out->size = 0x34;
  622. // Message header
  623. out->buffer[0x00] = (message_header>>8) & 0xff;
  624. out->buffer[0x01] = (message_header>>0) & 0xff;
  625. // Message length
  626. out->buffer[0x02] = (out->size>>0) & 0xff;
  627. out->buffer[0x03] = (out->size>>8) & 0xff;
  628. // Message protocol version
  629. out->buffer[0x04] = PROTOCOL_VER;
  630. // Message server command serial number
  631. out->buffer[0x05] = server_cmd_sn & 0xff;
  632. // Message command
  633. out->buffer[0x06] = (1006>>0) & 0xff;
  634. out->buffer[0x07] = (1006>>8) & 0xff;
  635. // Message user id
  636. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  637. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  638. // Message server command serial number
  639. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  640. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  641. // Charger ID
  642. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
  643. // Gun index
  644. out->buffer[0x2c] = gun_index;
  645. // Start adress
  646. out->buffer[0x2d] = (address>>0) & 0xff;
  647. out->buffer[0x2e] = (address>>8) & 0xff;
  648. out->buffer[0x2f] = (address>>16) & 0xff;
  649. out->buffer[0x30] = (address>>24) & 0xff;
  650. // Command count
  651. out->buffer[0x31] = count;
  652. // Command execute result;
  653. out->buffer[0x32] = isExecuted;
  654. // Checksum
  655. out->buffer[out->size-1] = checksum_cal(out);
  656. showCmdRaw(out, true);
  657. }
  658. void create_Cmd_1102(struct Message *out)
  659. {
  660. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  661. out->size = 0x2f;
  662. // Message header
  663. out->buffer[0x00] = (message_header>>8) & 0xff;
  664. out->buffer[0x01] = (message_header>>0) & 0xff;
  665. // Message length
  666. out->buffer[0x02] = (out->size>>0) & 0xff;
  667. out->buffer[0x03] = (out->size>>8) & 0xff;
  668. // Message protocol version
  669. out->buffer[0x04] = PROTOCOL_VER;
  670. // Message server command serial number
  671. out->buffer[0x05] = server_cmd_sn & 0xff;
  672. // Message command
  673. out->buffer[0x06] = (1102>>0) & 0xff;
  674. out->buffer[0x07] = (1102>>8) & 0xff;
  675. // Message user id
  676. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  677. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  678. // Message server command serial number
  679. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  680. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  681. // Charger ID
  682. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
  683. // Heart beat sn
  684. out->buffer[0x2c] = (backend_info.sn_heartbeat>>0) & 0xff;
  685. out->buffer[0x2d] = (backend_info.sn_heartbeat>>8) & 0xff;
  686. // Checksum
  687. out->buffer[out->size-1] = checksum_cal(out);
  688. showCmdRaw(out, true);
  689. }
  690. void create_Cmd_1104(struct Message *out, uint8_t gun_index)
  691. {
  692. uint8_t tempIndex;
  693. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  694. out->size = 0xd7;
  695. // Message header
  696. out->buffer[0x00] = (message_header>>8) & 0xff;
  697. out->buffer[0x01] = (message_header>>0) & 0xff;
  698. // Message length
  699. out->buffer[0x02] = (out->size>>0) & 0xff;
  700. out->buffer[0x03] = (out->size>>8) & 0xff;
  701. // Message protocol version
  702. out->buffer[0x04] = PROTOCOL_VER;
  703. // Message server command serial number
  704. out->buffer[0x05] = server_cmd_sn & 0xff;
  705. // Message command
  706. out->buffer[0x06] = (1104>>0) & 0xff;
  707. out->buffer[0x07] = (1104>>8) & 0xff;
  708. // Message user id
  709. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  710. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  711. // Message server command serial number
  712. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  713. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  714. // Charger ID
  715. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 0x20);
  716. // Charger connector quantity
  717. out->buffer[0x2c] = AC_QUANTITY + CCS_QUANTITY + GB_QUANTITY + CHAdeMO_QUANTITY;
  718. // Connector id
  719. out->buffer[0x2d] = gun_index;
  720. // Charger model type (1: DC, 2: AC)
  721. out->buffer[0x2e] = (ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D'?1:2);
  722. // Connector status
  723. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  724. {
  725. case Gun_Type_Chademo:
  726. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  727. {
  728. tempIndex = gun_index;
  729. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  730. {
  731. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  732. {
  733. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE))
  734. out->buffer[0x2f] = 7;
  735. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)
  736. out->buffer[0x2f] = 0;
  737. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING))
  738. out->buffer[0x2f] = 1;
  739. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING))
  740. out->buffer[0x2f] = 2;
  741. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)
  742. out->buffer[0x2f] = 3;
  743. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT))
  744. out->buffer[0x2f] = 6;
  745. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)
  746. out->buffer[0x2f] = 5;
  747. else
  748. out->buffer[0x2f] = 0;
  749. }
  750. }
  751. }
  752. else
  753. {
  754. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  755. {
  756. tempIndex = ((gun_index==2) ? 1: 0);
  757. }
  758. else
  759. {
  760. tempIndex = gun_index;
  761. }
  762. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  763. {
  764. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  765. {
  766. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_UPDATE))
  767. out->buffer[0x2f] = 7;
  768. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_IDLE)
  769. out->buffer[0x2f] = 0;
  770. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARING))
  771. out->buffer[0x2f] = 1;
  772. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
  773. out->buffer[0x2f] = 2;
  774. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_COMPLETE)
  775. out->buffer[0x2f] = 3;
  776. else if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_FAULT))
  777. out->buffer[0x2f] = 6;
  778. else if(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION)
  779. out->buffer[0x2f] = 5;
  780. else
  781. out->buffer[0x2f] = 0;
  782. }
  783. }
  784. }
  785. break;
  786. case Gun_Type_CCS_2:
  787. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  788. {
  789. tempIndex = gun_index;
  790. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  791. {
  792. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  793. {
  794. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE))
  795. out->buffer[0x2f] = 7;
  796. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)
  797. out->buffer[0x2f] = 0;
  798. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING))
  799. out->buffer[0x2f] = 1;
  800. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING))
  801. out->buffer[0x2f] = 2;
  802. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)
  803. out->buffer[0x2f] = 3;
  804. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT))
  805. out->buffer[0x2f] = 6;
  806. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)
  807. out->buffer[0x2f] = 5;
  808. else
  809. out->buffer[0x2f] = 0;
  810. }
  811. }
  812. }
  813. else
  814. {
  815. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  816. {
  817. tempIndex = ((gun_index==2) ? 1: 0);
  818. }
  819. else
  820. {
  821. tempIndex = gun_index;
  822. }
  823. for (int index = 0; index < CCS_QUANTITY; index++)
  824. {
  825. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  826. {
  827. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_UPDATE))
  828. out->buffer[0x2f] = 7;
  829. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_IDLE)
  830. out->buffer[0x2f] = 0;
  831. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARING))
  832. out->buffer[0x2f] = 1;
  833. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
  834. out->buffer[0x2f] = 2;
  835. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_COMPLETE)
  836. out->buffer[0x2f] = 3;
  837. else if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_FAULT))
  838. out->buffer[0x2f] = 6;
  839. else if(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION)
  840. out->buffer[0x2f] = 5;
  841. else
  842. out->buffer[0x2f] = 0;
  843. }
  844. }
  845. }
  846. break;
  847. case Gun_Type_GB:
  848. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  849. {
  850. tempIndex = gun_index;
  851. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  852. {
  853. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  854. {
  855. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_UPDATE))
  856. out->buffer[0x2f] = 7;
  857. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_IDLE)
  858. out->buffer[0x2f] = 0;
  859. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARING))
  860. out->buffer[0x2f] = 1;
  861. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_TERMINATING))
  862. out->buffer[0x2f] = 2;
  863. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_COMPLETE)
  864. out->buffer[0x2f] = 3;
  865. else if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_FAULT))
  866. out->buffer[0x2f] = 6;
  867. else if(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION)
  868. out->buffer[0x2f] = 5;
  869. else
  870. out->buffer[0x2f] = 0;
  871. }
  872. }
  873. }
  874. else
  875. {
  876. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  877. {
  878. tempIndex = ((gun_index==2) ? 1: 0);
  879. }
  880. else
  881. {
  882. tempIndex = gun_index;
  883. }
  884. for (int index = 0; index < GB_QUANTITY; index++)
  885. {
  886. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  887. {
  888. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_UPDATE))
  889. out->buffer[0x2f] = 7;
  890. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_IDLE)
  891. out->buffer[0x2f] = 0;
  892. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARING))
  893. out->buffer[0x2f] = 1;
  894. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
  895. out->buffer[0x2f] = 2;
  896. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_COMPLETE)
  897. out->buffer[0x2f] = 3;
  898. else if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_FAULT))
  899. out->buffer[0x2f] = 6;
  900. else if(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION)
  901. out->buffer[0x2f] = 5;
  902. else
  903. out->buffer[0x2f] = 0;
  904. }
  905. }
  906. }
  907. break;
  908. case Gun_Type_AC:
  909. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  910. {
  911. tempIndex = 2;
  912. }
  913. else
  914. {
  915. tempIndex = gun_index;
  916. }
  917. for (int index = 0; index < AC_QUANTITY; index++)
  918. {
  919. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  920. {
  921. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_BOOTING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_MAINTAIN) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_UPDATE))
  922. out->buffer[0x2f] = 7;
  923. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_IDLE)
  924. out->buffer[0x2f] = 0;
  925. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_AUTHORIZING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARING))
  926. out->buffer[0x2f] = 1;
  927. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_CHARGING) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_PREPARE_FOR_EV) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_TERMINATING))
  928. out->buffer[0x2f] = 2;
  929. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_COMPLETE)
  930. out->buffer[0x2f] = 3;
  931. else if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_ALARM) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_FAULT))
  932. out->buffer[0x2f] = 6;
  933. else if(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION)
  934. out->buffer[0x2f] = 5;
  935. else
  936. out->buffer[0x2f] = 0;
  937. }
  938. }
  939. break;
  940. }
  941. // SOC
  942. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  943. {
  944. case Gun_Type_Chademo:
  945. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  946. {
  947. tempIndex = gun_index;
  948. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  949. {
  950. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  951. {
  952. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  953. }
  954. }
  955. }
  956. else
  957. {
  958. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  959. {
  960. tempIndex = ((gun_index==2) ? 1: 0);
  961. }
  962. else
  963. {
  964. tempIndex = gun_index;
  965. }
  966. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  967. {
  968. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  969. {
  970. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].EvBatterySoc;
  971. }
  972. }
  973. }
  974. break;
  975. case Gun_Type_CCS_2:
  976. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  977. {
  978. tempIndex = gun_index;
  979. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  980. {
  981. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  982. {
  983. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc; }
  984. }
  985. }
  986. else
  987. {
  988. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  989. {
  990. tempIndex = ((gun_index==2) ? 1: 0);
  991. }
  992. else
  993. {
  994. tempIndex = gun_index;
  995. }
  996. for (int index = 0; index < CCS_QUANTITY; index++)
  997. {
  998. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  999. {
  1000. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].EvBatterySoc;
  1001. }
  1002. }
  1003. }
  1004. break;
  1005. case Gun_Type_GB:
  1006. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1007. {
  1008. tempIndex = gun_index;
  1009. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1010. {
  1011. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1012. {
  1013. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.EvBatterySoc;
  1014. }
  1015. }
  1016. }
  1017. else
  1018. {
  1019. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1020. {
  1021. tempIndex = ((gun_index==2) ? 1: 0);
  1022. }
  1023. else
  1024. {
  1025. tempIndex = gun_index;
  1026. }
  1027. for (int index = 0; index < GB_QUANTITY; index++)
  1028. {
  1029. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1030. {
  1031. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].EvBatterySoc;
  1032. }
  1033. }
  1034. }
  1035. break;
  1036. case Gun_Type_AC:
  1037. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1038. {
  1039. tempIndex = 2;
  1040. }
  1041. else
  1042. {
  1043. tempIndex = gun_index;
  1044. }
  1045. for (int index = 0; index < AC_QUANTITY; index++)
  1046. {
  1047. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1048. {
  1049. out->buffer[0x30] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].EvBatterySoc;
  1050. }
  1051. }
  1052. break;
  1053. }
  1054. // Alarm code
  1055. out->buffer[0x31] = 0x00;
  1056. out->buffer[0x32] = 0x00;
  1057. out->buffer[0x33] = 0x00;
  1058. out->buffer[0x34] = 0x00;
  1059. // Connect status
  1060. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1061. {
  1062. case Gun_Type_Chademo:
  1063. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1064. {
  1065. tempIndex = gun_index;
  1066. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1067. {
  1068. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1069. {
  1070. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn?0x02:0x00;
  1071. }
  1072. }
  1073. }
  1074. else
  1075. {
  1076. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1077. {
  1078. tempIndex = ((gun_index==2) ? 1: 0);
  1079. }
  1080. else
  1081. {
  1082. tempIndex = gun_index;
  1083. }
  1084. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1085. {
  1086. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1087. {
  1088. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn?0x02:0x00;
  1089. }
  1090. }
  1091. }
  1092. break;
  1093. case Gun_Type_CCS_2:
  1094. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1095. {
  1096. tempIndex = gun_index;
  1097. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1098. {
  1099. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1100. {
  1101. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn?0x02:0x00;
  1102. }
  1103. }
  1104. }
  1105. else
  1106. {
  1107. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1108. {
  1109. tempIndex = ((gun_index==2) ? 1: 0);
  1110. }
  1111. else
  1112. {
  1113. tempIndex = gun_index;
  1114. }
  1115. for (int index = 0; index < CCS_QUANTITY; index++)
  1116. {
  1117. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1118. {
  1119. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn?0x02:0x00;
  1120. }
  1121. }
  1122. }
  1123. break;
  1124. case Gun_Type_GB:
  1125. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1126. {
  1127. tempIndex = gun_index;
  1128. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1129. {
  1130. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1131. {
  1132. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn?0x02:0x00;
  1133. }
  1134. }
  1135. }
  1136. else
  1137. {
  1138. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1139. {
  1140. tempIndex = ((gun_index==2) ? 1: 0);
  1141. }
  1142. else
  1143. {
  1144. tempIndex = gun_index;
  1145. }
  1146. for (int index = 0; index < GB_QUANTITY; index++)
  1147. {
  1148. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1149. {
  1150. out->buffer[0x35] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn?0x02:0x00;
  1151. }
  1152. }
  1153. }
  1154. break;
  1155. case Gun_Type_AC:
  1156. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1157. {
  1158. tempIndex = 2;
  1159. }
  1160. else
  1161. {
  1162. tempIndex = gun_index;
  1163. }
  1164. for (int index = 0; index < AC_QUANTITY; index++)
  1165. {
  1166. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1167. {
  1168. out->buffer[0x35] = ((2<=ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState)&&(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState<=5))?0x02:0x00;
  1169. }
  1170. }
  1171. break;
  1172. }
  1173. // Charging amount
  1174. out->buffer[0x36] = 0x00;
  1175. out->buffer[0x37] = 0x00;
  1176. out->buffer[0x38] = 0x00;
  1177. out->buffer[0x39] = 0x00;
  1178. // Charging temperature
  1179. out->buffer[0x3a] = 0x00;
  1180. out->buffer[0x3b] = 0x00;
  1181. out->buffer[0x3c] = 0x00;
  1182. out->buffer[0x3d] = 0x00;
  1183. // Total power consumption
  1184. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1185. {
  1186. case Gun_Type_Chademo:
  1187. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1188. {
  1189. tempIndex = gun_index;
  1190. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1191. {
  1192. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1193. {
  1194. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  1195. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  1196. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  1197. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  1198. }
  1199. }
  1200. }
  1201. else
  1202. {
  1203. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1204. {
  1205. tempIndex = ((gun_index==2) ? 1: 0);
  1206. }
  1207. else
  1208. {
  1209. tempIndex = gun_index;
  1210. }
  1211. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1212. {
  1213. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1214. {
  1215. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)&0xff;
  1216. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>8)&0xff;
  1217. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>16)&0xff;
  1218. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>24)&0xff;
  1219. }
  1220. }
  1221. }
  1222. break;
  1223. case Gun_Type_CCS_2:
  1224. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1225. {
  1226. tempIndex = gun_index;
  1227. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1228. {
  1229. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1230. {
  1231. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  1232. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  1233. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  1234. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  1235. }
  1236. }
  1237. }
  1238. else
  1239. {
  1240. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1241. {
  1242. tempIndex = ((gun_index==2) ? 1: 0);
  1243. }
  1244. else
  1245. {
  1246. tempIndex = gun_index;
  1247. }
  1248. for (int index = 0; index < CCS_QUANTITY; index++)
  1249. {
  1250. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1251. {
  1252. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)&0xff;
  1253. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>8)&0xff;
  1254. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>16)&0xff;
  1255. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>24)&0xff;
  1256. }
  1257. }
  1258. }
  1259. break;
  1260. case Gun_Type_GB:
  1261. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1262. {
  1263. tempIndex = gun_index;
  1264. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1265. {
  1266. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1267. {
  1268. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  1269. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  1270. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  1271. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  1272. }
  1273. }
  1274. }
  1275. else
  1276. {
  1277. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1278. {
  1279. tempIndex = ((gun_index==2) ? 1: 0);
  1280. }
  1281. else
  1282. {
  1283. tempIndex = gun_index;
  1284. }
  1285. for (int index = 0; index < GB_QUANTITY; index++)
  1286. {
  1287. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1288. {
  1289. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)&0xff;
  1290. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>8)&0xff;
  1291. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>16)&0xff;
  1292. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>24)&0xff;
  1293. }
  1294. }
  1295. }
  1296. break;
  1297. case Gun_Type_AC:
  1298. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1299. {
  1300. tempIndex = 2;
  1301. }
  1302. else
  1303. {
  1304. tempIndex = gun_index;
  1305. }
  1306. for (int index = 0; index < AC_QUANTITY; index++)
  1307. {
  1308. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1309. {
  1310. out->buffer[0x3e] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)&0xff;
  1311. out->buffer[0x3f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>8)&0xff;
  1312. out->buffer[0x40] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>16)&0xff;
  1313. out->buffer[0x41] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>24)&0xff;
  1314. }
  1315. }
  1316. break;
  1317. }
  1318. // DC voltage
  1319. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1320. {
  1321. case Gun_Type_Chademo:
  1322. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1323. {
  1324. tempIndex = gun_index;
  1325. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1326. {
  1327. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1328. {
  1329. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)&0xff;
  1330. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)>>8)&0xff;
  1331. }
  1332. }
  1333. }
  1334. else
  1335. {
  1336. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1337. {
  1338. tempIndex = ((gun_index==2) ? 1: 0);
  1339. }
  1340. else
  1341. {
  1342. tempIndex = gun_index;
  1343. }
  1344. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1345. {
  1346. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1347. {
  1348. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].FireChargingVoltage*10)&0xff;
  1349. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].FireChargingVoltage*10)>>8)&0xff;
  1350. }
  1351. }
  1352. }
  1353. break;
  1354. case Gun_Type_CCS_2:
  1355. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1356. {
  1357. tempIndex = gun_index;
  1358. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1359. {
  1360. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1361. {
  1362. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)&0xff;
  1363. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)>>8)&0xff;
  1364. }
  1365. }
  1366. }
  1367. else
  1368. {
  1369. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1370. {
  1371. tempIndex = ((gun_index==2) ? 1: 0);
  1372. }
  1373. else
  1374. {
  1375. tempIndex = gun_index;
  1376. }
  1377. for (int index = 0; index < CCS_QUANTITY; index++)
  1378. {
  1379. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1380. {
  1381. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].FireChargingVoltage*10)&0xff;
  1382. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].FireChargingVoltage*10)>>8)&0xff;
  1383. }
  1384. }
  1385. }
  1386. break;
  1387. case Gun_Type_GB:
  1388. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1389. {
  1390. tempIndex = gun_index;
  1391. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1392. {
  1393. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1394. {
  1395. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)&0xff;
  1396. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.FireChargingVoltage*10)>>8)&0xff;
  1397. }
  1398. }
  1399. }
  1400. else
  1401. {
  1402. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1403. {
  1404. tempIndex = ((gun_index==2) ? 1: 0);
  1405. }
  1406. else
  1407. {
  1408. tempIndex = gun_index;
  1409. }
  1410. for (int index = 0; index < GB_QUANTITY; index++)
  1411. {
  1412. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1413. {
  1414. out->buffer[0x42] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].FireChargingVoltage*10)&0xff;
  1415. out->buffer[0x43] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].FireChargingVoltage*10)>>8)&0xff;
  1416. }
  1417. }
  1418. }
  1419. break;
  1420. case Gun_Type_AC:
  1421. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1422. {
  1423. tempIndex = 2;
  1424. }
  1425. else
  1426. {
  1427. tempIndex = gun_index;
  1428. }
  1429. for (int index = 0; index < AC_QUANTITY; index++)
  1430. {
  1431. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1432. {
  1433. out->buffer[0x42] = 0x00;
  1434. out->buffer[0x43] = 0x00;
  1435. }
  1436. }
  1437. break;
  1438. }
  1439. // DC current
  1440. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1441. {
  1442. case Gun_Type_Chademo:
  1443. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1444. {
  1445. tempIndex = gun_index;
  1446. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1447. {
  1448. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1449. {
  1450. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  1451. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  1452. }
  1453. }
  1454. }
  1455. else
  1456. {
  1457. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1458. {
  1459. tempIndex = ((gun_index==2) ? 1: 0);
  1460. }
  1461. else
  1462. {
  1463. tempIndex = gun_index;
  1464. }
  1465. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1466. {
  1467. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1468. {
  1469. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*10)&0xff;
  1470. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  1471. }
  1472. }
  1473. }
  1474. break;
  1475. case Gun_Type_CCS_2:
  1476. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1477. {
  1478. tempIndex = gun_index;
  1479. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1480. {
  1481. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1482. {
  1483. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  1484. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  1485. }
  1486. }
  1487. }
  1488. else
  1489. {
  1490. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1491. {
  1492. tempIndex = ((gun_index==2) ? 1: 0);
  1493. }
  1494. else
  1495. {
  1496. tempIndex = gun_index;
  1497. }
  1498. for (int index = 0; index < CCS_QUANTITY; index++)
  1499. {
  1500. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1501. {
  1502. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*10)&0xff;
  1503. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  1504. }
  1505. }
  1506. }
  1507. break;
  1508. case Gun_Type_GB:
  1509. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1510. {
  1511. tempIndex = gun_index;
  1512. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1513. {
  1514. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1515. {
  1516. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  1517. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  1518. }
  1519. }
  1520. }
  1521. else
  1522. {
  1523. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1524. {
  1525. tempIndex = ((gun_index==2) ? 1: 0);
  1526. }
  1527. else
  1528. {
  1529. tempIndex = gun_index;
  1530. }
  1531. for (int index = 0; index < GB_QUANTITY; index++)
  1532. {
  1533. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1534. {
  1535. out->buffer[0x44] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*10)&0xff;
  1536. out->buffer[0x45] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  1537. }
  1538. }
  1539. }
  1540. break;
  1541. case Gun_Type_AC:
  1542. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1543. {
  1544. tempIndex = 2;
  1545. }
  1546. else
  1547. {
  1548. tempIndex = gun_index;
  1549. }
  1550. for (int index = 0; index < AC_QUANTITY; index++)
  1551. {
  1552. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1553. {
  1554. out->buffer[0x44] = 0x00;
  1555. out->buffer[0x45] = 0x00;
  1556. }
  1557. }
  1558. break;
  1559. }
  1560. // BMS voltage request
  1561. out->buffer[0x46] = 0x00;
  1562. out->buffer[0x47] = 0x00;
  1563. // BMS current request
  1564. out->buffer[0x48] = 0x00;
  1565. out->buffer[0x49] = 0x00;
  1566. // BMS charging mode
  1567. out->buffer[0x4a] = 0x00;
  1568. // AC L1 voltage
  1569. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1570. {
  1571. case Gun_Type_Chademo:
  1572. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1573. {
  1574. tempIndex = gun_index;
  1575. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1576. {
  1577. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1578. {
  1579. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)&0xff;
  1580. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)>>8)&0xff;
  1581. }
  1582. }
  1583. }
  1584. else
  1585. {
  1586. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1587. {
  1588. tempIndex = ((gun_index==2) ? 1: 0);
  1589. }
  1590. else
  1591. {
  1592. tempIndex = gun_index;
  1593. }
  1594. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1595. {
  1596. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1597. {
  1598. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*10)&0xff;
  1599. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltage*10)>>8)&0xff;
  1600. }
  1601. }
  1602. }
  1603. break;
  1604. case Gun_Type_CCS_2:
  1605. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1606. {
  1607. tempIndex = gun_index;
  1608. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1609. {
  1610. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1611. {
  1612. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)&0xff;
  1613. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)>>8)&0xff;
  1614. }
  1615. }
  1616. }
  1617. else
  1618. {
  1619. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1620. {
  1621. tempIndex = ((gun_index==2) ? 1: 0);
  1622. }
  1623. else
  1624. {
  1625. tempIndex = gun_index;
  1626. }
  1627. for (int index = 0; index < CCS_QUANTITY; index++)
  1628. {
  1629. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1630. {
  1631. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*10)&0xff;
  1632. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltage*10)>>8)&0xff;
  1633. }
  1634. }
  1635. }
  1636. break;
  1637. case Gun_Type_GB:
  1638. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1639. {
  1640. tempIndex = gun_index;
  1641. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1642. {
  1643. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1644. {
  1645. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)&0xff;
  1646. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltage*10)>>8)&0xff;
  1647. }
  1648. }
  1649. }
  1650. else
  1651. {
  1652. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1653. {
  1654. tempIndex = ((gun_index==2) ? 1: 0);
  1655. }
  1656. else
  1657. {
  1658. tempIndex = gun_index;
  1659. }
  1660. for (int index = 0; index < GB_QUANTITY; index++)
  1661. {
  1662. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1663. {
  1664. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*10)&0xff;
  1665. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltage*10)>>8)&0xff;
  1666. }
  1667. }
  1668. }
  1669. break;
  1670. case Gun_Type_AC:
  1671. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1672. {
  1673. tempIndex = 2;
  1674. }
  1675. else
  1676. {
  1677. tempIndex = gun_index;
  1678. }
  1679. for (int index = 0; index < AC_QUANTITY; index++)
  1680. {
  1681. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1682. {
  1683. out->buffer[0x4b] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*10)&0xff;
  1684. out->buffer[0x4c] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltage*10)>>8)&0xff;
  1685. }
  1686. }
  1687. break;
  1688. }
  1689. // AC L2 voltage
  1690. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1691. {
  1692. case Gun_Type_Chademo:
  1693. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1694. {
  1695. tempIndex = gun_index;
  1696. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1697. {
  1698. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1699. {
  1700. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)&0xff;
  1701. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)>>8)&0xff;
  1702. }
  1703. }
  1704. }
  1705. else
  1706. {
  1707. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1708. {
  1709. tempIndex = ((gun_index==2) ? 1: 0);
  1710. }
  1711. else
  1712. {
  1713. tempIndex = gun_index;
  1714. }
  1715. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1716. {
  1717. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1718. {
  1719. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltageL2*10)&0xff;
  1720. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltageL2*10)>>8)&0xff;
  1721. }
  1722. }
  1723. }
  1724. break;
  1725. case Gun_Type_CCS_2:
  1726. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1727. {
  1728. tempIndex = gun_index;
  1729. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1730. {
  1731. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1732. {
  1733. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)&0xff;
  1734. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)>>8)&0xff;
  1735. }
  1736. }
  1737. }
  1738. else
  1739. {
  1740. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1741. {
  1742. tempIndex = ((gun_index==2) ? 1: 0);
  1743. }
  1744. else
  1745. {
  1746. tempIndex = gun_index;
  1747. }
  1748. for (int index = 0; index < CCS_QUANTITY; index++)
  1749. {
  1750. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1751. {
  1752. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltageL2*10)&0xff;
  1753. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltageL2*10)>>8)&0xff;
  1754. }
  1755. }
  1756. }
  1757. break;
  1758. case Gun_Type_GB:
  1759. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1760. {
  1761. tempIndex = gun_index;
  1762. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1763. {
  1764. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1765. {
  1766. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)&0xff;
  1767. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL2*10)>>8)&0xff;
  1768. }
  1769. }
  1770. }
  1771. else
  1772. {
  1773. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1774. {
  1775. tempIndex = ((gun_index==2) ? 1: 0);
  1776. }
  1777. else
  1778. {
  1779. tempIndex = gun_index;
  1780. }
  1781. for (int index = 0; index < GB_QUANTITY; index++)
  1782. {
  1783. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1784. {
  1785. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltageL2*10)&0xff;
  1786. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltageL2*10)>>8)&0xff;
  1787. }
  1788. }
  1789. }
  1790. break;
  1791. case Gun_Type_AC:
  1792. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1793. {
  1794. tempIndex = 2;
  1795. }
  1796. else
  1797. {
  1798. tempIndex = gun_index;
  1799. }
  1800. for (int index = 0; index < AC_QUANTITY; index++)
  1801. {
  1802. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1803. {
  1804. out->buffer[0x4d] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*10)&0xff;
  1805. out->buffer[0x4e] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL2*10)>>8)&0xff;
  1806. }
  1807. }
  1808. break;
  1809. }
  1810. // AC L3 voltage
  1811. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1812. {
  1813. case Gun_Type_Chademo:
  1814. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1815. {
  1816. tempIndex = gun_index;
  1817. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1818. {
  1819. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1820. {
  1821. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)&0xff;
  1822. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)>>8)&0xff;
  1823. }
  1824. }
  1825. }
  1826. else
  1827. {
  1828. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1829. {
  1830. tempIndex = ((gun_index==2) ? 1: 0);
  1831. }
  1832. else
  1833. {
  1834. tempIndex = gun_index;
  1835. }
  1836. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1837. {
  1838. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1839. {
  1840. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltageL3*10)&0xff;
  1841. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingVoltageL3*10)>>8)&0xff;
  1842. }
  1843. }
  1844. }
  1845. break;
  1846. case Gun_Type_CCS_2:
  1847. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1848. {
  1849. tempIndex = gun_index;
  1850. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1851. {
  1852. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1853. {
  1854. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)&0xff;
  1855. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)>>8)&0xff;
  1856. }
  1857. }
  1858. }
  1859. else
  1860. {
  1861. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1862. {
  1863. tempIndex = ((gun_index==2) ? 1: 0);
  1864. }
  1865. else
  1866. {
  1867. tempIndex = gun_index;
  1868. }
  1869. for (int index = 0; index < CCS_QUANTITY; index++)
  1870. {
  1871. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1872. {
  1873. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltageL3*10)&0xff;
  1874. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingVoltageL3*10)>>8)&0xff;
  1875. }
  1876. }
  1877. }
  1878. break;
  1879. case Gun_Type_GB:
  1880. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1881. {
  1882. tempIndex = gun_index;
  1883. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1884. {
  1885. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1886. {
  1887. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)&0xff;
  1888. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingVoltageL3*10)>>8)&0xff;
  1889. }
  1890. }
  1891. }
  1892. else
  1893. {
  1894. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1895. {
  1896. tempIndex = ((gun_index==2) ? 1: 0);
  1897. }
  1898. else
  1899. {
  1900. tempIndex = gun_index;
  1901. }
  1902. for (int index = 0; index < GB_QUANTITY; index++)
  1903. {
  1904. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  1905. {
  1906. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltageL3*10)&0xff;
  1907. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingVoltageL3*10)>>8)&0xff;
  1908. }
  1909. }
  1910. }
  1911. break;
  1912. case Gun_Type_AC:
  1913. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  1914. {
  1915. tempIndex = 2;
  1916. }
  1917. else
  1918. {
  1919. tempIndex = gun_index;
  1920. }
  1921. for (int index = 0; index < AC_QUANTITY; index++)
  1922. {
  1923. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  1924. {
  1925. out->buffer[0x4f] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*10)&0xff;
  1926. out->buffer[0x50] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingVoltageL3*10)>>8)&0xff;
  1927. }
  1928. }
  1929. break;
  1930. }
  1931. // AC L1 current
  1932. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  1933. {
  1934. case Gun_Type_Chademo:
  1935. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1936. {
  1937. tempIndex = gun_index;
  1938. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1939. {
  1940. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1941. {
  1942. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  1943. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  1944. }
  1945. }
  1946. }
  1947. else
  1948. {
  1949. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1950. {
  1951. tempIndex = ((gun_index==2) ? 1: 0);
  1952. }
  1953. else
  1954. {
  1955. tempIndex = gun_index;
  1956. }
  1957. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  1958. {
  1959. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  1960. {
  1961. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*10)&0xff;
  1962. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  1963. }
  1964. }
  1965. }
  1966. break;
  1967. case Gun_Type_CCS_2:
  1968. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  1969. {
  1970. tempIndex = gun_index;
  1971. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  1972. {
  1973. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  1974. {
  1975. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  1976. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  1977. }
  1978. }
  1979. }
  1980. else
  1981. {
  1982. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  1983. {
  1984. tempIndex = ((gun_index==2) ? 1: 0);
  1985. }
  1986. else
  1987. {
  1988. tempIndex = gun_index;
  1989. }
  1990. for (int index = 0; index < CCS_QUANTITY; index++)
  1991. {
  1992. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  1993. {
  1994. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*10)&0xff;
  1995. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  1996. }
  1997. }
  1998. }
  1999. break;
  2000. case Gun_Type_GB:
  2001. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2002. {
  2003. tempIndex = gun_index;
  2004. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2005. {
  2006. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2007. {
  2008. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)&0xff;
  2009. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrent*10)>>8)&0xff;
  2010. }
  2011. }
  2012. }
  2013. else
  2014. {
  2015. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2016. {
  2017. tempIndex = ((gun_index==2) ? 1: 0);
  2018. }
  2019. else
  2020. {
  2021. tempIndex = gun_index;
  2022. }
  2023. for (int index = 0; index < GB_QUANTITY; index++)
  2024. {
  2025. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2026. {
  2027. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*10)&0xff;
  2028. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  2029. }
  2030. }
  2031. }
  2032. break;
  2033. case Gun_Type_AC:
  2034. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2035. {
  2036. tempIndex = 2;
  2037. }
  2038. else
  2039. {
  2040. tempIndex = gun_index;
  2041. }
  2042. for (int index = 0; index < AC_QUANTITY; index++)
  2043. {
  2044. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2045. {
  2046. out->buffer[0x51] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*10)&0xff;
  2047. out->buffer[0x52] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrent*10)>>8)&0xff;
  2048. }
  2049. }
  2050. break;
  2051. }
  2052. // AC L2 current
  2053. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2054. {
  2055. case Gun_Type_Chademo:
  2056. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2057. {
  2058. tempIndex = gun_index;
  2059. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2060. {
  2061. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2062. {
  2063. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)&0xff;
  2064. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)>>8)&0xff;
  2065. }
  2066. }
  2067. }
  2068. else
  2069. {
  2070. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2071. {
  2072. tempIndex = ((gun_index==2) ? 1: 0);
  2073. }
  2074. else
  2075. {
  2076. tempIndex = gun_index;
  2077. }
  2078. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2079. {
  2080. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2081. {
  2082. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrentL2*10)&0xff;
  2083. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrentL2*10)>>8)&0xff;
  2084. }
  2085. }
  2086. }
  2087. break;
  2088. case Gun_Type_CCS_2:
  2089. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2090. {
  2091. tempIndex = gun_index;
  2092. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2093. {
  2094. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2095. {
  2096. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)&0xff;
  2097. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)>>8)&0xff;
  2098. }
  2099. }
  2100. }
  2101. else
  2102. {
  2103. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2104. {
  2105. tempIndex = ((gun_index==2) ? 1: 0);
  2106. }
  2107. else
  2108. {
  2109. tempIndex = gun_index;
  2110. }
  2111. for (int index = 0; index < CCS_QUANTITY; index++)
  2112. {
  2113. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2114. {
  2115. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrentL2*10)&0xff;
  2116. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrentL2*10)>>8)&0xff;
  2117. }
  2118. }
  2119. }
  2120. break;
  2121. case Gun_Type_GB:
  2122. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2123. {
  2124. tempIndex = gun_index;
  2125. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2126. {
  2127. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2128. {
  2129. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)&0xff;
  2130. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL2*10)>>8)&0xff;
  2131. }
  2132. }
  2133. }
  2134. else
  2135. {
  2136. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2137. {
  2138. tempIndex = ((gun_index==2) ? 1: 0);
  2139. }
  2140. else
  2141. {
  2142. tempIndex = gun_index;
  2143. }
  2144. for (int index = 0; index < GB_QUANTITY; index++)
  2145. {
  2146. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2147. {
  2148. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrentL2*10)&0xff;
  2149. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrentL2*10)>>8)&0xff;
  2150. }
  2151. }
  2152. }
  2153. break;
  2154. case Gun_Type_AC:
  2155. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2156. {
  2157. tempIndex = 2;
  2158. }
  2159. else
  2160. {
  2161. tempIndex = gun_index;
  2162. }
  2163. for (int index = 0; index < AC_QUANTITY; index++)
  2164. {
  2165. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2166. {
  2167. out->buffer[0x53] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*10)&0xff;
  2168. out->buffer[0x54] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL2*10)>>8)&0xff;
  2169. }
  2170. }
  2171. break;
  2172. }
  2173. // AC L3 current
  2174. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2175. {
  2176. case Gun_Type_Chademo:
  2177. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2178. {
  2179. tempIndex = gun_index;
  2180. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2181. {
  2182. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2183. {
  2184. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)&0xff;
  2185. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)>>8)&0xff;
  2186. }
  2187. }
  2188. }
  2189. else
  2190. {
  2191. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2192. {
  2193. tempIndex = ((gun_index==2) ? 1: 0);
  2194. }
  2195. else
  2196. {
  2197. tempIndex = gun_index;
  2198. }
  2199. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2200. {
  2201. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2202. {
  2203. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrentL3*10)&0xff;
  2204. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargingCurrentL3*10)>>8)&0xff;
  2205. }
  2206. }
  2207. }
  2208. break;
  2209. case Gun_Type_CCS_2:
  2210. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2211. {
  2212. tempIndex = gun_index;
  2213. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2214. {
  2215. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2216. {
  2217. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)&0xff;
  2218. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)>>8)&0xff;
  2219. }
  2220. }
  2221. }
  2222. else
  2223. {
  2224. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2225. {
  2226. tempIndex = ((gun_index==2) ? 1: 0);
  2227. }
  2228. else
  2229. {
  2230. tempIndex = gun_index;
  2231. }
  2232. for (int index = 0; index < CCS_QUANTITY; index++)
  2233. {
  2234. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2235. {
  2236. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrentL3*10)&0xff;
  2237. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargingCurrentL3*10)>>8)&0xff;
  2238. }
  2239. }
  2240. }
  2241. break;
  2242. case Gun_Type_GB:
  2243. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2244. {
  2245. tempIndex = gun_index;
  2246. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2247. {
  2248. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2249. {
  2250. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)&0xff;
  2251. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargingCurrentL3*10)>>8)&0xff;
  2252. }
  2253. }
  2254. }
  2255. else
  2256. {
  2257. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2258. {
  2259. tempIndex = ((gun_index==2) ? 1: 0);
  2260. }
  2261. else
  2262. {
  2263. tempIndex = gun_index;
  2264. }
  2265. for (int index = 0; index < GB_QUANTITY; index++)
  2266. {
  2267. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2268. {
  2269. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrentL3*10)&0xff;
  2270. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargingCurrentL3*10)>>8)&0xff;
  2271. }
  2272. }
  2273. }
  2274. break;
  2275. case Gun_Type_AC:
  2276. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2277. {
  2278. tempIndex = 2;
  2279. }
  2280. else
  2281. {
  2282. tempIndex = gun_index;
  2283. }
  2284. for (int index = 0; index < AC_QUANTITY; index++)
  2285. {
  2286. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2287. {
  2288. out->buffer[0x55] = (uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*10)&0xff;
  2289. out->buffer[0x56] = ((uint16_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargingCurrentL3*10)>>8)&0xff;
  2290. }
  2291. }
  2292. break;
  2293. }
  2294. // Charging remind time
  2295. out->buffer[0x57] = 0x00;
  2296. out->buffer[0x58] = 0x00;
  2297. // Charging time
  2298. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2299. {
  2300. case Gun_Type_Chademo:
  2301. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2302. {
  2303. tempIndex = gun_index;
  2304. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2305. {
  2306. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2307. {
  2308. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)&0xff;
  2309. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>8)&0xff;
  2310. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>16)&0xff;
  2311. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>24)&0xff;
  2312. }
  2313. }
  2314. }
  2315. else
  2316. {
  2317. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2318. {
  2319. tempIndex = ((gun_index==2) ? 1: 0);
  2320. }
  2321. else
  2322. {
  2323. tempIndex = gun_index;
  2324. }
  2325. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2326. {
  2327. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2328. {
  2329. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedDuration*1)&0xff;
  2330. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedDuration*1)>>8)&0xff;
  2331. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedDuration*1)>>16)&0xff;
  2332. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedDuration*1)>>24)&0xff;
  2333. }
  2334. }
  2335. }
  2336. break;
  2337. case Gun_Type_CCS_2:
  2338. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2339. {
  2340. tempIndex = gun_index;
  2341. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2342. {
  2343. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2344. {
  2345. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)&0xff;
  2346. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>8)&0xff;
  2347. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>16)&0xff;
  2348. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>24)&0xff;
  2349. }
  2350. }
  2351. }
  2352. else
  2353. {
  2354. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2355. {
  2356. tempIndex = ((gun_index==2) ? 1: 0);
  2357. }
  2358. else
  2359. {
  2360. tempIndex = gun_index;
  2361. }
  2362. for (int index = 0; index < CCS_QUANTITY; index++)
  2363. {
  2364. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2365. {
  2366. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedDuration*1)&0xff;
  2367. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedDuration*1)>>8)&0xff;
  2368. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedDuration*1)>>16)&0xff;
  2369. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedDuration*1)>>24)&0xff;
  2370. }
  2371. }
  2372. }
  2373. break;
  2374. case Gun_Type_GB:
  2375. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2376. {
  2377. tempIndex = gun_index;
  2378. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2379. {
  2380. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2381. {
  2382. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)&0xff;
  2383. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>8)&0xff;
  2384. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>16)&0xff;
  2385. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedDuration*1)>>24)&0xff;
  2386. }
  2387. }
  2388. }
  2389. else
  2390. {
  2391. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2392. {
  2393. tempIndex = ((gun_index==2) ? 1: 0);
  2394. }
  2395. else
  2396. {
  2397. tempIndex = gun_index;
  2398. }
  2399. for (int index = 0; index < GB_QUANTITY; index++)
  2400. {
  2401. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2402. {
  2403. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedDuration*1)&0xff;
  2404. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedDuration*1)>>8)&0xff;
  2405. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedDuration*1)>>16)&0xff;
  2406. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedDuration*1)>>24)&0xff;
  2407. }
  2408. }
  2409. }
  2410. break;
  2411. case Gun_Type_AC:
  2412. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2413. {
  2414. tempIndex = 2;
  2415. }
  2416. else
  2417. {
  2418. tempIndex = gun_index;
  2419. }
  2420. for (int index = 0; index < AC_QUANTITY; index++)
  2421. {
  2422. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2423. {
  2424. out->buffer[0x59] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedDuration*1)&0xff;
  2425. out->buffer[0x5a] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedDuration*1)>>8)&0xff;
  2426. out->buffer[0x5b] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedDuration*1)>>16)&0xff;
  2427. out->buffer[0x5c] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedDuration*1)>>24)&0xff;
  2428. }
  2429. }
  2430. break;
  2431. }
  2432. // Charging power consumption
  2433. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2434. {
  2435. case Gun_Type_Chademo:
  2436. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2437. {
  2438. tempIndex = gun_index;
  2439. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2440. {
  2441. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2442. {
  2443. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)&0xff;
  2444. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>8)&0xff;
  2445. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>16)&0xff;
  2446. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>24)&0xff;
  2447. }
  2448. }
  2449. }
  2450. else
  2451. {
  2452. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2453. {
  2454. tempIndex = ((gun_index==2) ? 1: 0);
  2455. }
  2456. else
  2457. {
  2458. tempIndex = gun_index;
  2459. }
  2460. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2461. {
  2462. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2463. {
  2464. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100)&0xff;
  2465. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100)>>8)&0xff;
  2466. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100)>>16)&0xff;
  2467. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PresentChargedEnergy*100)>>24)&0xff;
  2468. }
  2469. }
  2470. }
  2471. break;
  2472. case Gun_Type_CCS_2:
  2473. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2474. {
  2475. tempIndex = gun_index;
  2476. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2477. {
  2478. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2479. {
  2480. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)&0xff;
  2481. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>8)&0xff;
  2482. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>16)&0xff;
  2483. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>24)&0xff;
  2484. }
  2485. }
  2486. }
  2487. else
  2488. {
  2489. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2490. {
  2491. tempIndex = ((gun_index==2) ? 1: 0);
  2492. }
  2493. else
  2494. {
  2495. tempIndex = gun_index;
  2496. }
  2497. for (int index = 0; index < CCS_QUANTITY; index++)
  2498. {
  2499. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2500. {
  2501. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100)&0xff;
  2502. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100)>>8)&0xff;
  2503. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100)>>16)&0xff;
  2504. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PresentChargedEnergy*100)>>24)&0xff;
  2505. }
  2506. }
  2507. }
  2508. break;
  2509. case Gun_Type_GB:
  2510. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2511. {
  2512. tempIndex = gun_index;
  2513. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2514. {
  2515. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2516. {
  2517. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)&0xff;
  2518. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>8)&0xff;
  2519. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>16)&0xff;
  2520. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PresentChargedEnergy*100)>>24)&0xff;
  2521. }
  2522. }
  2523. }
  2524. else
  2525. {
  2526. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2527. {
  2528. tempIndex = ((gun_index==2) ? 1: 0);
  2529. }
  2530. else
  2531. {
  2532. tempIndex = gun_index;
  2533. }
  2534. for (int index = 0; index < GB_QUANTITY; index++)
  2535. {
  2536. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2537. {
  2538. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100)&0xff;
  2539. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100)>>8)&0xff;
  2540. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100)>>16)&0xff;
  2541. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PresentChargedEnergy*100)>>24)&0xff;
  2542. }
  2543. }
  2544. }
  2545. break;
  2546. case Gun_Type_AC:
  2547. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2548. {
  2549. tempIndex = 2;
  2550. }
  2551. else
  2552. {
  2553. tempIndex = gun_index;
  2554. }
  2555. for (int index = 0; index < AC_QUANTITY; index++)
  2556. {
  2557. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2558. {
  2559. out->buffer[0x5d] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100)&0xff;
  2560. out->buffer[0x5e] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100)>>8)&0xff;
  2561. out->buffer[0x5f] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100)>>16)&0xff;
  2562. out->buffer[0x60] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PresentChargedEnergy*100)>>24)&0xff;
  2563. }
  2564. }
  2565. break;
  2566. }
  2567. // Before charging meter value
  2568. out->buffer[0x61] = 0x00;
  2569. out->buffer[0x62] = 0x00;
  2570. out->buffer[0x63] = 0x00;
  2571. out->buffer[0x64] = 0x00;
  2572. // After charging meter value
  2573. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2574. {
  2575. case Gun_Type_Chademo:
  2576. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2577. {
  2578. tempIndex = gun_index;
  2579. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2580. {
  2581. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2582. {
  2583. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  2584. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  2585. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  2586. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  2587. }
  2588. }
  2589. }
  2590. else
  2591. {
  2592. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2593. {
  2594. tempIndex = ((gun_index==2) ? 1: 0);
  2595. }
  2596. else
  2597. {
  2598. tempIndex = gun_index;
  2599. }
  2600. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2601. {
  2602. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2603. {
  2604. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)&0xff;
  2605. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>8)&0xff;
  2606. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>16)&0xff;
  2607. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].PowerConsumption*100)>>24)&0xff;
  2608. }
  2609. }
  2610. }
  2611. break;
  2612. case Gun_Type_CCS_2:
  2613. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2614. {
  2615. tempIndex = gun_index;
  2616. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2617. {
  2618. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2619. {
  2620. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  2621. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  2622. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  2623. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  2624. }
  2625. }
  2626. }
  2627. else
  2628. {
  2629. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2630. {
  2631. tempIndex = ((gun_index==2) ? 1: 0);
  2632. }
  2633. else
  2634. {
  2635. tempIndex = gun_index;
  2636. }
  2637. for (int index = 0; index < CCS_QUANTITY; index++)
  2638. {
  2639. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2640. {
  2641. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)&0xff;
  2642. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>8)&0xff;
  2643. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>16)&0xff;
  2644. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].PowerConsumption*100)>>24)&0xff;
  2645. }
  2646. }
  2647. }
  2648. break;
  2649. case Gun_Type_GB:
  2650. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2651. {
  2652. tempIndex = gun_index;
  2653. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2654. {
  2655. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2656. {
  2657. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)&0xff;
  2658. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>8)&0xff;
  2659. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>16)&0xff;
  2660. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.PowerConsumption*100)>>24)&0xff;
  2661. }
  2662. }
  2663. }
  2664. else
  2665. {
  2666. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2667. {
  2668. tempIndex = ((gun_index==2) ? 1: 0);
  2669. }
  2670. else
  2671. {
  2672. tempIndex = gun_index;
  2673. }
  2674. for (int index = 0; index < GB_QUANTITY; index++)
  2675. {
  2676. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2677. {
  2678. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)&0xff;
  2679. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>8)&0xff;
  2680. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>16)&0xff;
  2681. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].PowerConsumption*100)>>24)&0xff;
  2682. }
  2683. }
  2684. }
  2685. break;
  2686. case Gun_Type_AC:
  2687. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2688. {
  2689. tempIndex = 2;
  2690. }
  2691. else
  2692. {
  2693. tempIndex = gun_index;
  2694. }
  2695. for (int index = 0; index < AC_QUANTITY; index++)
  2696. {
  2697. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2698. {
  2699. out->buffer[0x65] = (uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)&0xff;
  2700. out->buffer[0x66] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>8)&0xff;
  2701. out->buffer[0x67] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>16)&0xff;
  2702. out->buffer[0x68] = ((uint32_t)(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PowerConsumption*100)>>24)&0xff;
  2703. }
  2704. }
  2705. break;
  2706. }
  2707. // Start method
  2708. out->buffer[0x69] = 0x00;
  2709. // Charging strategy
  2710. out->buffer[0x6a] = 0x00;
  2711. // Charging parameter
  2712. out->buffer[0x6b] = 0x00;
  2713. out->buffer[0x6c] = 0x00;
  2714. out->buffer[0x6d] = 0x00;
  2715. out->buffer[0x6e] = 0x00;
  2716. // Reservation flag
  2717. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2718. {
  2719. case Gun_Type_Chademo:
  2720. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2721. {
  2722. tempIndex = gun_index;
  2723. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2724. {
  2725. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2726. {
  2727. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2728. }
  2729. }
  2730. }
  2731. else
  2732. {
  2733. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2734. {
  2735. tempIndex = ((gun_index==2) ? 1: 0);
  2736. }
  2737. else
  2738. {
  2739. tempIndex = gun_index;
  2740. }
  2741. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2742. {
  2743. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2744. {
  2745. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2746. }
  2747. }
  2748. }
  2749. break;
  2750. case Gun_Type_CCS_2:
  2751. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2752. {
  2753. tempIndex = gun_index;
  2754. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2755. {
  2756. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2757. {
  2758. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2759. }
  2760. }
  2761. }
  2762. else
  2763. {
  2764. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2765. {
  2766. tempIndex = ((gun_index==2) ? 1: 0);
  2767. }
  2768. else
  2769. {
  2770. tempIndex = gun_index;
  2771. }
  2772. for (int index = 0; index < CCS_QUANTITY; index++)
  2773. {
  2774. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2775. {
  2776. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2777. }
  2778. }
  2779. }
  2780. break;
  2781. case Gun_Type_GB:
  2782. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2783. {
  2784. tempIndex = gun_index;
  2785. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2786. {
  2787. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2788. {
  2789. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2790. }
  2791. }
  2792. }
  2793. else
  2794. {
  2795. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2796. {
  2797. tempIndex = ((gun_index==2) ? 1: 0);
  2798. }
  2799. else
  2800. {
  2801. tempIndex = gun_index;
  2802. }
  2803. for (int index = 0; index < GB_QUANTITY; index++)
  2804. {
  2805. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2806. {
  2807. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2808. }
  2809. }
  2810. }
  2811. break;
  2812. case Gun_Type_AC:
  2813. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2814. {
  2815. tempIndex = 2;
  2816. }
  2817. else
  2818. {
  2819. tempIndex = gun_index;
  2820. }
  2821. for (int index = 0; index < AC_QUANTITY; index++)
  2822. {
  2823. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2824. {
  2825. out->buffer[0x6f] = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus == SYS_MODE_RESERVATION?0x01:0x00;
  2826. }
  2827. }
  2828. break;
  2829. }
  2830. // User
  2831. memset(&out->buffer[0x70], 0x00, 0x24);
  2832. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2833. {
  2834. case Gun_Type_Chademo:
  2835. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2836. {
  2837. tempIndex = gun_index;
  2838. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2839. {
  2840. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2841. {
  2842. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId));
  2843. }
  2844. }
  2845. }
  2846. else
  2847. {
  2848. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2849. {
  2850. tempIndex = ((gun_index==2) ? 1: 0);
  2851. }
  2852. else
  2853. {
  2854. tempIndex = gun_index;
  2855. }
  2856. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2857. {
  2858. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2859. {
  2860. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartUserId));
  2861. }
  2862. }
  2863. }
  2864. break;
  2865. case Gun_Type_CCS_2:
  2866. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2867. {
  2868. tempIndex = gun_index;
  2869. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2870. {
  2871. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2872. {
  2873. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId));
  2874. }
  2875. }
  2876. }
  2877. else
  2878. {
  2879. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2880. {
  2881. tempIndex = ((gun_index==2) ? 1: 0);
  2882. }
  2883. else
  2884. {
  2885. tempIndex = gun_index;
  2886. }
  2887. for (int index = 0; index < CCS_QUANTITY; index++)
  2888. {
  2889. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  2890. {
  2891. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartUserId));
  2892. }
  2893. }
  2894. }
  2895. break;
  2896. case Gun_Type_GB:
  2897. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2898. {
  2899. tempIndex = gun_index;
  2900. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2901. {
  2902. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2903. {
  2904. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartUserId));
  2905. }
  2906. }
  2907. }
  2908. else
  2909. {
  2910. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2911. {
  2912. tempIndex = ((gun_index==2) ? 1: 0);
  2913. }
  2914. else
  2915. {
  2916. tempIndex = gun_index;
  2917. }
  2918. for (int index = 0; index < GB_QUANTITY; index++)
  2919. {
  2920. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  2921. {
  2922. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartUserId));
  2923. }
  2924. }
  2925. }
  2926. break;
  2927. case Gun_Type_AC:
  2928. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  2929. {
  2930. tempIndex = 2;
  2931. }
  2932. else
  2933. {
  2934. tempIndex = gun_index;
  2935. }
  2936. for (int index = 0; index < AC_QUANTITY; index++)
  2937. {
  2938. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  2939. {
  2940. memcpy(&out->buffer[0x70], ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartUserId));
  2941. }
  2942. }
  2943. break;
  2944. }
  2945. // Reservation over time
  2946. out->buffer[0x94] = 0x00;
  2947. // Start time
  2948. struct ParsingResult
  2949. {
  2950. int year;
  2951. int month;
  2952. int mday;
  2953. int hour;
  2954. int min;
  2955. int sec;
  2956. }result;
  2957. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  2958. {
  2959. case Gun_Type_Chademo:
  2960. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  2961. {
  2962. tempIndex = gun_index;
  2963. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  2964. {
  2965. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  2966. {
  2967. sscanf((char*)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  2968. &result.year,
  2969. &result.month,
  2970. &result.mday,
  2971. &result.hour,
  2972. &result.min,
  2973. &result.sec);
  2974. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  2975. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  2976. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  2977. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  2978. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  2979. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  2980. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  2981. out->buffer[0x9c] = 0xff;
  2982. }
  2983. }
  2984. }
  2985. else
  2986. {
  2987. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  2988. {
  2989. tempIndex = ((gun_index==2) ? 1: 0);
  2990. }
  2991. else
  2992. {
  2993. tempIndex = gun_index;
  2994. }
  2995. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  2996. {
  2997. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  2998. {
  2999. sscanf((char*)ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  3000. &result.year,
  3001. &result.month,
  3002. &result.mday,
  3003. &result.hour,
  3004. &result.min,
  3005. &result.sec);
  3006. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3007. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3008. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3009. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3010. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3011. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3012. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3013. out->buffer[0x9c] = 0xff;
  3014. }
  3015. }
  3016. }
  3017. break;
  3018. case Gun_Type_CCS_2:
  3019. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  3020. {
  3021. tempIndex = gun_index;
  3022. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  3023. {
  3024. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  3025. {
  3026. sscanf((char*)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  3027. &result.year,
  3028. &result.month,
  3029. &result.mday,
  3030. &result.hour,
  3031. &result.min,
  3032. &result.sec);
  3033. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3034. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3035. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3036. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3037. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3038. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3039. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3040. out->buffer[0x9c] = 0xff;
  3041. }
  3042. }
  3043. }
  3044. else
  3045. {
  3046. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  3047. {
  3048. tempIndex = ((gun_index==2) ? 1: 0);
  3049. }
  3050. else
  3051. {
  3052. tempIndex = gun_index;
  3053. }
  3054. for (int index = 0; index < CCS_QUANTITY; index++)
  3055. {
  3056. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  3057. {
  3058. sscanf((char*)ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  3059. &result.year,
  3060. &result.month,
  3061. &result.mday,
  3062. &result.hour,
  3063. &result.min,
  3064. &result.sec);
  3065. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3066. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3067. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3068. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3069. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3070. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3071. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3072. out->buffer[0x9c] = 0xff;
  3073. }
  3074. }
  3075. }
  3076. break;
  3077. case Gun_Type_GB:
  3078. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  3079. {
  3080. tempIndex = gun_index;
  3081. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  3082. {
  3083. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  3084. {
  3085. sscanf((char*)ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  3086. &result.year,
  3087. &result.month,
  3088. &result.mday,
  3089. &result.hour,
  3090. &result.min,
  3091. &result.sec);
  3092. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3093. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3094. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3095. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3096. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3097. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3098. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3099. out->buffer[0x9c] = 0xff;
  3100. }
  3101. }
  3102. }
  3103. else
  3104. {
  3105. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  3106. {
  3107. tempIndex = ((gun_index==2) ? 1: 0);
  3108. }
  3109. else
  3110. {
  3111. tempIndex = gun_index;
  3112. }
  3113. for (int index = 0; index < GB_QUANTITY; index++)
  3114. {
  3115. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  3116. {
  3117. sscanf((char*)ShmSysConfigAndInfo->SysInfo.GbChargingData[index].StartDateTime, "%04d.%02d.%02d %02d:%02d:%02d",
  3118. &result.year,
  3119. &result.month,
  3120. &result.mday,
  3121. &result.hour,
  3122. &result.min,
  3123. &result.sec);
  3124. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3125. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3126. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3127. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3128. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3129. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3130. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3131. out->buffer[0x9c] = 0xff;
  3132. }
  3133. }
  3134. }
  3135. break;
  3136. case Gun_Type_AC:
  3137. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  3138. {
  3139. tempIndex = 2;
  3140. }
  3141. else
  3142. {
  3143. tempIndex = gun_index;
  3144. }
  3145. for (int index = 0; index < AC_QUANTITY; index++)
  3146. {
  3147. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  3148. {
  3149. sscanf((char*)ShmSysConfigAndInfo->SysInfo.AcChargingData[index].StartDateTime, "%d.%d.%d %d:%d:%d",
  3150. &result.year,
  3151. &result.month,
  3152. &result.mday,
  3153. &result.hour,
  3154. &result.min,
  3155. &result.sec);
  3156. out->buffer[0x95] = decTobcd(result.year/100) & 0xff;
  3157. out->buffer[0x96] = decTobcd(result.year%100) & 0xff;
  3158. out->buffer[0x97] = decTobcd(result.month) & 0xff;
  3159. out->buffer[0x98] = decTobcd(result.mday) & 0xff;
  3160. out->buffer[0x99] = decTobcd(result.hour) & 0xff;
  3161. out->buffer[0x9a] = decTobcd(result.min) & 0xff;
  3162. out->buffer[0x9b] = decTobcd(result.sec) & 0xff;
  3163. out->buffer[0x9c] = 0xff;
  3164. }
  3165. }
  3166. break;
  3167. }
  3168. // Surplus
  3169. memset(&out->buffer[0x9d], 0x00, 0x04);
  3170. // System variable reserve
  3171. memset(&out->buffer[0xa1], 0x00, 0x14);
  3172. // RFID/Member flag
  3173. out->buffer[0xb5] = 0x00;
  3174. // Order No.
  3175. memset(&out->buffer[0xb6], 0x00, 0x20);
  3176. // SN
  3177. memset(&out->buffer[0xd6], 0x00, 0x10);
  3178. // Checksum
  3179. out->buffer[out->size-1] = checksum_cal(out);
  3180. showCmdRaw(out, true);
  3181. }
  3182. void create_Cmd_1106(struct Message *out)
  3183. {
  3184. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  3185. out->size = 0x63;
  3186. // Message header
  3187. out->buffer[0x00] = (message_header>>8) & 0xff;
  3188. out->buffer[0x01] = (message_header>>0) & 0xff;
  3189. // Message length
  3190. out->buffer[0x02] = (out->size>>0) & 0xff;
  3191. out->buffer[0x03] = (out->size>>8) & 0xff;
  3192. // Message protocol version
  3193. out->buffer[0x04] = PROTOCOL_VER;
  3194. // Message server command serial number
  3195. out->buffer[0x05] = server_cmd_sn & 0xff;
  3196. // Message command
  3197. out->buffer[0x06] = (1106>>0) & 0xff;
  3198. out->buffer[0x07] = (1106>>8) & 0xff;
  3199. // Message user id
  3200. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  3201. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  3202. // Message server command serial number
  3203. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  3204. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  3205. // Charger ID
  3206. memcpy(&out->buffer[0x0c], &ShmSysConfigAndInfo->SysConfig.SystemId[0], 32);
  3207. // Charger type (0:Normal 1:none polar 2:polling)
  3208. out->buffer[0x2c] = 0x00;
  3209. // Software version
  3210. out->buffer[0x2d] = 0x01;
  3211. out->buffer[0x2e] = 0x00;
  3212. out->buffer[0x2f] = 0x00;
  3213. out->buffer[0x30] = 0x00;
  3214. // Charger item type
  3215. out->buffer[0x31] = 0x00;
  3216. out->buffer[0x32] = 0x00;
  3217. // Start count
  3218. out->buffer[0x33] = 0x00;
  3219. out->buffer[0x34] = 0x00;
  3220. out->buffer[0x35] = 0x00;
  3221. out->buffer[0x36] = 0x00;
  3222. // Data upload type (1:Handshake 2:Report)
  3223. out->buffer[0x37] = 0x02;
  3224. // Register time (Minute)
  3225. out->buffer[0x38] = 0x00;
  3226. out->buffer[0x39] = 0x00;
  3227. // Spare
  3228. out->buffer[0x3a] = 0x00;
  3229. // Charge gun count
  3230. out->buffer[0x3b] = 0x01;
  3231. // Heart beat upload cycle
  3232. out->buffer[0x3c] = 0x98;
  3233. // Heart beat overtime count
  3234. out->buffer[0x3d] = 0x00;
  3235. // Charge record count
  3236. out->buffer[0x3e] = 0x00;
  3237. out->buffer[0x3f] = 0x00;
  3238. out->buffer[0x40] = 0x00;
  3239. out->buffer[0x41] = 0x00;
  3240. // Current system time
  3241. out->buffer[0x42] = 0x20;
  3242. out->buffer[0x43] = 0x20;
  3243. out->buffer[0x44] = 0x06;
  3244. out->buffer[0x45] = 0x11;
  3245. out->buffer[0x46] = 0x11;
  3246. out->buffer[0x47] = 0x02;
  3247. out->buffer[0x48] = 0x18;
  3248. out->buffer[0x49] = 0xff;
  3249. // Latest charge time
  3250. out->buffer[0x4a] = 0x20;
  3251. out->buffer[0x4b] = 0x20;
  3252. out->buffer[0x4c] = 0x06;
  3253. out->buffer[0x4d] = 0x11;
  3254. out->buffer[0x4e] = 0x11;
  3255. out->buffer[0x4f] = 0x01;
  3256. out->buffer[0x50] = 0x52;
  3257. out->buffer[0x51] = 0xff;
  3258. // Latest start time
  3259. out->buffer[0x52] = 0x20;
  3260. out->buffer[0x53] = 0x20;
  3261. out->buffer[0x54] = 0x06;
  3262. out->buffer[0x55] = 0x11;
  3263. out->buffer[0x56] = 0x11;
  3264. out->buffer[0x57] = 0x01;
  3265. out->buffer[0x58] = 0x52;
  3266. out->buffer[0x59] = 0xff;
  3267. // Latest register time
  3268. out->buffer[0x5a] = 0x20;
  3269. out->buffer[0x5b] = 0x20;
  3270. out->buffer[0x5c] = 0x06;
  3271. out->buffer[0x5d] = 0x11;
  3272. out->buffer[0x5e] = 0x11;
  3273. out->buffer[0x5f] = 0x02;
  3274. out->buffer[0x60] = 0x08;
  3275. out->buffer[0x61] = 0xff;
  3276. // Checksum
  3277. out->buffer[out->size-1] = checksum_cal(out);
  3278. showCmdRaw(out, true);
  3279. }
  3280. void create_Cmd_2304(struct Message *out)
  3281. {
  3282. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  3283. out->size = 0x0e;
  3284. // Message header
  3285. out->buffer[0x00] = (message_header>>8) & 0xff;
  3286. out->buffer[0x01] = (message_header>>0) & 0xff;
  3287. // Message length
  3288. out->buffer[0x02] = (out->size>>0) & 0xff;
  3289. out->buffer[0x03] = (out->size>>8) & 0xff;
  3290. // Message protocol version
  3291. out->buffer[0x04] = PROTOCOL_VER;
  3292. // Message server command serial number
  3293. out->buffer[0x05] = server_cmd_sn & 0xff;
  3294. // Message command
  3295. out->buffer[0x06] = (2304>>0) & 0xff;
  3296. out->buffer[0x07] = (2304>>8) & 0xff;
  3297. // Message user id
  3298. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  3299. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  3300. // Message server command serial number
  3301. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  3302. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  3303. // Result (0:Success 1:Fail)
  3304. out->buffer[0x0c] = 0x00;
  3305. // Checksum
  3306. out->buffer[out->size-1] = checksum_cal(out);
  3307. showCmdRaw(out, true);
  3308. }
  3309. void create_Cmd_2306(struct Message *out)
  3310. {
  3311. memset(out->buffer, 0, ARRAY_SIZE(out->buffer));
  3312. out->size = 0x11;
  3313. // Message header
  3314. out->buffer[0x00] = (message_header>>8) & 0xff;
  3315. out->buffer[0x01] = (message_header>>0) & 0xff;
  3316. // Message length
  3317. out->buffer[0x02] = (out->size>>0) & 0xff;
  3318. out->buffer[0x03] = (out->size>>8) & 0xff;
  3319. // Message protocol version
  3320. out->buffer[0x04] = PROTOCOL_VER;
  3321. // Message server command serial number
  3322. out->buffer[0x05] = server_cmd_sn & 0xff;
  3323. // Message command
  3324. out->buffer[0x06] = (2306>>0) & 0xff;
  3325. out->buffer[0x07] = (2306>>8) & 0xff;
  3326. // Message user id
  3327. out->buffer[0x08] = (server_user_id>>0) & 0xff;
  3328. out->buffer[0x09] = (server_user_id>>8) & 0xff;
  3329. // Message server command serial number
  3330. out->buffer[0x0a] = (server_cmd_sn>>0) & 0xff;
  3331. out->buffer[0x0b] = (server_cmd_sn>>8) & 0xff;
  3332. // Result (0:Success 1:Fail)
  3333. out->buffer[0x0c] = 0x00;
  3334. out->buffer[0x0d] = 0x00;
  3335. out->buffer[0x0e] = 0x00;
  3336. out->buffer[0x0f] = 0x00;
  3337. // Checksum
  3338. out->buffer[out->size-1] = checksum_cal(out);
  3339. showCmdRaw(out, true);
  3340. }
  3341. int main(void)
  3342. {
  3343. struct PreviousState
  3344. {
  3345. uint8_t sys_mode;
  3346. uint8_t connector_status;
  3347. uint8_t isReportStatusReq:1;
  3348. }previousState[3];
  3349. int sockfd;
  3350. struct sockaddr_in info;
  3351. struct hostent *ghbn;
  3352. struct timeval tv;
  3353. uint8_t socketEnable;
  3354. struct Message input;
  3355. struct Message intputBuf;
  3356. struct Message output;
  3357. sprintf((char*)server_addr, "evsocket.phihong.com.tw");
  3358. server_port = 9999;
  3359. if(InitShareMemory() == FAIL)
  3360. {
  3361. DEBUG_ERROR("InitShareMemory NG\n");
  3362. if(ShmStatusCodeData!=NULL)
  3363. {
  3364. ShmStatusCodeData->AlarmCode.AlarmEvents.bits.FailToCreateShareMemory=ON;
  3365. }
  3366. sleep(5);
  3367. return 0;
  3368. }
  3369. RatedCurrentParsing((char*)ShmSysConfigAndInfo->SysConfig.ModelName, &modelnameInfo);
  3370. DEBUG_INFO("Initialize OK!\n");
  3371. for(;;)
  3372. {
  3373. while(!ShmSysConfigAndInfo->SysInfo.InternetConn)
  3374. {
  3375. sleep(1);
  3376. }
  3377. bzero(&info,sizeof(info));
  3378. ghbn = gethostbyname((char*)server_addr);
  3379. info.sin_family = PF_INET;
  3380. info.sin_addr.s_addr = inet_addr(inet_ntoa(*(struct in_addr *)ghbn->h_addr_list[0]));
  3381. info.sin_port = htons(server_port);
  3382. DEBUG_INFO("Connecto to %s:%d\n", inet_ntoa(*(struct in_addr *)ghbn->h_addr_list[0]), server_port);
  3383. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  3384. if (sockfd == -1)
  3385. {
  3386. DEBUG_ERROR("Fail to create a socket.");
  3387. return 0;
  3388. }
  3389. if(connect(sockfd, (struct sockaddr *)&info,sizeof(info)) ==-1)
  3390. {
  3391. DEBUG_ERROR("Connection error");
  3392. }
  3393. else
  3394. {
  3395. DEBUG_INFO("Connect success.\n");
  3396. tv.tv_sec = 0;
  3397. tv.tv_usec = 500000;
  3398. setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
  3399. socketEnable = ON;
  3400. }
  3401. while(socketEnable)
  3402. {
  3403. memset(input.buffer, 0, ARRAY_SIZE(input.buffer));
  3404. if((input.size = recv(sockfd, input.buffer, ARRAY_SIZE(input.buffer), 0)) > 0)
  3405. {
  3406. if(input.size < ARRAY_SIZE(input.buffer))
  3407. {
  3408. //DEBUG_INFO("Receive size: %d.\n", input.size);
  3409. for(uint16_t idx=0;idx<input.size;idx++)
  3410. {
  3411. if((input.buffer[idx] == ((message_header>>8) & 0xff)) && (input.buffer[idx+1] == ((message_header>>0) & 0xff)))
  3412. {
  3413. //DEBUG_INFO("idx: %d\n", idx);
  3414. memset(&intputBuf.buffer[0], 0x00, ARRAY_SIZE(intputBuf.buffer));
  3415. memcpy(&intputBuf.buffer[0], &input.buffer[idx], input.buffer[idx+2] | ((uint16_t)input.buffer[idx+3]<<8));
  3416. intputBuf.size = input.buffer[idx+2] | ((uint16_t)input.buffer[idx+3]<<8);
  3417. idx += (input.buffer[idx+2] | (uint16_t)input.buffer[idx+3]) -1;
  3418. server_cmd_sn = intputBuf.buffer[10] | ((uint16_t)intputBuf.buffer[11]<<8);
  3419. if(!checksum_valid(&intputBuf))
  3420. DEBUG_INFO("Message checksum wrong.\n");
  3421. else
  3422. {
  3423. showCmdRaw(&intputBuf, OFF);
  3424. switch(intputBuf.buffer[6] | ((uint16_t)intputBuf.buffer[7]<<8))
  3425. {
  3426. case 1001:
  3427. handle_cmd_1001(&intputBuf, &output);
  3428. send(sockfd, output.buffer, output.size, 0);
  3429. break;
  3430. case 1003:
  3431. handle_cmd_1003(&intputBuf, &output);
  3432. send(sockfd, output.buffer, output.size, 0);
  3433. break;
  3434. case 1005:
  3435. handle_cmd_1005(&intputBuf, &output);
  3436. send(sockfd, output.buffer, output.size, 0);
  3437. break;
  3438. case 1101:
  3439. handle_cmd_1101(&intputBuf);
  3440. break;
  3441. case 1103:
  3442. handle_cmd_1103(&intputBuf);
  3443. break;
  3444. case 1105:
  3445. handle_cmd_1105(&intputBuf);
  3446. break;
  3447. case 2303:
  3448. handle_cmd_2303(&intputBuf, &output);
  3449. send(sockfd, output.buffer, output.size, 0);
  3450. break;
  3451. case 2305:
  3452. handle_cmd_2305(&intputBuf, &output);
  3453. send(sockfd, output.buffer, output.size, 0);
  3454. break;
  3455. }
  3456. }
  3457. }
  3458. }
  3459. }
  3460. }
  3461. else if(input.size == 0)
  3462. {
  3463. DEBUG_INFO("Disconnected.\n");
  3464. fflush(stdout);
  3465. backend_info.isSignin = OFF;
  3466. socketEnable = OFF;
  3467. }
  3468. else if(input.size == -1)
  3469. {
  3470. // Sign in request
  3471. if(!backend_info.isSignin)
  3472. {
  3473. create_Cmd_1106(&output);
  3474. send(sockfd, output.buffer, output.size, 0);
  3475. }
  3476. // Heart beat request
  3477. if(backend_info.isSignin && (difftime(time((time_t*)NULL), backend_info.st_hearbeat) > backend_info.interval_heartbeat))
  3478. {
  3479. create_Cmd_1102(&output);
  3480. send(sockfd, output.buffer, output.size, 0);
  3481. backend_info.st_hearbeat = time((time_t*)NULL);
  3482. backend_info.counter_heartbeat_retry++;
  3483. }
  3484. // Heart beat retry fail
  3485. if(backend_info.isSignin && (backend_info.counter_heartbeat_retry > backend_info.retry_heartbeat))
  3486. {
  3487. fflush(stdout);
  3488. backend_info.isSignin = OFF;
  3489. socketEnable = OFF;
  3490. DEBUG_ERROR("Heart beat retry over count.\n");
  3491. }
  3492. for(uint8_t gun_index=0;gun_index<modelnameInfo.GetGunCount;gun_index++)
  3493. {
  3494. uint8_t tempIndex;
  3495. switch(modelnameInfo.ParsingInfo[gun_index].GunType)
  3496. {
  3497. case Gun_Type_Chademo:
  3498. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  3499. {
  3500. tempIndex = gun_index;
  3501. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  3502. {
  3503. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  3504. {
  3505. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != previousState[index].connector_status) )
  3506. {
  3507. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  3508. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  3509. previousState[gun_index].isReportStatusReq = ON;
  3510. }
  3511. }
  3512. }
  3513. }
  3514. else
  3515. {
  3516. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  3517. {
  3518. tempIndex = ((gun_index==2) ? 1: 0);
  3519. }
  3520. else
  3521. {
  3522. tempIndex = gun_index;
  3523. }
  3524. for (int index = 0; index < CHAdeMO_QUANTITY; index++)
  3525. {
  3526. if (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].Index == tempIndex)
  3527. {
  3528. if((ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn != previousState[index].connector_status) )
  3529. {
  3530. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].SystemStatus;
  3531. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.ChademoChargingData[index].ConnectorPlugIn;
  3532. previousState[gun_index].isReportStatusReq = ON;
  3533. }
  3534. }
  3535. }
  3536. }
  3537. break;
  3538. case Gun_Type_CCS_2:
  3539. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  3540. {
  3541. tempIndex = gun_index;
  3542. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  3543. {
  3544. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  3545. {
  3546. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != previousState[index].connector_status) )
  3547. {
  3548. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  3549. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  3550. previousState[gun_index].isReportStatusReq = ON;
  3551. }
  3552. }
  3553. }
  3554. }
  3555. else
  3556. {
  3557. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  3558. {
  3559. tempIndex = ((gun_index==2) ? 1: 0);
  3560. }
  3561. else
  3562. {
  3563. tempIndex = gun_index;
  3564. }
  3565. for (int index = 0; index < CCS_QUANTITY; index++)
  3566. {
  3567. if (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].Index == tempIndex)
  3568. {
  3569. if((ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn != previousState[index].connector_status) )
  3570. {
  3571. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].SystemStatus;
  3572. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.CcsChargingData[index].ConnectorPlugIn;
  3573. previousState[gun_index].isReportStatusReq = ON;
  3574. }
  3575. }
  3576. }
  3577. }
  3578. break;
  3579. case Gun_Type_GB:
  3580. if((ShmSysConfigAndInfo->SysConfig.ModelName[0] == 'D') && ((ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'O') || (ShmSysConfigAndInfo->SysConfig.ModelName[1] == 'K')))
  3581. {
  3582. tempIndex = gun_index;
  3583. for (int index = 0; index < GENERAL_GUN_QUANTITY; index++)
  3584. {
  3585. if (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.Index == tempIndex)
  3586. {
  3587. if((ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn != previousState[index].connector_status) )
  3588. {
  3589. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.SystemStatus;
  3590. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.ConnectorInfo[index].GeneralChargingData.ConnectorPlugIn;
  3591. previousState[gun_index].isReportStatusReq = ON;
  3592. }
  3593. }
  3594. }
  3595. }
  3596. else
  3597. {
  3598. if(ShmSysConfigAndInfo->SysConfig.ModelName[8] != '0')
  3599. {
  3600. tempIndex = ((gun_index==2) ? 1: 0);
  3601. }
  3602. else
  3603. {
  3604. tempIndex = gun_index;
  3605. }
  3606. for (int index = 0; index < GB_QUANTITY; index++)
  3607. {
  3608. if (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].Index == tempIndex)
  3609. {
  3610. if((ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn != previousState[index].connector_status) )
  3611. {
  3612. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].SystemStatus;
  3613. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.GbChargingData[index].ConnectorPlugIn;
  3614. previousState[gun_index].isReportStatusReq = ON;
  3615. }
  3616. }
  3617. }
  3618. }
  3619. break;
  3620. case Gun_Type_AC:
  3621. if(ShmSysConfigAndInfo->SysConfig.ModelName[0]=='D')
  3622. {
  3623. tempIndex = 2;
  3624. }
  3625. else
  3626. {
  3627. tempIndex = gun_index;
  3628. }
  3629. for (int index = 0; index < AC_QUANTITY; index++)
  3630. {
  3631. if (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].Index == tempIndex)
  3632. {
  3633. if((ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus != previousState[index].sys_mode) || (ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState != previousState[index].connector_status) )
  3634. {
  3635. previousState[index].sys_mode = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].SystemStatus;
  3636. previousState[index].connector_status = ShmSysConfigAndInfo->SysInfo.AcChargingData[index].PilotState;
  3637. previousState[gun_index].isReportStatusReq = ON;
  3638. }
  3639. }
  3640. }
  3641. break;
  3642. }
  3643. // Send status to backend server
  3644. if(previousState[gun_index].isReportStatusReq || (difftime(time((time_t*)NULL), backend_info.st_status[gun_index]) > backend_info.interval_status))
  3645. {
  3646. create_Cmd_1104(&output, gun_index);
  3647. send(sockfd, output.buffer, output.size, 0);
  3648. previousState[gun_index].isReportStatusReq = OFF;
  3649. backend_info.st_status[gun_index] = time((time_t*)NULL);
  3650. }
  3651. }
  3652. }
  3653. usleep(100000);
  3654. }
  3655. close(sockfd);
  3656. sleep(5);
  3657. }
  3658. return 0;
  3659. }