api.c 185 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051
  1. /*===========================================================================
  2. Combined Charging System (CCS): SECC
  3. api.c
  4. initiated by Joseph
  5. (since 2019/08/07)
  6. =============================================================================*/
  7. #include <netinet/ip.h>
  8. #include <arpa/inet.h>
  9. #include <sys/types.h>
  10. #include <sys/stat.h>
  11. #include <fcntl.h>
  12. #include <linux/termios.h>
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <time.h>
  16. #include <stdlib.h>
  17. #include <sys/ipc.h>
  18. #include <sys/shm.h>
  19. #include <sys/mman.h>
  20. #include <linux/sockios.h>
  21. #include <linux/socket.h>
  22. #include <sys/socket.h>
  23. #include <netinet/in.h>
  24. #include <sys/time.h>
  25. #include <sys/timeb.h>
  26. #include <math.h>//for pow
  27. #include <unistd.h>
  28. #include <linux/if_packet.h>
  29. #include <netinet/if_ether.h>
  30. #include <net/if.h>
  31. #include <netinet/ether.h>
  32. #include <linux/can.h>
  33. #include <linux/can/raw.h>
  34. #include "api.h"
  35. #include "Module_CCS.h"
  36. //#include "../../CsuComm.h"
  37. #include "define_ccs.h"
  38. #include "../codec/EXITypes.h"
  39. /* Activate support for DIN */
  40. #include "../din/dinEXIDatatypes.h"
  41. #if DEPLOY_DIN_CODEC == SUPPORT_YES
  42. #include "../din/dinEXIDatatypesEncoder.h"
  43. #include "../din/dinEXIDatatypesDecoder.h"
  44. #endif /* DEPLOY_DIN_CODEC == SUPPORT_YES */
  45. /* Activate support for XMLDSIG */
  46. #include "../xmldsig/xmldsigEXIDatatypes.h"
  47. #if DEPLOY_XMLDSIG_CODEC == SUPPORT_YES
  48. #include "../xmldsig/xmldsigEXIDatatypesEncoder.h"
  49. #include "../xmldsig/xmldsigEXIDatatypesDecoder.h"
  50. #endif /* DEPLOY_XMLDSIG_CODEC == SUPPORT_YES */
  51. /* Activate support for ISO1 */
  52. #include "../iso1/iso1EXIDatatypes.h"
  53. #if DEPLOY_ISO1_CODEC == SUPPORT_YES
  54. #include "../iso1/iso1EXIDatatypesEncoder.h"
  55. #include "../iso1/iso1EXIDatatypesDecoder.h"
  56. #endif /* DEPLOY_ISO1_CODEC == SUPPORT_YES */
  57. /* Activate support for ISO2 */
  58. #include "../iso2/iso2EXIDatatypes.h"
  59. #if DEPLOY_ISO2_CODEC == SUPPORT_YES
  60. #include "../iso2/iso2EXIDatatypesEncoder.h"
  61. #include "../iso2/iso2EXIDatatypesDecoder.h"
  62. #endif /* DEPLOY_ISO2_CODEC == SUPPORT_YES */
  63. #include "../transport/v2gtp.h"
  64. extern struct SysConfigAndInfo *ShmSysConfigAndInfo;
  65. extern struct StatusCodeData *ShmStatusCodeData;
  66. extern struct CcsData *ShmCcsData;
  67. extern struct InternalComm *ShmInternalComm;
  68. extern struct InternalCommAC *ShmInternalCommAC;
  69. /*Preserve V2GTP Rx and Tx Buffer*/
  70. //unsigned char V2GTP_Rx_buf[V2GTP_MSG_RX_BUFFER_SIZE]; //(64*1024) //65,536 = 65.5KB
  71. unsigned char V2GTP_Tx_buf[V2GTP_MSG_TX_BUFFER_SIZE]; //(64*1024) //65,536 = 65.5KB
  72. bitstream_t iStream; //for V2GTP Message
  73. struct appHandEXIDocument exiDoc; //for decoded V2GTP messages, i.e. EXI DOC (XML)
  74. unsigned char buf_log_exi_api[256];
  75. /**
  76. *
  77. * @param fmt
  78. * @return
  79. */
  80. int StoreLogV2GMsg(const char *fmt, ...)
  81. {
  82. char Buf[4096+256];
  83. char buffer[4096];
  84. time_t CurrentTime;
  85. struct tm *tm;
  86. struct timeval tv;
  87. va_list args;
  88. va_start(args, fmt);
  89. int rc = vsnprintf(buffer, sizeof(buffer), fmt, args);
  90. va_end(args);
  91. memset(Buf,0,sizeof(Buf));
  92. CurrentTime = time(NULL);
  93. tm=localtime(&CurrentTime);
  94. gettimeofday(&tv, NULL); // get microseconds, 10^-6
  95. sprintf(Buf,"echo -n \"[%04d.%02d.%02d %02d:%02d:%02d.%06ld]%s\" >> /Storage/SystemLog/[%04d.%02d]CCS_V2G",
  96. tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec,tv.tv_usec,
  97. buffer,
  98. tm->tm_year+1900,tm->tm_mon+1);
  99. system((const char*)Buf);
  100. return rc;
  101. }
  102. /*===========================================================================
  103. FUNCTION: printASCIIString
  104. DESCRIPTION:
  105. PRE-CONDITION:
  106. INPUT:
  107. 1. exi_doc_DIN
  108. OUTPUT:
  109. GLOBAL VARIABLES:
  110. =============================================================================*/
  111. static void printASCIIString(exi_string_character_t* string, uint16_t len)
  112. {
  113. unsigned int i = 0;
  114. unsigned char buffer[1024]={0};
  115. for(i = 0; i < len; i++)
  116. {
  117. sprintf((char*)buffer, "%s%c ", buffer, (char)string[i]);
  118. }
  119. DEBUG_PRINTF_EXI_ENGINE_DETAIL("%s\n", buffer);
  120. }
  121. /*===========================================================================
  122. FUNCTION: writeStringToEXIString
  123. DESCRIPTION:
  124. PRE-CONDITION:
  125. INPUT:
  126. 1. exi_doc_DIN
  127. OUTPUT:
  128. GLOBAL VARIABLES:
  129. =============================================================================*/
  130. /*
  131. static int writeStringToEXIString(char* string, exi_string_character_t* exiString)
  132. {
  133. int pos = 0;
  134. while(string[pos]!='\0')
  135. {
  136. exiString[pos] = string[pos];
  137. pos++;
  138. }
  139. return pos;
  140. }*/
  141. /*===========================================================================
  142. FUNCTION: PRINT_V2GTP_MSG_RX_REQUEST_NAME_DIN
  143. DESCRIPTION:
  144. PRE-CONDITION:
  145. INPUT:
  146. 1. exi_doc_DIN
  147. OUTPUT:
  148. GLOBAL VARIABLES:
  149. =============================================================================*/
  150. int Check_V2G_Rx_Msg_Name_din(struct dinEXIDocument *exi_doc_DIN)
  151. {
  152. int errn = 0;
  153. //Session Setup (0a ⇄ 0b)
  154. if (exi_doc_DIN->V2G_Message.Body.SessionSetupReq_isUsed == 1u)
  155. {
  156. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionSetupReq_isUsed: YES (0a , 0b)\n");
  157. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionSetupRequest;
  158. }
  159. //Service Discovery (1a ⇄ 1b)
  160. else if (exi_doc_DIN->V2G_Message.Body.ServiceDiscoveryReq_isUsed == 1u)
  161. {
  162. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceDiscoveryReq_isUsed: YES (1a , 1b)\n");
  163. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceDiscoveryRequest;
  164. }
  165. //Service Payment Selection (2a ⇄ 2b)
  166. else if (exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq_isUsed == 1u)
  167. {
  168. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServicePaymentSelectionReq_isUsed: YES (2a , 2b)\n");
  169. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceAndPaymentSelectionRequest;
  170. }
  171. //Contract Contract Authentication (Xa ⇄ Xb)
  172. else if (exi_doc_DIN->V2G_Message.Body.ContractAuthenticationReq_isUsed == 1u)
  173. {
  174. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ContractAuthenticationReq_isUsed: YES (Xa , Xb)\n");
  175. EVCOMM_SYS_INFO.V2G_Rx_Msg = AuthorizationRequest;
  176. }
  177. //Charge Parameter Discovery (3a ⇄ 3b)
  178. else if (exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq_isUsed == 1u)
  179. {
  180. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeParameterDiscoveryReq_isUsed: YES (3a , 3b)\n");
  181. EVCOMM_SYS_INFO.V2G_Rx_Msg = ChargeParameterDiscoveryRequest;
  182. }
  183. //Cable Check (4a ⇄ 4b)
  184. else if (exi_doc_DIN->V2G_Message.Body.CableCheckReq_isUsed == 1u)
  185. {
  186. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CableCheckReq_isUsed: YES (4a , 4b)\n");
  187. EVCOMM_SYS_INFO.V2G_Rx_Msg = CableCheckRequest;
  188. }
  189. //Precharge (5a ⇄ 5b)
  190. else if (exi_doc_DIN->V2G_Message.Body.PreChargeReq_isUsed == 1u)
  191. {
  192. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PreChargeReq_isUsed: YES (5a , 5b)\n");
  193. EVCOMM_SYS_INFO.V2G_Rx_Msg = PreChargeRequest;
  194. }
  195. //Power Delivery (6a ⇄ 6b)
  196. else if (exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq_isUsed == 1u)
  197. {
  198. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PowerDeliveryReq_isUsed: YES (6a , 6b)\n");
  199. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre == PreChargeRequest)
  200. {
  201. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStart;
  202. }
  203. else
  204. {
  205. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStop;
  206. }
  207. }
  208. //Current Demand (7a ⇄ 7b)
  209. else if (exi_doc_DIN->V2G_Message.Body.CurrentDemandReq_isUsed == 1u)
  210. {
  211. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CurrentDemandReq_isUsed: YES (7a , 7b)\n");
  212. EVCOMM_SYS_INFO.V2G_Rx_Msg = CurrentDemandRequest;
  213. }
  214. //Welding Detection (9a ⇄ 9b)
  215. else if (exi_doc_DIN->V2G_Message.Body.WeldingDetectionReq_isUsed == 1u)
  216. {
  217. DEBUG_PRINTF_EXI_ENGINE_DETAIL("WeldingDetectionReq_isUsed: YES (9a ,9b)\n");
  218. EVCOMM_SYS_INFO.V2G_Rx_Msg = WeldingDetectionRequest;
  219. }
  220. //Session Stop (10a ⇄ 10b)
  221. else if (exi_doc_DIN->V2G_Message.Body.SessionStopReq_isUsed == 1u)
  222. {
  223. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionStopReq_isUsed: YES (10a , 10b)\n");
  224. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionStopRequest;
  225. }
  226. else
  227. {
  228. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] unidentified V2G_Rx_Msg\n");
  229. errn = -1;
  230. }
  231. //Compare with the previous Message
  232. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre != EVCOMM_SYS_INFO.V2G_Rx_Msg)
  233. {
  234. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[V2G_RX_MSG]%d >> %d\n",
  235. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre,
  236. EVCOMM_SYS_INFO.V2G_Rx_Msg);
  237. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre = EVCOMM_SYS_INFO.V2G_Rx_Msg;
  238. }
  239. return errn;
  240. }
  241. /*===========================================================================
  242. FUNCTION: PRINT_V2GTP_MSG_RX_REQUEST_NAME_ISO1
  243. DESCRIPTION:
  244. PRE-CONDITION:
  245. INPUT:
  246. 1. exi_doc_ISO1
  247. OUTPUT:
  248. GLOBAL VARIABLES:
  249. =============================================================================*/
  250. int Check_V2G_Rx_Msg_Name_iso1(struct iso1EXIDocument *exi_doc_ISO1)
  251. {
  252. int errn = 0;
  253. //Session Setup (0a ⇄ 0b)
  254. if (exi_doc_ISO1->V2G_Message.Body.SessionSetupReq_isUsed == 1u)
  255. {
  256. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionSetupReq_isUsed: YES (0a , 0b)\n");
  257. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionSetupRequest;
  258. }
  259. //Service Discovery (1a ⇄ 1b)
  260. else if (exi_doc_ISO1->V2G_Message.Body.ServiceDiscoveryReq_isUsed == 1u)
  261. {
  262. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceDiscoveryReq_isUsed: YES (1a , 1b)\n");
  263. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceDiscoveryRequest;
  264. }
  265. //Service Detail
  266. else if (exi_doc_ISO1->V2G_Message.Body.ServiceDetailReq_isUsed == 1u)
  267. {
  268. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceDetailReq_isUsed: YES\n");
  269. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceDetailRequest;
  270. }
  271. //Payment Service Selection (2a ⇄ 2b)
  272. else if (exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq_isUsed == 1u)
  273. {
  274. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PaymentServiceSelectionReq_isUsed: YES (2a , 2b)\n");
  275. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceAndPaymentSelectionRequest;
  276. }
  277. //Payment Details
  278. else if (exi_doc_ISO1->V2G_Message.Body.PaymentDetailsReq_isUsed == 1u)
  279. {
  280. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PaymentDetailsReq_isUsed: YES\n");
  281. EVCOMM_SYS_INFO.V2G_Rx_Msg = PaymentDetailsRequest;
  282. }
  283. //Authorization (Xa ⇄ Xb)
  284. else if (exi_doc_ISO1->V2G_Message.Body.AuthorizationReq_isUsed == 1u)
  285. {
  286. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AuthorizationReq_isUsed: YES (Xa , Xb)\n");
  287. EVCOMM_SYS_INFO.V2G_Rx_Msg = AuthorizationRequest;
  288. }
  289. //Certificate Update
  290. else if (exi_doc_ISO1->V2G_Message.Body.CertificateUpdateReq_isUsed == 1u)
  291. {
  292. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CertificateUpdateReq_isUsed: YES\n");
  293. EVCOMM_SYS_INFO.V2G_Rx_Msg = CertificateUpdateRequest;
  294. }
  295. //Certificate Installation
  296. else if (exi_doc_ISO1->V2G_Message.Body.CertificateInstallationReq_isUsed == 1u)
  297. {
  298. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CertificateInstallationReq_isUsed: YES\n");
  299. EVCOMM_SYS_INFO.V2G_Rx_Msg = CertificateInstallationRequest;
  300. }
  301. //Charge Parameter Discovery (3a ⇄ 3b)
  302. else if (exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq_isUsed == 1u)
  303. {
  304. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeParameterDiscoveryReq_isUsed: YES (3a , 3b)\n");
  305. EVCOMM_SYS_INFO.V2G_Rx_Msg = ChargeParameterDiscoveryRequest;
  306. }
  307. //Cable Check (4a ⇄ 4b)
  308. else if (exi_doc_ISO1->V2G_Message.Body.CableCheckReq_isUsed == 1u)
  309. {
  310. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CableCheckReq_isUsed: YES (4a , 4b)\n");
  311. EVCOMM_SYS_INFO.V2G_Rx_Msg = CableCheckRequest;
  312. }
  313. //Precharge (5a ⇄ 5b)
  314. else if (exi_doc_ISO1->V2G_Message.Body.PreChargeReq_isUsed == 1u)
  315. {
  316. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PreChargeReq_isUsed: YES (5a , 5b)\n");
  317. EVCOMM_SYS_INFO.V2G_Rx_Msg = PreChargeRequest;
  318. }
  319. //Power Delivery (6a ⇄ 6b)
  320. else if (exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq_isUsed == 1u)
  321. {
  322. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PowerDeliveryReq_isUsed: YES (6a , 6b)\n");
  323. //For DC
  324. if (CCS_ENERGY_TRANSFER_MODE == MODE_DC_EXTENDED)
  325. {
  326. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre == PreChargeRequest)
  327. {
  328. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStart;
  329. }
  330. else
  331. {
  332. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStop;
  333. }
  334. }
  335. //For AC
  336. else if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) || (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
  337. {
  338. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre == ChargeParameterDiscoveryRequest)
  339. {
  340. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStart;
  341. }
  342. else
  343. {
  344. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStop;
  345. }
  346. }
  347. else
  348. {
  349. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] unexpected CCS_ENERGY_TRANSFER_MODE(%d)\n", CCS_ENERGY_TRANSFER_MODE);
  350. errn = -2;
  351. }
  352. }
  353. //Current Demand (7a ⇄ 7b)
  354. else if (exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq_isUsed == 1u)
  355. {
  356. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CurrentDemandReq_isUsed: YES (7a , 7b)\n");
  357. EVCOMM_SYS_INFO.V2G_Rx_Msg = CurrentDemandRequest;
  358. }
  359. //Charging Status
  360. else if (exi_doc_ISO1->V2G_Message.Body.ChargingStatusReq_isUsed == 1u)
  361. {
  362. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingStatusReq_isUsed: YES (7a , 7b)\n");
  363. EVCOMM_SYS_INFO.V2G_Rx_Msg = ChargingStatusRequest;
  364. }
  365. //Metering Receipt
  366. else if (exi_doc_ISO1->V2G_Message.Body.MeteringReceiptReq_isUsed == 1u)
  367. {
  368. DEBUG_PRINTF_EXI_ENGINE_DETAIL("MeteringReceiptReq_isUsed: YES\n");
  369. EVCOMM_SYS_INFO.V2G_Rx_Msg = MeteringReceiptRequest;
  370. }
  371. //Welding Detection (9a ⇄ 9b)
  372. else if (exi_doc_ISO1->V2G_Message.Body.WeldingDetectionReq_isUsed == 1u)
  373. {
  374. DEBUG_PRINTF_EXI_ENGINE_DETAIL("WeldingDetectionReq_isUsed: YES (9a , 9b)\n");
  375. EVCOMM_SYS_INFO.V2G_Rx_Msg = WeldingDetectionRequest;
  376. }
  377. //Session Stop (10a ⇄ 10b)
  378. else if (exi_doc_ISO1->V2G_Message.Body.SessionStopReq_isUsed == 1u)
  379. {
  380. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionStopReq_isUsed: YES (10a , 10b)\n");
  381. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionStopRequest;
  382. }
  383. else
  384. {
  385. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] unidentified V2G_Rx_Msg\n");
  386. errn = -1;
  387. }
  388. //Compare with the previous Message
  389. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre != EVCOMM_SYS_INFO.V2G_Rx_Msg)
  390. {
  391. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[V2G_RX_MSG]%d >> %d\n",
  392. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre,
  393. EVCOMM_SYS_INFO.V2G_Rx_Msg);
  394. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre = EVCOMM_SYS_INFO.V2G_Rx_Msg;
  395. }
  396. return errn;
  397. }
  398. /*===========================================================================
  399. FUNCTION: PRINT_V2GTP_MSG_RX_REQUEST_NAME_ISO2
  400. DESCRIPTION:
  401. PRE-CONDITION:
  402. INPUT:
  403. 1. exi_doc_ISO2
  404. OUTPUT:
  405. GLOBAL VARIABLES:
  406. =============================================================================*/
  407. int Check_V2G_Rx_Msg_Name_iso2(struct iso2EXIDocument *exi_doc_ISO2)
  408. {
  409. int errn = 0;
  410. //V2GRequest_isUsed
  411. if (exi_doc_ISO2->V2G_Message.Body.V2GRequest_isUsed == 1u)
  412. {
  413. DEBUG_PRINTF_EXI_ENGINE_DETAIL("V2GRequest_isUsed: YES\n");
  414. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  415. }
  416. //DisconnectChargingDeviceReq_isUsed
  417. else if (exi_doc_ISO2->V2G_Message.Body.DisconnectChargingDeviceReq_isUsed == 1u)
  418. {
  419. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DisconnectChargingDeviceReq_isUsed: YES\n");
  420. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  421. }
  422. //ConnectChargingDeviceReq_isUsed
  423. else if (exi_doc_ISO2->V2G_Message.Body.ConnectChargingDeviceReq_isUsed == 1u)
  424. {
  425. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ConnectChargingDeviceReq_isUsed: YES\n");
  426. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  427. }
  428. //SystemStatusReq_isUsed
  429. else if (exi_doc_ISO2->V2G_Message.Body.SystemStatusReq_isUsed == 1u)
  430. {
  431. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SystemStatusReq_isUsed: YES\n");
  432. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  433. }
  434. //DC_BidirectionalControlReq_isUsed
  435. else if (exi_doc_ISO2->V2G_Message.Body.DC_BidirectionalControlReq_isUsed == 1u)
  436. {
  437. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_BidirectionalControlReq_isUsed: YES\n");
  438. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  439. }
  440. //AC_BidirectionalControlReq_isUsed
  441. else if (exi_doc_ISO2->V2G_Message.Body.AC_BidirectionalControlReq_isUsed == 1u)
  442. {
  443. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AC_BidirectionalControlReq_isUsed: YES\n");
  444. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  445. }
  446. //VehicleCheckOutReq_isUsed
  447. else if (exi_doc_ISO2->V2G_Message.Body.VehicleCheckOutReq_isUsed == 1u)
  448. {
  449. DEBUG_PRINTF_EXI_ENGINE_DETAIL("VehicleCheckOutReq_isUsed: YES\n");
  450. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  451. }
  452. //VehicleCheckInReq_isUsed
  453. else if (exi_doc_ISO2->V2G_Message.Body.VehicleCheckInReq_isUsed == 1u)
  454. {
  455. DEBUG_PRINTF_EXI_ENGINE_DETAIL("VehicleCheckInReq_isUsed: YES\n");
  456. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  457. }
  458. //PowerDemandReq_isUsed
  459. else if (exi_doc_ISO2->V2G_Message.Body.PowerDemandReq_isUsed == 1u)
  460. {
  461. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PowerDemandReq_isUsed: YES\n");
  462. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  463. }
  464. //PairingReq_isUsed
  465. else if (exi_doc_ISO2->V2G_Message.Body.PairingReq_isUsed == 1u)
  466. {
  467. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PairingReq_isUsed: YES\n");
  468. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  469. }
  470. //AlignmentCheckReq_isUsed
  471. else if (exi_doc_ISO2->V2G_Message.Body.AlignmentCheckReq_isUsed == 1u)
  472. {
  473. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AlignmentCheckReq_isUsed: YES\n");
  474. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  475. }
  476. //FinePositioningReq_isUsed
  477. else if (exi_doc_ISO2->V2G_Message.Body.FinePositioningReq_isUsed == 1u)
  478. {
  479. DEBUG_PRINTF_EXI_ENGINE_DETAIL("FinePositioningReq_isUsed: YES\n");
  480. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  481. }
  482. //FinePositioningSetupReq_isUsed
  483. else if (exi_doc_ISO2->V2G_Message.Body.FinePositioningSetupReq_isUsed == 1u)
  484. {
  485. DEBUG_PRINTF_EXI_ENGINE_DETAIL("FinePositioningSetupReq_isUsed: YES\n");
  486. //EVCOMM_SYS_INFO.V2G_Rx_Msg = ;
  487. }
  488. //Session Setup (0a ⇄ 0b)
  489. else if (exi_doc_ISO2->V2G_Message.Body.SessionSetupReq_isUsed == 1u)
  490. {
  491. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionSetupReq_isUsed: YES (0a , 0b)\n");
  492. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionSetupRequest;
  493. }
  494. //Service Discovery (1a ⇄ 1b)
  495. else if (exi_doc_ISO2->V2G_Message.Body.ServiceDiscoveryReq_isUsed == 1u)
  496. {
  497. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceDiscoveryReq_isUsed: YES (1a , 1b)\n");
  498. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceDiscoveryRequest;
  499. }
  500. //Service Detail
  501. else if (exi_doc_ISO2->V2G_Message.Body.ServiceDetailReq_isUsed == 1u)
  502. {
  503. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceDetailReq_isUsed: YES\n");
  504. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceDetailRequest;
  505. }
  506. //Payment Service Selection (2a ⇄ 2b)
  507. else if (exi_doc_ISO2->V2G_Message.Body.PaymentServiceSelectionReq_isUsed == 1u)
  508. {
  509. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PaymentServiceSelectionReq_isUsed: YES (2a , 2b)\n");
  510. EVCOMM_SYS_INFO.V2G_Rx_Msg = ServiceAndPaymentSelectionRequest;
  511. }
  512. //Payment Details
  513. else if (exi_doc_ISO2->V2G_Message.Body.PaymentDetailsReq_isUsed == 1u)
  514. {
  515. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PaymentDetailsReq_isUsed: YES\n");
  516. EVCOMM_SYS_INFO.V2G_Rx_Msg = PaymentDetailsRequest;
  517. }
  518. //Authorization (Xa ⇄ Xb)
  519. else if (exi_doc_ISO2->V2G_Message.Body.AuthorizationReq_isUsed == 1u)
  520. {
  521. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AuthorizationReq_isUsed: YES (Xa , Xb)\n");
  522. EVCOMM_SYS_INFO.V2G_Rx_Msg = AuthorizationRequest;
  523. }
  524. //Certificate Update
  525. else if (exi_doc_ISO2->V2G_Message.Body.CertificateUpdateReq_isUsed == 1u)
  526. {
  527. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CertificateUpdateReq_isUsed: YES\n");
  528. EVCOMM_SYS_INFO.V2G_Rx_Msg = CertificateUpdateRequest;
  529. }
  530. //Certificate Installation
  531. else if (exi_doc_ISO2->V2G_Message.Body.CertificateInstallationReq_isUsed == 1u)
  532. {
  533. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CertificateInstallationReq_isUsed: YES\n");
  534. EVCOMM_SYS_INFO.V2G_Rx_Msg = CertificateInstallationRequest;
  535. }
  536. //Charge Parameter Discovery (3a ⇄ 3b)
  537. else if (exi_doc_ISO2->V2G_Message.Body.ChargeParameterDiscoveryReq_isUsed == 1u)
  538. {
  539. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeParameterDiscoveryReq_isUsed: YES (3a , 3b)\n");
  540. EVCOMM_SYS_INFO.V2G_Rx_Msg = ChargeParameterDiscoveryRequest;
  541. }
  542. //Cable Check (4a ⇄ 4b)
  543. else if (exi_doc_ISO2->V2G_Message.Body.CableCheckReq_isUsed == 1u)
  544. {
  545. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CableCheckReq_isUsed: YES (4a , 4b)\n");
  546. EVCOMM_SYS_INFO.V2G_Rx_Msg = CableCheckRequest;
  547. }
  548. //Precharge (5a ⇄ 5b)
  549. else if (exi_doc_ISO2->V2G_Message.Body.PreChargeReq_isUsed == 1u)
  550. {
  551. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PreChargeReq_isUsed: YES (5a , 5b)\n");
  552. EVCOMM_SYS_INFO.V2G_Rx_Msg = PreChargeRequest;
  553. }
  554. //Power Delivery (6a ⇄ 6b)
  555. else if (exi_doc_ISO2->V2G_Message.Body.PowerDeliveryReq_isUsed == 1u)
  556. {
  557. DEBUG_PRINTF_EXI_ENGINE_DETAIL("PowerDeliveryReq_isUsed: YES (6a , 6b)\n");
  558. //For DC
  559. if (CCS_ENERGY_TRANSFER_MODE == MODE_DC_EXTENDED)
  560. {
  561. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre == PreChargeRequest)
  562. {
  563. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStart;
  564. }
  565. else
  566. {
  567. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStop;
  568. }
  569. }
  570. //For AC
  571. else if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) || (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
  572. {
  573. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre == ChargeParameterDiscoveryRequest)
  574. {
  575. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStart;
  576. }
  577. else
  578. {
  579. EVCOMM_SYS_INFO.V2G_Rx_Msg = PowerDeliveryRequestStop;
  580. }
  581. }
  582. else
  583. {
  584. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] unexpected CCS_ENERGY_TRANSFER_MODE(%d)\n", CCS_ENERGY_TRANSFER_MODE);
  585. errn = -2;
  586. }
  587. }
  588. //Current Demand (7a ⇄ 7b)
  589. else if (exi_doc_ISO2->V2G_Message.Body.CurrentDemandReq_isUsed == 1u)
  590. {
  591. DEBUG_PRINTF_EXI_ENGINE_DETAIL("CurrentDemandReq_isUsed: YES (7a , 7b)\n");
  592. EVCOMM_SYS_INFO.V2G_Rx_Msg = CurrentDemandRequest;
  593. }
  594. //Charging Status
  595. else if (exi_doc_ISO2->V2G_Message.Body.ChargingStatusReq_isUsed == 1u)
  596. {
  597. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingStatusReq_isUsed: YES (7a ,7b)\n");
  598. EVCOMM_SYS_INFO.V2G_Rx_Msg = ChargingStatusRequest;
  599. }
  600. //Metering Receipt
  601. else if (exi_doc_ISO2->V2G_Message.Body.MeteringReceiptReq_isUsed == 1u)
  602. {
  603. DEBUG_PRINTF_EXI_ENGINE_DETAIL("MeteringReceiptReq_isUsed: YES\n");
  604. EVCOMM_SYS_INFO.V2G_Rx_Msg = MeteringReceiptRequest;
  605. }
  606. //Welding Detection (9a ⇄ 9b)
  607. else if (exi_doc_ISO2->V2G_Message.Body.WeldingDetectionReq_isUsed == 1u)
  608. {
  609. DEBUG_PRINTF_EXI_ENGINE_DETAIL("WeldingDetectionReq_isUsed: YES (9a , 9b)\n");
  610. EVCOMM_SYS_INFO.V2G_Rx_Msg = WeldingDetectionRequest;
  611. }
  612. //Session Stop (10a ⇄ 10b)
  613. else if (exi_doc_ISO2->V2G_Message.Body.SessionStopReq_isUsed == 1u)
  614. {
  615. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionStopReq_isUsed: YES (10a , 10b)\n");
  616. EVCOMM_SYS_INFO.V2G_Rx_Msg = SessionStopRequest;
  617. }
  618. else
  619. {
  620. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] unidentified V2G_Rx_Msg\n");
  621. errn = -1;
  622. }
  623. //Compare with the previous Message
  624. if (EVCOMM_SYS_INFO.V2G_Rx_Msg_pre != EVCOMM_SYS_INFO.V2G_Rx_Msg)
  625. {
  626. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[V2G_RX_MSG]%d >> %d\n",
  627. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre,
  628. EVCOMM_SYS_INFO.V2G_Rx_Msg);
  629. EVCOMM_SYS_INFO.V2G_Rx_Msg_pre = EVCOMM_SYS_INFO.V2G_Rx_Msg;
  630. }
  631. return errn;
  632. }
  633. /*===========================================================================
  634. FUNCTION: SAVE_PhysicalValueType_DIN70121
  635. DESCRIPTION:
  636. PRE-CONDITION:
  637. INPUT:
  638. OUTPUT:
  639. GLOBAL VARIABLES:
  640. =============================================================================*/
  641. void SAVE_PhysicalValueType_DIN70121(struct PhysicalValueType_DIN70121 *out, int in_value, unsigned char unit)
  642. {
  643. out->Value = in_value;
  644. out->Unit = unit;
  645. switch (unit)
  646. {
  647. case H_DIN70121:
  648. case M_DIN70121:
  649. case S_DIN70121:
  650. case A_DIN70121:
  651. case V_DIN70121:
  652. case AH_DIN70121:
  653. case VA_DIN70121:
  654. out->Multiplier = -1;
  655. break; //KW
  656. case W_DIN70121:
  657. case WH_DIN70121:
  658. out->Value = in_value * 10;
  659. out->Multiplier = 1;
  660. break; //KWh
  661. }
  662. //H_DIN70121 = 0,
  663. //M_DIN70121 = 1,
  664. //S_DIN70121 = 2,
  665. //A_DIN70121 = 3,
  666. //AH_DIN70121 = 4,
  667. //V_DIN70121 = 5,
  668. //VA_DIN70121 = 6,
  669. //W_DIN70121 = 7,
  670. //WS_DIN70121 = 8,
  671. //WH_DIN70121 = 9};
  672. }
  673. /*===========================================================================
  674. FUNCTION: SAVE_PhysicalValueType_ISO15118_2014
  675. DESCRIPTION:
  676. PRE-CONDITION:
  677. INPUT:
  678. OUTPUT:
  679. GLOBAL VARIABLES:
  680. =============================================================================*/
  681. void SAVE_PhysicalValueType_ISO15118_2014(struct PhysicalValueType_ISO15118_2014 *out, int in_value, unsigned char unit)
  682. {
  683. out->Value = in_value;
  684. out->Unit = unit;
  685. switch (unit)
  686. {
  687. case h_ISO15118_2014:
  688. case m_ISO15118_2014:
  689. case s_ISO15118_2014:
  690. case A_ISO15118_2014:
  691. case V_ISO15118_2014:
  692. out->Multiplier = -1;
  693. break; //KW
  694. case W_ISO15118_2014:
  695. case Wh_ISO15118_2014:
  696. out->Value = in_value * 10;
  697. out->Multiplier = 1;
  698. break; //KWh
  699. }
  700. //H_DIN70121 = 0,
  701. //M_DIN70121 = 1,
  702. //S_DIN70121 = 2,
  703. //A_DIN70121 = 3,
  704. //AH_DIN70121 = 4,
  705. //V_DIN70121 = 5,
  706. //VA_DIN70121 = 6,
  707. //W_DIN70121 = 7,
  708. //WS_DIN70121 = 8,
  709. //WH_DIN70121 = 9};
  710. }
  711. /*===========================================================================
  712. FUNCTION: DIN70121PhyValDecode
  713. DESCRIPTION:
  714. Output Unit: 1V, 1A, 1S, etc.
  715. PRE-CONDITION:
  716. INPUT:
  717. OUTPUT:
  718. GLOBAL VARIABLES:
  719. =============================================================================*/
  720. float DIN70121PhyValDecode(struct PhysicalValueType_DIN70121 PhysicalData)
  721. {
  722. short DataValue;
  723. int DataMultiplier;
  724. float Rtn;
  725. DataValue = PhysicalData.Value;
  726. DataMultiplier = PhysicalData.Multiplier;
  727. switch(PhysicalData.Unit)
  728. {
  729. case H_DIN70121:
  730. Rtn = (DataValue * pow(10, DataMultiplier) * 60 * 60);
  731. return Rtn;
  732. case M_DIN70121:
  733. Rtn = (DataValue * pow(10, DataMultiplier) * 60);
  734. return Rtn;
  735. case S_DIN70121:
  736. case A_DIN70121:
  737. case V_DIN70121:
  738. Rtn = (DataValue * pow(10, DataMultiplier));
  739. return Rtn; //S, A, V
  740. case AH_DIN70121:
  741. Rtn = (DataValue * pow(10, DataMultiplier));
  742. return Rtn;
  743. case VA_DIN70121:
  744. case W_DIN70121:
  745. Rtn = (DataValue * pow(10, DataMultiplier)) / 1000;
  746. return Rtn; //kW
  747. case WS_DIN70121:
  748. Rtn = (DataValue * pow(10, DataMultiplier)) / 1000; //[Joseph] TBD
  749. return Rtn;
  750. case WH_DIN70121:
  751. Rtn = (DataValue * pow(10, DataMultiplier)) / 1000;
  752. return Rtn; //kWh
  753. }
  754. return 0;
  755. }
  756. /*===========================================================================
  757. FUNCTION: ISO151182014PhyValDecode
  758. DESCRIPTION:
  759. PRE-CONDITION:
  760. INPUT:
  761. OUTPUT:
  762. GLOBAL VARIABLES:
  763. =============================================================================*/
  764. float ISO151182014PhyValDecode(struct PhysicalValueType_ISO15118_2014 PhysicalData)
  765. {
  766. short DataValue;
  767. int DataMultiplier;
  768. float Rtn;
  769. DataValue = PhysicalData.Value;
  770. DataMultiplier = PhysicalData.Multiplier;
  771. switch(PhysicalData.Unit)
  772. {
  773. case h_ISO15118_2014:
  774. Rtn = (DataValue * pow(10, DataMultiplier) * 60 * 60);
  775. return Rtn;
  776. case m_ISO15118_2014:
  777. Rtn = (DataValue * pow(10, DataMultiplier) * 60);
  778. return Rtn;
  779. case s_ISO15118_2014:
  780. case A_ISO15118_2014:
  781. case V_ISO15118_2014:
  782. Rtn = (DataValue * pow(10, DataMultiplier));
  783. return Rtn;
  784. case W_ISO15118_2014:
  785. Rtn = (DataValue * pow(10, DataMultiplier)) / 1000;
  786. return Rtn; //kW
  787. case Wh_ISO15118_2014:
  788. Rtn = (DataValue * pow(10, DataMultiplier)) / 1000;
  789. return Rtn; //kWh
  790. }
  791. return 0;
  792. }
  793. /*===========================================================================
  794. FUNCTION: SHM_Read_dinPhysicalValueType
  795. DESCRIPTION:
  796. PRE-CONDITION:
  797. INPUT:
  798. 1. in
  799. OUTPUT:
  800. 2. out
  801. GLOBAL VARIABLES:
  802. =============================================================================*/
  803. void SHM_Read_dinPhysicalValueType(struct dinPhysicalValueType *out, struct PhysicalValueType_DIN70121 *in)
  804. {
  805. out->Value = (short) in->Value;
  806. out->Multiplier = (char) in->Multiplier;
  807. out->Unit_isUsed = 1u; //[CAUTION] Remember to put Uinit, since here we set it as 1 as default.
  808. out->Unit = (unsigned char) in->Unit;
  809. // dinunitSymbolType_h = 0,
  810. // dinunitSymbolType_m = 1,
  811. // dinunitSymbolType_s = 2,
  812. // dinunitSymbolType_A = 3,
  813. // dinunitSymbolType_Ah = 4,
  814. // dinunitSymbolType_V = 5,
  815. // dinunitSymbolType_VA = 6,
  816. // dinunitSymbolType_W = 7,
  817. // dinunitSymbolType_W_s = 8,
  818. // dinunitSymbolType_Wh = 9
  819. }
  820. /*===========================================================================
  821. FUNCTION: SHM_Read_iso1PhysicalValueType
  822. DESCRIPTION:
  823. PRE-CONDITION:
  824. INPUT:
  825. 1. in
  826. OUTPUT:
  827. 2. out
  828. GLOBAL VARIABLES:
  829. =============================================================================*/
  830. void SHM_Read_iso1PhysicalValueType(struct iso1PhysicalValueType *out, struct PhysicalValueType_ISO15118_2014 *in)
  831. {
  832. out->Value = (short) in->Value;
  833. out->Multiplier = (char) in->Multiplier;
  834. //out->Unit_isUsed = 1u; //[CAUTION] Remember to put Uinit, since here we set it as 1 as default.
  835. out->Unit = (unsigned char) in->Unit;
  836. //iso1unitSymbolType_h = 0,
  837. //iso1unitSymbolType_m = 1,
  838. //iso1unitSymbolType_s = 2,
  839. //iso1unitSymbolType_A = 3,
  840. //iso1unitSymbolType_V = 4,
  841. //iso1unitSymbolType_W = 5,
  842. //iso1unitSymbolType_Wh = 6
  843. }
  844. /*===========================================================================
  845. FUNCTION: SHM_Read_dinDC_EVSEStatusType
  846. DESCRIPTION:
  847. PRE-CONDITION:
  848. INPUT:
  849. 1. in
  850. OUTPUT:
  851. 2. out
  852. GLOBAL VARIABLES:
  853. =============================================================================*/
  854. void SHM_Read_dinDC_EVSEStatusType(struct dinDC_EVSEStatusType *out, struct DC_EVSEStatusType_DIN70121 *in)
  855. {
  856. out->EVSEIsolationStatus_isUsed = 1u;
  857. out->EVSEIsolationStatus = (unsigned char) in->EVSEIsolationStatus;
  858. // dinisolationLevelType_Invalid = 0, (default)
  859. // dinisolationLevelType_Valid = 1,
  860. // dinisolationLevelType_Warning = 2,
  861. // dinisolationLevelType_Fault = 3
  862. out->EVSEStatusCode = (unsigned char) in->EVSEStatusCode;
  863. // dinDC_EVSEStatusCodeType_EVSE_NotReady = 0,
  864. // dinDC_EVSEStatusCodeType_EVSE_Ready = 1, (default)
  865. // dinDC_EVSEStatusCodeType_EVSE_Shutdown = 2,
  866. // dinDC_EVSEStatusCodeType_EVSE_UtilityInterruptEvent = 3,
  867. // dinDC_EVSEStatusCodeType_EVSE_IsolationMonitoringActive = 4,
  868. // dinDC_EVSEStatusCodeType_EVSE_EmergencyShutdown = 5,
  869. // dinDC_EVSEStatusCodeType_EVSE_Malfunction = 6,
  870. // dinDC_EVSEStatusCodeType_Reserved_8 = 7,
  871. // dinDC_EVSEStatusCodeType_Reserved_9 = 8,
  872. // dinDC_EVSEStatusCodeType_Reserved_A = 9,
  873. // dinDC_EVSEStatusCodeType_Reserved_B = 10,
  874. // dinDC_EVSEStatusCodeType_Reserved_C = 11
  875. out->NotificationMaxDelay = 0u;
  876. out->EVSENotification = (unsigned char) in->EVSENotification;
  877. // dinEVSENotificationType_None = 0, (default)
  878. // dinEVSENotificationType_StopCharging = 1,
  879. // dinEVSENotificationType_ReNegotiation = 2
  880. }
  881. /*===========================================================================
  882. FUNCTION: SHM_Read_iso1DC_EVSEStatusType
  883. DESCRIPTION:
  884. PRE-CONDITION:
  885. INPUT:
  886. 1. in
  887. OUTPUT:
  888. 2. out
  889. GLOBAL VARIABLES:
  890. =============================================================================*/
  891. void SHM_Read_iso1DC_EVSEStatusType(struct iso1DC_EVSEStatusType *out, struct DC_EVSEStatusType_ISO15118_2014 *in)
  892. {
  893. out->EVSEIsolationStatus_isUsed = 1u;
  894. out->EVSEIsolationStatus = (unsigned char) in->EVSEIsolationStatus;
  895. //iso1isolationLevelType_Invalid = 0,
  896. //iso1isolationLevelType_Valid = 1,
  897. //iso1isolationLevelType_Warning = 2,
  898. //iso1isolationLevelType_Fault = 3,
  899. //iso1isolationLevelType_No_IMD = 4
  900. out->EVSEStatusCode = (unsigned char) in->DC_EVSEStatusCode;
  901. //iso1DC_EVSEStatusCodeType_EVSE_NotReady = 0,
  902. //iso1DC_EVSEStatusCodeType_EVSE_Ready = 1,
  903. //iso1DC_EVSEStatusCodeType_EVSE_Shutdown = 2,
  904. //iso1DC_EVSEStatusCodeType_EVSE_UtilityInterruptEvent = 3,
  905. //iso1DC_EVSEStatusCodeType_EVSE_IsolationMonitoringActive = 4,
  906. //iso1DC_EVSEStatusCodeType_EVSE_EmergencyShutdown = 5,
  907. //iso1DC_EVSEStatusCodeType_EVSE_Malfunction = 6,
  908. //iso1DC_EVSEStatusCodeType_Reserved_8 = 7,
  909. //iso1DC_EVSEStatusCodeType_Reserved_9 = 8,
  910. //iso1DC_EVSEStatusCodeType_Reserved_A = 9,
  911. //iso1DC_EVSEStatusCodeType_Reserved_B = 10,
  912. //iso1DC_EVSEStatusCodeType_Reserved_C = 11
  913. out->NotificationMaxDelay = 0u;
  914. out->EVSENotification = (unsigned char) in->EVSENotification;
  915. //iso1EVSENotificationType_None = 0, (default)
  916. //iso1EVSENotificationType_StopCharging = 1,
  917. //iso1EVSENotificationType_ReNegotiation = 2
  918. }
  919. /*===========================================================================
  920. FUNCTION: SHM_Read_iso1AC_EVSEStatusType
  921. DESCRIPTION:
  922. PRE-CONDITION:
  923. INPUT:
  924. 1. in
  925. OUTPUT:
  926. 2. out
  927. GLOBAL VARIABLES:
  928. =============================================================================*/
  929. void SHM_Read_iso1AC_EVSEStatusType(struct iso1AC_EVSEStatusType *out, struct AC_EVSEStatusType_ISO15118_2014 *in)
  930. {
  931. out->RCD = (int)in->RCD;
  932. //0: no error is detected
  933. //1: an error is detected
  934. out->NotificationMaxDelay = (unsigned short)in->NotificationMaxDelay;
  935. //unit: 1s
  936. //The time SECC expects EVCC to perform EVSENotification
  937. out->EVSENotification = (unsigned char)in->EVSENotification;
  938. //iso1EVSENotificationType_None = 0,
  939. //iso1EVSENotificationType_StopCharging = 1,
  940. //iso1EVSENotificationType_ReNegotiation = 2
  941. }
  942. /*===========================================================================
  943. FUNCTION: SHM_Read_iso1MeterInfo
  944. DESCRIPTION:
  945. PRE-CONDITION:
  946. INPUT:
  947. 1. in
  948. OUTPUT:
  949. 2. out
  950. GLOBAL VARIABLES:
  951. =============================================================================*/
  952. void SHM_Read_iso1MeterInfo(struct iso1MeterInfoType *out, struct MeterInfoType_ISO15118_2014 *in)
  953. {
  954. int i = 0;
  955. //[1/5] MeterID
  956. out->MeterID.charactersLen = 32;
  957. for (i = 0; i < out->MeterID.charactersLen; i++)
  958. {
  959. out->MeterID.characters[i] = (unsigned char)in->MeterID[i];
  960. }
  961. //[2/5] MeterReading
  962. out->MeterReading_isUsed = 1u;
  963. out->MeterReading = (unsigned long)in->MeterReading;
  964. //[3/5] SigMeterReading
  965. out->SigMeterReading_isUsed = 1u;
  966. out->SigMeterReading.bytesLen = 64;
  967. for (i = 0; i < out->SigMeterReading.bytesLen; i++)
  968. {
  969. out->SigMeterReading.bytes[i] = (unsigned char)in->SigMeterReading[i];
  970. }
  971. //[4/5] MeterStatus
  972. out->MeterStatus_isUsed = 1u;
  973. out->MeterStatus = (short)in->MeterStatus;
  974. //[5/5] TMeter
  975. out->TMeter_isUsed = 1u;
  976. out->TMeter = (long)in->TMeter; //[CAUTION] data type
  977. }
  978. /*===========================================================================
  979. FUNCTION: SHM_Save_din_supportedAppProtocolReq
  980. DESCRIPTION:
  981. PRE-CONDITION:
  982. INPUT:
  983. OUTPUT:
  984. GLOBAL VARIABLES:
  985. =============================================================================*/
  986. void SHM_Save_din_supportedAppProtocolReq(struct CcsData *shm_ccs, struct appHandEXIDocument *buf, struct SysConfigAndInfo *shm_sys)
  987. {
  988. // ======== [STEP 1/3] Initialize ========
  989. int i = 0;
  990. int j = 0;
  991. struct SupportedAppProtocolRequest_DIN70121 *shm_msg;
  992. struct appHandAnonType_supportedAppProtocolReq *exi;
  993. shm_msg = &shm_ccs->V2GMessage_DIN70121.SupportedAppProtocolRequest;
  994. exi = &buf->supportedAppProtocolReq;
  995. // ======== [STEP 2/3] Update Flags ========
  996. // ======== [STEP 3/3] Transfer Data ========
  997. for (i = 0; i < exi->AppProtocol.arrayLen ; i++)
  998. {
  999. //ProtocolNamespace
  1000. shm_msg->AppProtocol[i].ProtocolNamespaceLen = (unsigned int) exi->AppProtocol.array[i].ProtocolNamespace.charactersLen;
  1001. for (j = 0; j< shm_msg->AppProtocol[i].ProtocolNamespaceLen; j++)
  1002. {
  1003. shm_msg->AppProtocol[i].ProtocolNamespace[j] = (unsigned char) exi->AppProtocol.array[i].ProtocolNamespace.characters[j];
  1004. }
  1005. //Version (Major, Minor)
  1006. shm_msg->AppProtocol[i].VersionNumberMajor = (unsigned int) exi->AppProtocol.array[i].VersionNumberMajor;
  1007. shm_msg->AppProtocol[i].VersionNumberMinor = (unsigned int) exi->AppProtocol.array[i].VersionNumberMinor;
  1008. //SchemaID
  1009. shm_msg->AppProtocol[i].SchemaID = (unsigned char) exi->AppProtocol.array[i].SchemaID;
  1010. //Priority
  1011. shm_msg->AppProtocol[i].Priority = (unsigned char) exi->AppProtocol.array[i].Priority;
  1012. }
  1013. }
  1014. /*===========================================================================
  1015. FUNCTION: SHM_Save_din_SessionSetupReq
  1016. DESCRIPTION:
  1017. PRE-CONDITION:
  1018. INPUT:
  1019. OUTPUT:
  1020. GLOBAL VARIABLES:
  1021. =============================================================================*/
  1022. void SHM_Save_din_SessionSetupReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1023. {
  1024. // ======== [STEP 1/3] Initialize ========
  1025. int i = 0;
  1026. struct SessionSetupRequest_DIN70121 *shm_msg;
  1027. struct dinSessionSetupReqType *exi;
  1028. shm_msg = &shm_ccs->V2GMessage_DIN70121.SessionSetupRequest;
  1029. exi = &exi_doc_DIN->V2G_Message.Body.SessionSetupReq;
  1030. // ======== [STEP 2/3] Update Flags ========
  1031. // ======== [STEP 3/3] Transfer Data ========
  1032. //SHM_Save_din_V2GMSG_Header(buf);
  1033. //EVCCID Length
  1034. EVCOMM_SYS_INFO.EVCCID_length = (unsigned char)exi->EVCCID.bytesLen;
  1035. //EVCCID
  1036. for (i = 0; i < exi->EVCCID.bytesLen; i++)
  1037. {
  1038. shm_msg->EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1039. EVCOMM_SYS_INFO.EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1040. }
  1041. }
  1042. /*===========================================================================
  1043. FUNCTION: SHM_Save_iso1_SessionSetupReq
  1044. DESCRIPTION:
  1045. PRE-CONDITION:
  1046. INPUT:
  1047. OUTPUT:
  1048. GLOBAL VARIABLES:
  1049. =============================================================================*/
  1050. void SHM_Save_iso1_SessionSetupReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1051. {
  1052. // ======== [STEP 1/3] Initialize ========
  1053. int i = 0;
  1054. struct SessionSetupRequest_ISO15118_2014 *shm_msg;
  1055. struct iso1SessionSetupReqType *exi;
  1056. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.SessionSetupRequest;
  1057. exi = &exi_doc_ISO1->V2G_Message.Body.SessionSetupReq;
  1058. // ======== [STEP 2/3] Update Flags ========
  1059. // ======== [STEP 3/3] Transfer Data ========
  1060. //SHM_Save_din_V2GMSG_Header(buf);
  1061. //EVCCID Length
  1062. EVCOMM_SYS_INFO.EVCCID_length = (unsigned char)exi->EVCCID.bytesLen;
  1063. //EVCCID
  1064. for (i = 0; i < exi->EVCCID.bytesLen; i++)
  1065. {
  1066. shm_msg->EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1067. EVCOMM_SYS_INFO.EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1068. }
  1069. }
  1070. /*===========================================================================
  1071. FUNCTION: SHM_Save_iso2_SessionSetupReq
  1072. DESCRIPTION:
  1073. PRE-CONDITION:
  1074. INPUT:
  1075. OUTPUT:
  1076. GLOBAL VARIABLES:
  1077. =============================================================================*/
  1078. void SHM_Save_iso2_SessionSetupReq(struct CcsData *shm_ccs, struct iso2EXIDocument *exi_doc_ISO2, struct SysConfigAndInfo *shm_sys)
  1079. {
  1080. // ======== [STEP 1/3] Initialize ========
  1081. int i = 0;
  1082. struct SessionSetupRequest_ISO15118_2018 *shm_msg;
  1083. struct iso2SessionSetupReqType *exi;
  1084. shm_msg = &shm_ccs->V2GMessage_ISO15118_2018.SessionSetupRequest;
  1085. exi = &exi_doc_ISO2->V2G_Message.Body.SessionSetupReq;
  1086. // ======== [STEP 2/3] Update Flags ========
  1087. // ======== [STEP 3/3] Transfer Data ========
  1088. //SHM_Save_din_V2GMSG_Header(buf);
  1089. //EVCCID Length
  1090. EVCOMM_SYS_INFO.EVCCID_length = (unsigned char)exi->EVCCID.bytesLen;
  1091. //EVCCID
  1092. for (i = 0; i < exi->EVCCID.bytesLen; i++)
  1093. {
  1094. shm_msg->EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1095. EVCOMM_SYS_INFO.EVCCID[i] = (unsigned char) exi->EVCCID.bytes[i];
  1096. }
  1097. }
  1098. /*===========================================================================
  1099. FUNCTION: SHM_Save_din_ServiceDiscoveryReq
  1100. DESCRIPTION:
  1101. PRE-CONDITION:
  1102. INPUT:
  1103. OUTPUT:
  1104. GLOBAL VARIABLES:
  1105. =============================================================================*/
  1106. void SHM_Save_din_ServiceDiscoveryReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1107. {
  1108. // ======== [STEP 1/3] Initialize ========
  1109. int i = 0;
  1110. struct ServiceDiscoveryRequest_DIN70121 *shm_msg;
  1111. struct dinServiceDiscoveryReqType *exi;
  1112. shm_msg = &shm_ccs->V2GMessage_DIN70121.ServiceDiscoveryRequest;
  1113. exi = &exi_doc_DIN->V2G_Message.Body.ServiceDiscoveryReq;
  1114. // ======== [STEP 2/3] Update Flags ========
  1115. // ======== [STEP 3/3] Transfer Data ========
  1116. //SHM_Save_din_V2GMSG_Header(buf);
  1117. //ServiceScope
  1118. shm_msg->ServiceScopeLen = (unsigned int) exi->ServiceScope.charactersLen;
  1119. for (i = 0; i <shm_msg->ServiceScopeLen ; i++)
  1120. {
  1121. shm_msg->ServiceScope[i] = (unsigned char) exi->ServiceScope.characters[i];
  1122. }
  1123. //ServiceCategory
  1124. shm_msg->ServiceCategory = (unsigned int) exi->ServiceCategory;
  1125. }
  1126. /*===========================================================================
  1127. FUNCTION: SHM_Save_iso1_ServiceDiscoveryReq
  1128. DESCRIPTION:
  1129. PRE-CONDITION:
  1130. INPUT:
  1131. OUTPUT:
  1132. GLOBAL VARIABLES:
  1133. =============================================================================*/
  1134. void SHM_Save_iso1_ServiceDiscoveryReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1135. {
  1136. // ======== [STEP 1/3] Initialize ========
  1137. int i = 0;
  1138. struct ServiceDiscoveryRequest_ISO15118_2014 *shm_msg;
  1139. struct iso1ServiceDiscoveryReqType *exi;
  1140. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.ServiceDiscoveryRequest;
  1141. exi = &exi_doc_ISO1->V2G_Message.Body.ServiceDiscoveryReq;
  1142. // ======== [STEP 2/3] Update Flags ========
  1143. // ======== [STEP 3/3] Transfer Data ========
  1144. //SHM_Save_iso1_V2GMSG_Header(buf);
  1145. //ServiceScope
  1146. shm_msg->ServiceScopeLen = (unsigned int) exi->ServiceScope.charactersLen;
  1147. for (i = 0; i <shm_msg->ServiceScopeLen ; i++)
  1148. {
  1149. shm_msg->ServiceScope[i] = (unsigned char) exi->ServiceScope.characters[i];
  1150. }
  1151. //ServiceCategory
  1152. shm_msg->ServiceCategory = (unsigned int) exi->ServiceCategory;
  1153. }
  1154. /*===========================================================================
  1155. FUNCTION: SHM_Save_din_ServiceAndPaymentSelectionReq
  1156. DESCRIPTION:
  1157. PRE-CONDITION:
  1158. INPUT:
  1159. OUTPUT:
  1160. GLOBAL VARIABLES:
  1161. =============================================================================*/
  1162. void SHM_Save_din_ServiceAndPaymentSelectionReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1163. {
  1164. // ======== [STEP 1/3] Initialize ========
  1165. int i = 0;
  1166. struct ServiceAndPaymentSelectionRequest_DIN70121 *shm_msg;
  1167. struct dinServicePaymentSelectionReqType *exi;
  1168. shm_msg = &shm_ccs->V2GMessage_DIN70121.ServiceAndPaymentSelectionRequest;
  1169. exi = &exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq;
  1170. // ======== [STEP 2/3] Update Flags ========
  1171. // ======== [STEP 3/3] Transfer Data ========
  1172. //SHM_Save_din_V2GMSG_Header(buf);
  1173. //[1/2] SelectedPaymentOption
  1174. shm_msg->SelectedPaymentOption = (unsigned char) exi->SelectedPaymentOption;
  1175. //[2/2] SelectedServiceList
  1176. shm_msg->SelectedServiceList.SelectedServiceLen = (unsigned int) exi->SelectedServiceList.SelectedService.arrayLen;
  1177. for (i = 0; i< shm_msg->SelectedServiceList.SelectedServiceLen; i++)
  1178. {
  1179. shm_msg->SelectedServiceList.SelectedService[i].ServiceID =
  1180. (unsigned short) exi->SelectedServiceList.SelectedService.array[i].ServiceID;
  1181. shm_msg->SelectedServiceList.SelectedService[i].ParameterSetID =
  1182. (short) exi->SelectedServiceList.SelectedService.array[i].ParameterSetID;
  1183. }
  1184. }
  1185. /*===========================================================================
  1186. FUNCTION: SHM_Save_iso1_ServiceAndPaymentSelectionReq
  1187. DESCRIPTION:
  1188. PRE-CONDITION:
  1189. INPUT:
  1190. OUTPUT:
  1191. GLOBAL VARIABLES:
  1192. =============================================================================*/
  1193. void SHM_Save_iso1_ServiceAndPaymentSelectionReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1194. {
  1195. // ======== [STEP 1/3] Initialize ========
  1196. int i = 0;
  1197. struct ServiceAndPaymentSelectionRequest_ISO15118_2014 *shm_msg;
  1198. struct iso1PaymentServiceSelectionReqType *exi;
  1199. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.ServiceAndPaymentSelectionRequest;
  1200. exi = &exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq;
  1201. // ======== [STEP 2/3] Update Flags ========
  1202. // ======== [STEP 3/3] Transfer Data ========
  1203. //SHM_Save_iso1_V2GMSG_Header(buf);
  1204. //[1/2] SelectedPaymentOption
  1205. shm_msg->SelectedPaymentOption = (unsigned char) exi->SelectedPaymentOption;
  1206. //[2/2] SelectedServiceList
  1207. shm_msg->SelectedServiceList.SelectedServiceLen = (unsigned int) exi->SelectedServiceList.SelectedService.arrayLen;
  1208. for (i = 0; i< shm_msg->SelectedServiceList.SelectedServiceLen; i++)
  1209. {
  1210. shm_msg->SelectedServiceList.SelectedService[i].ServiceID =
  1211. (unsigned short) exi->SelectedServiceList.SelectedService.array[i].ServiceID;
  1212. shm_msg->SelectedServiceList.SelectedService[i].ParameterSetID =
  1213. (short) exi->SelectedServiceList.SelectedService.array[i].ParameterSetID;
  1214. }
  1215. }
  1216. /*===========================================================================
  1217. FUNCTION: SHM_Save_din_ContractAuthenticationReq
  1218. DESCRIPTION:
  1219. PRE-CONDITION:
  1220. INPUT:
  1221. OUTPUT:
  1222. GLOBAL VARIABLES:
  1223. =============================================================================*/
  1224. void SHM_Save_din_ContractAuthenticationReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1225. {
  1226. // ======== [STEP 1/3] Initialize ========
  1227. //int i = 0;
  1228. //struct ContractAuthenticationRequest_DIN70121 *shm_msg;
  1229. //struct dinContractAuthenticationReqType *exi;
  1230. //shm_msg = &shm_ccs->V2GMessage_DIN70121.ContractAuthenticationRequest;
  1231. //exi = &exi_doc_DIN->V2G_Message.Body.ContractAuthenticationReq;
  1232. // ======== [STEP 2/3] Update Flags ========
  1233. // ======== [STEP 3/3] Transfer Data ========
  1234. //SHM_Save_din_V2GMSG_Header(buf);
  1235. //none
  1236. }
  1237. /*===========================================================================
  1238. FUNCTION: SHM_Save_iso1_AuthorizationReq
  1239. DESCRIPTION:
  1240. PRE-CONDITION:
  1241. INPUT:
  1242. OUTPUT:
  1243. GLOBAL VARIABLES:
  1244. =============================================================================*/
  1245. void SHM_Save_iso1_AuthorizationReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1246. {
  1247. // ======== [STEP 1/3] Initialize ========
  1248. //int i = 0;
  1249. //struct AuthorizationRequest_ISO15118_2014 *shm_msg;
  1250. //struct iso1AuthorizationReqType *exi;
  1251. //shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.AuthorizationRequest;
  1252. // exi = &exi_doc_ISO1->V2G_Message.Body.AuthorizationReq;
  1253. // ======== [STEP 2/3] Update Flags ========
  1254. // ======== [STEP 3/3] Transfer Data ========
  1255. //SHM_Save_iso1_V2GMSG_Header(buf);
  1256. //none
  1257. }
  1258. /*===========================================================================
  1259. FUNCTION: SHM_Save_din_ChargeParameterDiscoveryReq
  1260. DESCRIPTION: Save into share memories
  1261. (1) ShmCcsData (shm_ccs)
  1262. (2) ShmSysConfigAndInfo (shm_sys)
  1263. PRE-CONDITION:
  1264. INPUT:
  1265. OUTPUT:
  1266. GLOBAL VARIABLES:
  1267. =============================================================================*/
  1268. void SHM_Save_din_ChargeParameterDiscoveryReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1269. {
  1270. // ======== [STEP 1/3] Initialize ========
  1271. //int i = 0;
  1272. struct ChargeParameterDiscoveryRequest_DIN70121 *shm_msg;
  1273. struct dinChargeParameterDiscoveryReqType *exi;
  1274. struct ChargingInfoData *sys;
  1275. shm_msg = &shm_ccs->V2GMessage_DIN70121.ChargeParameterDiscoveryRequest;
  1276. exi = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq;
  1277. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1278. // ======== [STEP 2/3] Update Flags ========
  1279. // ======== [STEP 3/3] Transfer Data ========
  1280. //SHM_Save_din_V2GMSG_Header(buf);
  1281. //===== [BODY (1/9)] EVRequestedEnergyTransferType =====
  1282. shm_msg->EVRequestedEnergyTransferType = (unsigned char) exi->EVRequestedEnergyTransferType;
  1283. //===== [BODY (2/9)] DC_EVChargeParameter of EVChargeParameter =====
  1284. //DC_EVStatus
  1285. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVReady = (BOOL) exi->DC_EVChargeParameter.DC_EVStatus.EVReady;
  1286. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVChargeParameter.DC_EVStatus.EVCabinConditioning;
  1287. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVChargeParameter.DC_EVStatus.EVRESSConditioning;
  1288. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVChargeParameter.DC_EVStatus.EVErrorCode;
  1289. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC;
  1290. sys->EvBatterySoc = (int) shm_msg->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC;
  1291. //[BODY (3/9)] EVMaximumCurrentLimit
  1292. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Multiplier =
  1293. (int) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Multiplier;
  1294. //shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit;
  1295. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit = A_DIN70121;
  1296. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Value =
  1297. (short) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Value;
  1298. sys->EvBatteryMaxCurrent = DIN70121PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit);
  1299. //[BODY (4/9)] EVMaximumPowerLimit
  1300. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Multiplier =
  1301. (int) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Multiplier;
  1302. //shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Unit;
  1303. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Unit = W_DIN70121;
  1304. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Value =
  1305. (short) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Value;
  1306. sys->EvBatteryMaxPower = DIN70121PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit);
  1307. //[BODY (5/9)] EVMaximumVoltageLimit
  1308. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Multiplier =
  1309. (int) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Multiplier;
  1310. //shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit;
  1311. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit = V_DIN70121;
  1312. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Value =
  1313. (short) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Value;
  1314. sys->EvBatteryMaxVoltage = DIN70121PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit);
  1315. //[BODY (6/9)] EVEnergyCapacity
  1316. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Multiplier =
  1317. (int) exi->DC_EVChargeParameter.EVEnergyCapacity.Multiplier;
  1318. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Unit = WH_DIN70121;
  1319. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Value =
  1320. (short) exi->DC_EVChargeParameter.EVEnergyCapacity.Value;
  1321. sys->EvBatteryCapacity = DIN70121PhyValDecode(shm_msg->DC_EVChargeParameter.EVEnergyCapacity);
  1322. //[BODY (7/9)] EVEnergyRequest
  1323. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Multiplier =
  1324. (int) exi->DC_EVChargeParameter.EVEnergyRequest.Multiplier;
  1325. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Unit = WH_DIN70121;
  1326. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Value =
  1327. (short) exi->DC_EVChargeParameter.EVEnergyRequest.Value;
  1328. sys->EvBatteryEngergyRequest = DIN70121PhyValDecode(shm_msg->DC_EVChargeParameter.EVEnergyRequest);
  1329. //[BODY (8/9)] FullSOC
  1330. if (exi->DC_EVChargeParameter.FullSOC_isUsed != 0 && exi->DC_EVChargeParameter.FullSOC != 0)
  1331. {
  1332. shm_msg->DC_EVChargeParameter.FullSOC = (unsigned char) exi->DC_EVChargeParameter.FullSOC;
  1333. }
  1334. else
  1335. {
  1336. shm_msg->DC_EVChargeParameter.FullSOC = (unsigned char) exi->DC_EVChargeParameter.BulkSOC;
  1337. }
  1338. //[BODY (9/9)] BulkSOC
  1339. shm_msg->DC_EVChargeParameter.BulkSOC = (unsigned char) exi->DC_EVChargeParameter.BulkSOC;
  1340. }
  1341. /*===========================================================================
  1342. FUNCTION: SHM_Save_iso1_ChargeParameterDiscoveryReq
  1343. DESCRIPTION: Save into share memories
  1344. (1) ShmCcsData (shm_ccs)
  1345. (2) ShmSysConfigAndInfo (shm_sys)
  1346. PRE-CONDITION:
  1347. INPUT:
  1348. OUTPUT:
  1349. GLOBAL VARIABLES:
  1350. =============================================================================*/
  1351. void SHM_Save_iso1_ChargeParameterDiscoveryReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1352. {
  1353. // ======== [STEP 1/3] Initialize ========
  1354. //int i = 0;
  1355. struct ChargeParameterDiscoveryRequest_ISO15118_2014 *shm_msg;
  1356. struct iso1ChargeParameterDiscoveryReqType *exi;
  1357. struct ChargingInfoData *sys;
  1358. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.ChargeParameterDiscoveryRequest;
  1359. exi = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq;
  1360. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1361. // ======== [STEP 2/3] Update Flags ========
  1362. // ======== [STEP 3/3] Transfer Data ========
  1363. //SHM_Save_iso1_V2GMSG_Header(buf);
  1364. //===== [BODY (1/9)] EVRequestedEnergyTransferType =====
  1365. shm_msg->RequestedEnergyTransferMode = (unsigned char) exi->RequestedEnergyTransferMode;
  1366. //===== [BODY (2/9)] DC_EVChargeParameter of EVChargeParameter =====
  1367. //DC_EVStatus
  1368. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVReady = (BOOL) exi->DC_EVChargeParameter.DC_EVStatus.EVReady;
  1369. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVChargeParameter.DC_EVStatus.EVErrorCode;
  1370. shm_msg->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC;
  1371. sys->EvBatterySoc = (int) shm_msg->DC_EVChargeParameter.DC_EVStatus.EVRESSSOC;
  1372. //[BODY (3/9)] EVMaximumCurrentLimit
  1373. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Multiplier =
  1374. (int) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Multiplier;
  1375. //shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit;
  1376. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Unit = A_ISO15118_2014;
  1377. shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit.Value =
  1378. (short) exi->DC_EVChargeParameter.EVMaximumCurrentLimit.Value;
  1379. sys->EvBatteryMaxCurrent = ISO151182014PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumCurrentLimit);
  1380. //[BODY (4/9)] EVMaximumPowerLimit
  1381. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Multiplier =
  1382. (int) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Multiplier;
  1383. //shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Unit;
  1384. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Unit = W_ISO15118_2014;
  1385. shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit.Value =
  1386. (short) exi->DC_EVChargeParameter.EVMaximumPowerLimit.Value;
  1387. sys->EvBatteryMaxPower = ISO151182014PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumPowerLimit);
  1388. //[BODY (5/9)] EVMaximumVoltageLimit
  1389. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Multiplier =
  1390. (int) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Multiplier;
  1391. //shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit = (unsigned char) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit;
  1392. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Unit = V_ISO15118_2014;
  1393. shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit.Value =
  1394. (short) exi->DC_EVChargeParameter.EVMaximumVoltageLimit.Value;
  1395. sys->EvBatteryMaxVoltage = ISO151182014PhyValDecode(shm_msg->DC_EVChargeParameter.EVMaximumVoltageLimit);
  1396. //[BODY (6/9)] EVEnergyCapacity
  1397. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Multiplier =
  1398. (int) exi->DC_EVChargeParameter.EVEnergyCapacity.Multiplier;
  1399. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Unit = Wh_ISO15118_2014;
  1400. shm_msg->DC_EVChargeParameter.EVEnergyCapacity.Value =
  1401. (short) exi->DC_EVChargeParameter.EVEnergyCapacity.Value;
  1402. sys->EvBatteryCapacity = ISO151182014PhyValDecode(shm_msg->DC_EVChargeParameter.EVEnergyCapacity);
  1403. //[BODY (7/9)] EVEnergyRequest
  1404. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Multiplier =
  1405. (int) exi->DC_EVChargeParameter.EVEnergyRequest.Multiplier;
  1406. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Unit = Wh_ISO15118_2014;
  1407. shm_msg->DC_EVChargeParameter.EVEnergyRequest.Value =
  1408. (short) exi->DC_EVChargeParameter.EVEnergyRequest.Value;
  1409. sys->EvBatteryEngergyRequest = ISO151182014PhyValDecode(shm_msg->DC_EVChargeParameter.EVEnergyRequest);
  1410. //[BODY (8/9)] FullSOC
  1411. if (exi->DC_EVChargeParameter.FullSOC_isUsed != 0 && exi->DC_EVChargeParameter.FullSOC != 0)
  1412. {
  1413. shm_msg->DC_EVChargeParameter.FullSOC = (unsigned char) exi->DC_EVChargeParameter.FullSOC;
  1414. }
  1415. else
  1416. {
  1417. shm_msg->DC_EVChargeParameter.FullSOC = (unsigned char) exi->DC_EVChargeParameter.BulkSOC;
  1418. }
  1419. //[BODY (9/9)] BulkSOC
  1420. shm_msg->DC_EVChargeParameter.BulkSOC = (unsigned char) exi->DC_EVChargeParameter.BulkSOC;
  1421. }
  1422. /*===========================================================================
  1423. FUNCTION: SHM_Save_din_CableCheckReq
  1424. DESCRIPTION:
  1425. PRE-CONDITION:
  1426. INPUT:
  1427. OUTPUT:
  1428. GLOBAL VARIABLES:
  1429. =============================================================================*/
  1430. void SHM_Save_din_CableCheckReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1431. {
  1432. // ======== [STEP 1/3] Initialize ========
  1433. struct CableCheckRequest_DIN70121 *shm_msg;
  1434. struct dinCableCheckReqType *exi;
  1435. struct ChargingInfoData *sys;
  1436. shm_msg = &shm_ccs->V2GMessage_DIN70121.CableCheckRequest;
  1437. exi = &exi_doc_DIN->V2G_Message.Body.CableCheckReq;
  1438. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1439. // ======== [STEP 2/3] Update Flags ========
  1440. // ======== [STEP 3/3] Transfer Data ========
  1441. //SHM_Save_din_V2GMSG_Header(buf);
  1442. //===== [BODY (1/1)] DC_EVStatus =====
  1443. //DC_EVStatus
  1444. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1445. shm_msg->DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVStatus.EVCabinConditioning;
  1446. shm_msg->DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVStatus.EVRESSConditioning;
  1447. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1448. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1449. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1450. //Check for EVReady
  1451. //if (shm_msg->DC_EVStatus.EVReady == TRUE && shm_msg->DC_EVStatus.EVErrorCode == NO_ERROR)
  1452. //{
  1453. //sys->ConnectorLocked = TRUE; //Inicating EVSE that the CCS Connector is Locked.
  1454. //}
  1455. }
  1456. /*===========================================================================
  1457. FUNCTION: SHM_Save_iso1_CableCheckReq
  1458. DESCRIPTION:
  1459. PRE-CONDITION:
  1460. INPUT:
  1461. OUTPUT:
  1462. GLOBAL VARIABLES:
  1463. =============================================================================*/
  1464. void SHM_Save_iso1_CableCheckReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1465. {
  1466. // ======== [STEP 1/3] Initialize ========
  1467. struct CableCheckRequest_ISO15118_2014 *shm_msg;
  1468. struct iso1CableCheckReqType *exi;
  1469. struct ChargingInfoData *sys;
  1470. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.CableCheckRequest;
  1471. exi = &exi_doc_ISO1->V2G_Message.Body.CableCheckReq;
  1472. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1473. // ======== [STEP 2/3] Update Flags ========
  1474. // ======== [STEP 3/3] Transfer Data ========
  1475. //SHM_Save_iso1_V2GMSG_Header(buf);
  1476. //===== [BODY (1/1)] DC_EVStatus =====
  1477. //DC_EVStatus
  1478. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1479. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1480. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1481. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1482. //Check for EVReady
  1483. //if (shm_msg->DC_EVStatus.EVReady == TRUE && shm_msg->DC_EVStatus.EVErrorCode == NO_ERROR)
  1484. //{
  1485. //sys->ConnectorLocked = TRUE; //Inicating EVSE that the CCS Connector is Locked.
  1486. //}
  1487. }
  1488. /*===========================================================================
  1489. FUNCTION: SHM_Save_din_PreChargeReq
  1490. DESCRIPTION:
  1491. PRE-CONDITION:
  1492. INPUT:
  1493. OUTPUT:
  1494. GLOBAL VARIABLES:
  1495. =============================================================================*/
  1496. void SHM_Save_din_PreChargeReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1497. {
  1498. // ======== [STEP 1/3] Initialize ========
  1499. struct PreChargeRequest_DIN70121 *shm_msg;
  1500. struct dinPreChargeReqType *exi;
  1501. struct ChargingInfoData *sys;
  1502. shm_msg = &shm_ccs->V2GMessage_DIN70121.PreChargeRequest;
  1503. exi = &exi_doc_DIN->V2G_Message.Body.PreChargeReq;
  1504. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1505. shm_msg->cnt++;
  1506. // ======== [STEP 2/3] Update Flags ========
  1507. // ======== [STEP 3/3] Transfer Data ========
  1508. //SHM_Save_din_V2GMSG_Header(buf);
  1509. //===== [BODY (1/3)] DC_EVStatus =====
  1510. //DC_EVStatus
  1511. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1512. shm_msg->DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVStatus.EVCabinConditioning;
  1513. shm_msg->DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVStatus.EVRESSConditioning;
  1514. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1515. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1516. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1517. //[BODY (2/3)] EVTargetVoltage
  1518. shm_msg->EVTargetVoltage.Multiplier = (int) exi->EVTargetVoltage.Multiplier;
  1519. //shm_msg->EVTargetVoltage.Unit = (unsigned char) exi->EVTargetVoltage.Unit;
  1520. shm_msg->EVTargetVoltage.Unit = V_DIN70121;
  1521. shm_msg->EVTargetVoltage.Value = (short) exi->EVTargetVoltage.Value;
  1522. if ((sys->EVSEPrechargeStatus == EVSE_STATUS_NOT_READY_FOR_PRECHARGE) || (shm_msg->cnt <= 2)) //0
  1523. {
  1524. sys->EvBatterytargetVoltage = 0; //0V, in order to avoid of turning off relay when D+/D- owns voltage.
  1525. }
  1526. else if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2
  1527. {
  1528. sys->EvBatterytargetVoltage = DIN70121PhyValDecode(shm_msg->EVTargetVoltage);
  1529. //sys->EvBatterytargetVoltage = DIN70121PhyValDecode(shm_msg->EVTargetVoltage) + 5; //for test, add 10V
  1530. }
  1531. //[BODY (3/3)] EVTargetCurrent
  1532. shm_msg->EVTargetCurrent.Multiplier = (int) exi->EVTargetCurrent.Multiplier;
  1533. //shm_msg->EVTargetCurrent.Unit = (unsigned char) exi->EVTargetCurrent.Unit;
  1534. shm_msg->EVTargetCurrent.Unit = A_DIN70121;
  1535. shm_msg->EVTargetCurrent.Value = (short) exi->EVTargetCurrent.Value;
  1536. if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2
  1537. {
  1538. //sys->EvBatteryMaxCurrent = DIN70121PhyValDecode(shm_msg->EVTargetCurrent);
  1539. sys->EvBatterytargetCurrent = PRECHARGE_TARGET_CURRENT; //for EVSE (default: 2A)
  1540. }
  1541. else
  1542. {
  1543. sys->EvBatterytargetCurrent = 0; //0A
  1544. }
  1545. //printf("\n\n[%d-th]sys-EvBatterytargetVoltage = %.02f (ori = %d)\n\n", cnt, sys->EvBatterytargetVoltage, shm_msg->EVTargetVoltage.Value);
  1546. }
  1547. /*===========================================================================
  1548. FUNCTION: SHM_Save_iso1_PreChargeReq
  1549. DESCRIPTION:
  1550. PRE-CONDITION:
  1551. INPUT:
  1552. OUTPUT:
  1553. GLOBAL VARIABLES:
  1554. =============================================================================*/
  1555. void SHM_Save_iso1_PreChargeReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1556. {
  1557. // ======== [STEP 1/3] Initialize ========
  1558. struct PreChargeRequest_ISO15118_2014 *shm_msg;
  1559. struct iso1PreChargeReqType *exi;
  1560. struct ChargingInfoData *sys;
  1561. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.PreChargeRequest;
  1562. exi = &exi_doc_ISO1->V2G_Message.Body.PreChargeReq;
  1563. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1564. shm_msg->cnt++;
  1565. // ======== [STEP 2/3] Update Flags ========
  1566. // ======== [STEP 3/3] Transfer Data ========
  1567. //SHM_Save_iso1_V2GMSG_Header(buf);
  1568. //===== [BODY (1/3)] DC_EVStatus =====
  1569. //DC_EVStatus
  1570. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1571. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1572. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1573. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1574. //[BODY (2/3)] EVTargetVoltage
  1575. shm_msg->EVTargetVoltage.Multiplier = (int) exi->EVTargetVoltage.Multiplier;
  1576. //shm_msg->EVTargetVoltage.Unit = (unsigned char) exi->EVTargetVoltage.Unit;
  1577. shm_msg->EVTargetVoltage.Unit = V_ISO15118_2014;
  1578. shm_msg->EVTargetVoltage.Value = (short) exi->EVTargetVoltage.Value;
  1579. if ((sys->EVSEPrechargeStatus == EVSE_STATUS_NOT_READY_FOR_PRECHARGE) || (shm_msg->cnt <= 2)) //0
  1580. {
  1581. sys->EvBatterytargetVoltage = 0; //0V, in order to avoid of turning off relay when D+/D- owns voltage.
  1582. }
  1583. else if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2
  1584. {
  1585. sys->EvBatterytargetVoltage = ISO151182014PhyValDecode(shm_msg->EVTargetVoltage);
  1586. }
  1587. //[BODY (3/3)] EVTargetCurrent
  1588. shm_msg->EVTargetCurrent.Multiplier = (int) exi->EVTargetCurrent.Multiplier;
  1589. //shm_msg->EVTargetCurrent.Unit = (unsigned char) exi->EVTargetCurrent.Unit;
  1590. shm_msg->EVTargetCurrent.Unit = A_ISO15118_2014;
  1591. shm_msg->EVTargetCurrent.Value = (short) exi->EVTargetCurrent.Value;
  1592. if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2
  1593. {
  1594. //sys->EvBatteryMaxCurrent = ISO151182014PhyValDecode(shm_msg->EVTargetCurrent);
  1595. sys->EvBatterytargetCurrent = PRECHARGE_TARGET_CURRENT; //for EVSE (default: 2A)
  1596. }
  1597. else
  1598. {
  1599. sys->EvBatterytargetCurrent = 0; //0A
  1600. }
  1601. //printf("\n\n[%d-th]sys-EvBatterytargetVoltage = %.02f (ori = %d)\n\n", cnt, sys->EvBatterytargetVoltage, shm_msg->EVTargetVoltage.Value);
  1602. }
  1603. /*===========================================================================
  1604. FUNCTION: SHM_Save_din_PowerDeliveryReq
  1605. DESCRIPTION:
  1606. PRE-CONDITION:
  1607. INPUT:
  1608. OUTPUT:
  1609. GLOBAL VARIABLES:
  1610. =============================================================================*/
  1611. void SHM_Save_din_PowerDeliveryReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1612. {
  1613. // ======== [STEP 1/3] Initialize ========
  1614. //int i = 0;
  1615. struct PowerDeliveryRequest_DIN70121 *shm_msg;
  1616. struct dinPowerDeliveryReqType *exi;
  1617. struct ChargingInfoData *sys;
  1618. shm_msg = &shm_ccs->V2GMessage_DIN70121.PowerDeliveryRequest;
  1619. exi = &exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq;
  1620. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1621. // ======== [STEP 2/3] Update Flags ========
  1622. // ======== [STEP 3/3] Transfer Data ========
  1623. //SHM_Save_din_V2GMSG_Header(buf);
  1624. //[BODY (1/3)] ReadyToChargeState
  1625. shm_msg->ReadyToChargeState = (BOOL) exi->ReadyToChargeState;
  1626. //[BODY (2/3)] ChargingProfile
  1627. //[BODY (3/3)] DC_EVPowerDeliveryParameters
  1628. //DC_EVStatus
  1629. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVReady = (BOOL) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVReady;
  1630. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVCabinConditioning;
  1631. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSConditioning;
  1632. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVErrorCode;
  1633. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC;
  1634. sys->EvBatterySoc = (int) shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC;
  1635. //BulkChargingComplete
  1636. shm_msg->DC_EVPowerDeliveryParameter.BulkChargingComplete = (BOOL) exi->DC_EVPowerDeliveryParameter.BulkChargingComplete;
  1637. //ChargingComplete
  1638. shm_msg->DC_EVPowerDeliveryParameter.ChargingComplete = (BOOL) exi->DC_EVPowerDeliveryParameter.ChargingComplete;
  1639. }
  1640. /*===========================================================================
  1641. FUNCTION: SHM_Save_iso1_PowerDeliveryReq
  1642. DESCRIPTION:
  1643. PRE-CONDITION:
  1644. INPUT:
  1645. OUTPUT:
  1646. GLOBAL VARIABLES:
  1647. =============================================================================*/
  1648. void SHM_Save_iso1_PowerDeliveryReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1649. {
  1650. // ======== [STEP 1/3] Initialize ========
  1651. //int i = 0;
  1652. struct PowerDeliveryRequest_ISO15118_2014 *shm_msg;
  1653. struct iso1PowerDeliveryReqType *exi;
  1654. struct ChargingInfoData *sys;
  1655. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.PowerDeliveryRequest;
  1656. exi = &exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq;
  1657. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1658. // ======== [STEP 2/3] Update Flags ========
  1659. // ======== [STEP 3/3] Transfer Data ========
  1660. //SHM_Save_iso1_V2GMSG_Header(buf);
  1661. //[BODY (1/3)] ChargeProgress
  1662. shm_msg->ChargeProgress = (BOOL) exi->ChargeProgress;
  1663. //[BODY (2/3)] ChargingProfile
  1664. //[BODY (3/3)] DC_EVPowerDeliveryParameters
  1665. //DC_EVStatus
  1666. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVReady = (BOOL) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVReady;
  1667. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVErrorCode;
  1668. shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC;
  1669. sys->EvBatterySoc = (int) shm_msg->DC_EVPowerDeliveryParameter.DC_EVStatus.EVRESSSOC;
  1670. //BulkChargingComplete
  1671. shm_msg->DC_EVPowerDeliveryParameter.BulkChargingComplete = (BOOL) exi->DC_EVPowerDeliveryParameter.BulkChargingComplete;
  1672. //ChargingComplete
  1673. shm_msg->DC_EVPowerDeliveryParameter.ChargingComplete = (BOOL) exi->DC_EVPowerDeliveryParameter.ChargingComplete;
  1674. }
  1675. /*===========================================================================
  1676. FUNCTION: SHM_Save_din_CurrentDemandReq
  1677. DESCRIPTION:
  1678. PRE-CONDITION:
  1679. INPUT:
  1680. OUTPUT:
  1681. GLOBAL VARIABLES:
  1682. =============================================================================*/
  1683. void SHM_Save_din_CurrentDemandReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1684. {
  1685. // ======== [STEP 1/3] Initialize ========
  1686. //int i = 0;
  1687. struct CurrentDemandRequest_DIN70121 *shm_msg;
  1688. struct dinCurrentDemandReqType *exi;
  1689. struct ChargingInfoData *sys;
  1690. shm_msg = &shm_ccs->V2GMessage_DIN70121.CurrentDemandRequest;
  1691. exi = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq;
  1692. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1693. // ======== [STEP 2/3] Update Flags ========
  1694. // ======== [STEP 3/3] Transfer Data ========
  1695. //SHM_Save_din_V2GMSG_Header(buf);
  1696. //[BODY (1/10)] DC_EVStatus
  1697. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1698. shm_msg->DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVStatus.EVCabinConditioning;
  1699. shm_msg->DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVStatus.EVRESSConditioning;
  1700. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1701. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1702. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1703. //[BODY (2/10)] EVTargetCurrent
  1704. shm_msg->EVTargetCurrent.Multiplier = (int) exi->EVTargetCurrent.Multiplier;
  1705. //shm_msg->EVTargetCurrent.Unit = (unsigned char) exi->EVTargetCurrent.Unit;
  1706. shm_msg->EVTargetCurrent.Unit = A_DIN70121;
  1707. shm_msg->EVTargetCurrent.Value = (short) exi->EVTargetCurrent.Value;
  1708. if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_ENERGY_TRANSFER) //3 (Precharge Relay OFF, DC+ Relay ON)
  1709. {
  1710. sys->EvBatterytargetCurrent = DIN70121PhyValDecode(shm_msg->EVTargetCurrent);
  1711. #if MANUAL_SET_EV_TARGET_FUNCTION == ENABLE
  1712. sys->EvBatterytargetCurrent = SUDO_EV_TARGET_CURRENT; //60A, for test;
  1713. #endif
  1714. }
  1715. else if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2 (Precharge Relay ON, DC+ Relay OFF)
  1716. {
  1717. //sys->EvBatterytargetCurrent = PRECHARGE_TARGET_CURRENT; //2A, unit: 1A
  1718. sys->EvBatterytargetCurrent = DIN70121PhyValDecode(shm_msg->EVTargetCurrent);
  1719. }
  1720. else //0 (Precharge Relay is still under preparing, not ON, yet.)
  1721. {
  1722. //sys->EvBatterytargetCurrent = 0; //0A
  1723. sys->EvBatterytargetCurrent = DIN70121PhyValDecode(shm_msg->EVTargetCurrent);
  1724. }
  1725. //[BODY (3/10)] EVMaximumVoltageLimit
  1726. shm_msg->EVMaximumVoltageLimit.Multiplier = (int) exi->EVMaximumVoltageLimit.Multiplier;
  1727. //shm_msg->EVMaximumVoltageLimit.Unit = (unsigned char) exi->EVMaximumVoltageLimit.Unit;
  1728. shm_msg->EVMaximumVoltageLimit.Unit = V_DIN70121;
  1729. shm_msg->EVMaximumVoltageLimit.Value = (short) exi->EVMaximumVoltageLimit.Value;
  1730. if (shm_msg->EVMaximumVoltageLimit.Value != 0 && exi->EVMaximumVoltageLimit_isUsed == 1u) //Gridwiz EVCC Emulator will not send EVMaximumVoltageLimit in CurrentDemandReq
  1731. {
  1732. sys->EvBatteryMaxVoltage = DIN70121PhyValDecode(shm_msg->EVMaximumVoltageLimit);
  1733. }
  1734. //[BODY (4/10)] EVMaximumCurrentLimit
  1735. shm_msg->EVMaximumCurrentLimit.Multiplier = (int) exi->EVMaximumCurrentLimit.Multiplier;
  1736. //shm_msg->EVMaximumCurrentLimit.Unit = (unsigned char) exi->EVMaximumCurrentLimit.Unit;
  1737. shm_msg->EVMaximumCurrentLimit.Unit = A_DIN70121;
  1738. shm_msg->EVMaximumCurrentLimit.Value = (short) exi->EVMaximumCurrentLimit.Value;
  1739. sys->EvBatteryMaxCurrent = DIN70121PhyValDecode(shm_msg->EVMaximumCurrentLimit);
  1740. //[BODY (5/10)] EVMaximumPowerLimit
  1741. shm_msg->EVMaximumPowerLimit.Multiplier = (int) exi->EVMaximumPowerLimit.Multiplier;
  1742. //shm_msg->EVMaximumPowerLimit.Unit = (unsigned char) exi->EVMaximumPowerLimit.Unit;
  1743. shm_msg->EVMaximumPowerLimit.Unit = W_DIN70121;
  1744. shm_msg->EVMaximumPowerLimit.Value = (short) exi->EVMaximumPowerLimit.Value;
  1745. sys->EvBatteryMaxPower = DIN70121PhyValDecode(shm_msg->EVMaximumPowerLimit);
  1746. //[BODY (6/10)] BulkChargingComplete
  1747. shm_msg->BulkChargingComplete = (BOOL) exi->BulkChargingComplete;
  1748. //[BODY (7/10)] ChargingComplete
  1749. shm_msg->ChargingComplete = (BOOL) exi->ChargingComplete;
  1750. //[BODY (8/10)] RemainingTimeToFullSoC
  1751. shm_msg->RemainingTimeToFullSoC.Multiplier = (int) exi->RemainingTimeToFullSoC.Multiplier;
  1752. shm_msg->RemainingTimeToFullSoC.Unit = (unsigned char) exi->RemainingTimeToFullSoC.Unit;
  1753. shm_msg->RemainingTimeToFullSoC.Value = (short) exi->RemainingTimeToFullSoC.Value;
  1754. sys->RemainChargingDuration = DIN70121PhyValDecode(shm_msg->RemainingTimeToFullSoC);
  1755. //[BODY (9/10)] RemainingTimeToBulkSoC
  1756. shm_msg->RemainingTimeToBulkSoC.Multiplier = (int) exi->RemainingTimeToBulkSoC.Multiplier;
  1757. shm_msg->RemainingTimeToBulkSoC.Unit = (unsigned char) exi->RemainingTimeToBulkSoC.Unit;
  1758. shm_msg->RemainingTimeToBulkSoC.Value = (short) exi->RemainingTimeToBulkSoC.Value;
  1759. //[BODY (10/10)] EVTargetVoltage
  1760. shm_msg->EVTargetVoltage.Multiplier = (int) exi->EVTargetVoltage.Multiplier;
  1761. //shm_msg->EVTargetVoltage.Unit = (unsigned char) exi->EVTargetVoltage.Unit;
  1762. shm_msg->EVTargetVoltage.Unit = V_DIN70121;
  1763. shm_msg->EVTargetVoltage.Value = (short) exi->EVTargetVoltage.Value;
  1764. if((shm_msg->EVTargetVoltage.Value != 0) && (sys->EvBatteryMaxVoltage != 0))
  1765. {
  1766. sys->EvBatterytargetVoltage = (DIN70121PhyValDecode(shm_msg->EVTargetVoltage) + sys->EvBatteryMaxVoltage)/2;
  1767. }
  1768. else
  1769. {
  1770. sys->EvBatterytargetVoltage = DIN70121PhyValDecode(shm_msg->EVTargetVoltage);
  1771. }
  1772. #if MANUAL_SET_EV_TARGET_FUNCTION == ENABLE
  1773. sys->EvBatterytargetVoltage = SUDO_EV_TARGET_VOLTAGE; //for test (500V, unit: 1V)
  1774. #endif
  1775. }
  1776. /*===========================================================================
  1777. FUNCTION: SHM_Save_iso1_CurrentDemandReq
  1778. DESCRIPTION:
  1779. PRE-CONDITION:
  1780. INPUT:
  1781. OUTPUT:
  1782. GLOBAL VARIABLES:
  1783. =============================================================================*/
  1784. void SHM_Save_iso1_CurrentDemandReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1785. {
  1786. // ======== [STEP 1/3] Initialize ========
  1787. //int i = 0;
  1788. struct CurrentDemandRequest_ISO15118_2014 *shm_msg;
  1789. struct iso1CurrentDemandReqType *exi;
  1790. struct ChargingInfoData *sys;
  1791. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.CurrentDemandRequest;
  1792. exi = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq;
  1793. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1794. // ======== [STEP 2/3] Update Flags ========
  1795. // ======== [STEP 3/3] Transfer Data ========
  1796. //SHM_Save_iso1_V2GMSG_Header(buf);
  1797. //[BODY (1/10)] DC_EVStatus
  1798. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1799. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1800. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1801. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1802. //[BODY (2/10)] EVTargetCurrent
  1803. shm_msg->EVTargetCurrent.Multiplier = (int) exi->EVTargetCurrent.Multiplier;
  1804. //shm_msg->EVTargetCurrent.Unit = (unsigned char) exi->EVTargetCurrent.Unit;
  1805. shm_msg->EVTargetCurrent.Unit = A_ISO15118_2014;
  1806. shm_msg->EVTargetCurrent.Value = (short) exi->EVTargetCurrent.Value;
  1807. if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_ENERGY_TRANSFER) //3 (Precharge Relay OFF, DC+ Relay ON)
  1808. {
  1809. sys->EvBatterytargetCurrent = ISO151182014PhyValDecode(shm_msg->EVTargetCurrent);
  1810. #if MANUAL_SET_EV_TARGET_FUNCTION == ENABLE
  1811. sys->EvBatterytargetCurrent = SUDO_EV_TARGET_CURRENT; //60A, for test;
  1812. #endif
  1813. }
  1814. else if (sys->EVSEPrechargeStatus == EVSE_STATUS_READY_FOR_PRECHARGE) //2 (Precharge Relay ON, DC+ Relay OFF)
  1815. {
  1816. //sys->EvBatterytargetCurrent = PRECHARGE_TARGET_CURRENT; //2A, unit: 1A
  1817. sys->EvBatterytargetCurrent = ISO151182014PhyValDecode(shm_msg->EVTargetCurrent);
  1818. }
  1819. else //0 (Precharge Relay is still under preparing, not ON, yet.)
  1820. {
  1821. //sys->EvBatterytargetCurrent = 0; //0A
  1822. sys->EvBatterytargetCurrent = ISO151182014PhyValDecode(shm_msg->EVTargetCurrent);
  1823. }
  1824. //[BODY (3/10)] EVMaximumVoltageLimit
  1825. shm_msg->EVMaximumVoltageLimit.Multiplier = (int) exi->EVMaximumVoltageLimit.Multiplier;
  1826. //shm_msg->EVMaximumVoltageLimit.Unit = (unsigned char) exi->EVMaximumVoltageLimit.Unit;
  1827. shm_msg->EVMaximumVoltageLimit.Unit = V_ISO15118_2014;
  1828. shm_msg->EVMaximumVoltageLimit.Value = (short) exi->EVMaximumVoltageLimit.Value;
  1829. if (shm_msg->EVMaximumVoltageLimit.Value != 0 && exi->EVMaximumVoltageLimit_isUsed == 1u) //Gridwiz EVCC Emulator will not send EVMaximumVoltageLimit in CurrentDemandReq
  1830. {
  1831. sys->EvBatteryMaxVoltage = ISO151182014PhyValDecode(shm_msg->EVMaximumVoltageLimit);
  1832. }
  1833. /*
  1834. printf("[SeccComm] <V_ev_max> = %d, %d, %.02f\n",
  1835. exi->EVMaximumVoltageLimit.Value,
  1836. shm_msg->EVMaximumVoltageLimit.Value,
  1837. sys->EvBatteryMaxVoltage
  1838. );
  1839. */
  1840. //[BODY (4/10)] EVMaximumCurrentLimit
  1841. shm_msg->EVMaximumCurrentLimit.Multiplier = (int) exi->EVMaximumCurrentLimit.Multiplier;
  1842. //shm_msg->EVMaximumCurrentLimit.Unit = (unsigned char) exi->EVMaximumCurrentLimit.Unit;
  1843. shm_msg->EVMaximumCurrentLimit.Unit = A_ISO15118_2014;
  1844. shm_msg->EVMaximumCurrentLimit.Value = (short) exi->EVMaximumCurrentLimit.Value;
  1845. sys->EvBatteryMaxCurrent = ISO151182014PhyValDecode(shm_msg->EVMaximumCurrentLimit);
  1846. //[BODY (5/10)] EVMaximumPowerLimit
  1847. shm_msg->EVMaximumPowerLimit.Multiplier = (int) exi->EVMaximumPowerLimit.Multiplier;
  1848. //shm_msg->EVMaximumPowerLimit.Unit = (unsigned char) exi->EVMaximumPowerLimit.Unit;
  1849. shm_msg->EVMaximumPowerLimit.Unit = W_ISO15118_2014;
  1850. shm_msg->EVMaximumPowerLimit.Value = (short) exi->EVMaximumPowerLimit.Value;
  1851. sys->EvBatteryMaxPower = ISO151182014PhyValDecode(shm_msg->EVMaximumPowerLimit);
  1852. //[BODY (6/10)] BulkChargingComplete
  1853. shm_msg->BulkChargingComplete = (BOOL) exi->BulkChargingComplete;
  1854. //[BODY (7/10)] ChargingComplete
  1855. shm_msg->ChargingComplete = (BOOL) exi->ChargingComplete;
  1856. //[BODY (8/10)] RemainingTimeToFullSoC
  1857. shm_msg->RemainingTimeToFullSoC.Multiplier = (int) exi->RemainingTimeToFullSoC.Multiplier;
  1858. shm_msg->RemainingTimeToFullSoC.Unit = (unsigned char) exi->RemainingTimeToFullSoC.Unit;
  1859. shm_msg->RemainingTimeToFullSoC.Value = (short) exi->RemainingTimeToFullSoC.Value;
  1860. sys->RemainChargingDuration = ISO151182014PhyValDecode(shm_msg->RemainingTimeToFullSoC);
  1861. //[BODY (9/10)] RemainingTimeToBulkSoC
  1862. shm_msg->RemainingTimeToBulkSoC.Multiplier = (int) exi->RemainingTimeToBulkSoC.Multiplier;
  1863. shm_msg->RemainingTimeToBulkSoC.Unit = (unsigned char) exi->RemainingTimeToBulkSoC.Unit;
  1864. shm_msg->RemainingTimeToBulkSoC.Value = (short) exi->RemainingTimeToBulkSoC.Value;
  1865. //[BODY (10/10)] EVTargetVoltage
  1866. shm_msg->EVTargetVoltage.Multiplier = (int) exi->EVTargetVoltage.Multiplier;
  1867. //shm_msg->EVTargetVoltage.Unit = (unsigned char) exi->EVTargetVoltage.Unit;
  1868. shm_msg->EVTargetVoltage.Unit = V_ISO15118_2014;
  1869. shm_msg->EVTargetVoltage.Value = (short) exi->EVTargetVoltage.Value;
  1870. if((shm_msg->EVTargetVoltage.Value != 0) && (sys->EvBatteryMaxVoltage != 0))
  1871. {
  1872. sys->EvBatterytargetVoltage = (ISO151182014PhyValDecode(shm_msg->EVTargetVoltage) + sys->EvBatteryMaxVoltage)/2;
  1873. }
  1874. else
  1875. {
  1876. sys->EvBatterytargetVoltage = ISO151182014PhyValDecode(shm_msg->EVTargetVoltage);
  1877. }
  1878. /*
  1879. printf("[SeccComm] <V_ev_target> = %d, %d, %.02f\n",
  1880. exi->EVTargetVoltage.Value,
  1881. shm_msg->EVTargetVoltage.Value,
  1882. sys->EvBatterytargetVoltage
  1883. );
  1884. */
  1885. #if MANUAL_SET_EV_TARGET_FUNCTION == ENABLE
  1886. sys->EvBatterytargetVoltage = SUDO_EV_TARGET_VOLTAGE; //for test (500V, unit: 1V)
  1887. #endif
  1888. }
  1889. /*===========================================================================
  1890. FUNCTION: SHM_Save_iso1_ChargingStatusReq
  1891. DESCRIPTION:
  1892. PRE-CONDITION:
  1893. INPUT:
  1894. OUTPUT:
  1895. GLOBAL VARIABLES:
  1896. =============================================================================*/
  1897. void SHM_Save_iso1_ChargingStatusReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1898. {
  1899. //no content for ISO1
  1900. }
  1901. /*===========================================================================
  1902. FUNCTION: SHM_Save_din_WeldingDetectionReq
  1903. DESCRIPTION:
  1904. PRE-CONDITION:
  1905. INPUT:
  1906. OUTPUT:
  1907. GLOBAL VARIABLES:
  1908. =============================================================================*/
  1909. void SHM_Save_din_WeldingDetectionReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1910. {
  1911. // ======== [STEP 1/3] Initialize ========
  1912. //int i = 0;
  1913. struct WeldingDetectionRequest_DIN70121 *shm_msg;
  1914. struct dinWeldingDetectionReqType *exi;
  1915. struct ChargingInfoData *sys;
  1916. shm_msg = &shm_ccs->V2GMessage_DIN70121.WeldingDetectionRequest;
  1917. exi = &exi_doc_DIN->V2G_Message.Body.WeldingDetectionReq;
  1918. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1919. // ======== [STEP 2/3] Update Flags ========
  1920. // ======== [STEP 3/3] Transfer Data ========
  1921. //SHM_Save_din_V2GMSG_Header(buf);
  1922. //===== [BODY (1/3)] DC_EVStatus =====
  1923. //DC_EVStatus
  1924. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1925. shm_msg->DC_EVStatus.EVCabinConditioning = (BOOL) exi->DC_EVStatus.EVCabinConditioning;
  1926. shm_msg->DC_EVStatus.EVRESSConiditioning = (BOOL) exi->DC_EVStatus.EVRESSConditioning;
  1927. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1928. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1929. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1930. }
  1931. /*===========================================================================
  1932. FUNCTION: SHM_Save_iso1_WeldingDetectionReq
  1933. DESCRIPTION:
  1934. PRE-CONDITION:
  1935. INPUT:
  1936. OUTPUT:
  1937. GLOBAL VARIABLES:
  1938. =============================================================================*/
  1939. void SHM_Save_iso1_WeldingDetectionReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1940. {
  1941. // ======== [STEP 1/3] Initialize ========
  1942. //int i = 0;
  1943. struct WeldingDetectionRequest_ISO15118_2014 *shm_msg;
  1944. struct iso1WeldingDetectionReqType *exi;
  1945. struct ChargingInfoData *sys;
  1946. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.WeldingDetectionRequest;
  1947. exi = &exi_doc_ISO1->V2G_Message.Body.WeldingDetectionReq;
  1948. sys = &shm_sys->SysInfo.CcsChargingData[0];
  1949. // ======== [STEP 2/3] Update Flags ========
  1950. // ======== [STEP 3/3] Transfer Data ========
  1951. //SHM_Save_iso1_V2GMSG_Header(buf);
  1952. //===== [BODY (1/3)] DC_EVStatus =====
  1953. //DC_EVStatus
  1954. shm_msg->DC_EVStatus.EVReady = (BOOL) exi->DC_EVStatus.EVReady;
  1955. shm_msg->DC_EVStatus.EVErrorCode = (unsigned char) exi->DC_EVStatus.EVErrorCode;
  1956. shm_msg->DC_EVStatus.EVRESSSOC = (unsigned char) exi->DC_EVStatus.EVRESSSOC;
  1957. sys->EvBatterySoc = (int) shm_msg->DC_EVStatus.EVRESSSOC;
  1958. }
  1959. /*===========================================================================
  1960. FUNCTION: SHM_Save_din_SessionStopReq
  1961. DESCRIPTION:
  1962. PRE-CONDITION:
  1963. INPUT:
  1964. OUTPUT:
  1965. GLOBAL VARIABLES:
  1966. =============================================================================*/
  1967. void SHM_Save_din_SessionStopReq(struct CcsData *shm_ccs, struct dinEXIDocument *exi_doc_DIN, struct SysConfigAndInfo *shm_sys)
  1968. {
  1969. // ======== [STEP 1/3] Initialize ========
  1970. /*
  1971. int i = 0;
  1972. struct SessionStopRequest_DIN70121 *shm_msg;
  1973. struct dinSessionStopReqType *exi;
  1974. shm_msg = &shm_ccs->V2GMessage_DIN70121.SessionStopRequest;
  1975. exi = &exi_doc_DIN->V2G_Message.Body.SessionStopReq;
  1976. */
  1977. // ======== [STEP 2/3] Update Flags ========
  1978. // ======== [STEP 3/3] Transfer Data ========
  1979. //SHM_Save_din_V2GMSG_Header(buf);
  1980. //null
  1981. }
  1982. /*===========================================================================
  1983. FUNCTION: SHM_Save_iso1_SessionStopReq
  1984. DESCRIPTION:
  1985. PRE-CONDITION:
  1986. INPUT:
  1987. OUTPUT:
  1988. GLOBAL VARIABLES:
  1989. =============================================================================*/
  1990. void SHM_Save_iso1_SessionStopReq(struct CcsData *shm_ccs, struct iso1EXIDocument *exi_doc_ISO1, struct SysConfigAndInfo *shm_sys)
  1991. {
  1992. // ======== [STEP 1/3] Initialize ========
  1993. /*
  1994. int i = 0;
  1995. struct SessionStopRequest_ISO15118_2014 *shm_msg;
  1996. struct iso1SessionStopReqType *exi;
  1997. shm_msg = &shm_ccs->V2GMessage_ISO15118_2014.SessionStopRequest;
  1998. exi = &exi_doc_ISO1->V2G_Message.Body.SessionStopReq;
  1999. */
  2000. // ======== [STEP 2/3] Update Flags ========
  2001. // ======== [STEP 3/3] Transfer Data ========
  2002. //SHM_Save_iso1_V2GMSG_Header(buf);
  2003. //null
  2004. }
  2005. /*===========================================================================
  2006. FUNCTION: SHM_Read_din_SessionSetupRes
  2007. DESCRIPTION:
  2008. PRE-CONDITION:
  2009. INPUT:
  2010. 1. shm_ccs
  2011. OUTPUT:
  2012. 2. exi_doc_DIN
  2013. GLOBAL VARIABLES:
  2014. =============================================================================*/
  2015. void SHM_Read_din_SessionSetupRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2016. {
  2017. int i = 0;
  2018. struct dinSessionSetupResType *out;
  2019. struct SessionSetupResponse_DIN70121 *in;
  2020. out = &exi_doc_DIN->V2G_Message.Body.SessionSetupRes;
  2021. in = &shm_ccs->V2GMessage_DIN70121.SessionSetupResponse;
  2022. exi_doc_DIN->V2G_Message.Body.SessionSetupRes_isUsed = 1u;
  2023. // ====== [BODY (1/3) ResponseCode ======
  2024. out->ResponseCode = in->ResponseCode;
  2025. // ====== [BODY (2/3) EVSEID ======
  2026. out->EVSEID.bytesLen = 32; //max = 32 bytes(DIN), all zero
  2027. for (i = 0; i< 32; i++)
  2028. {
  2029. out->EVSEID.bytes[i] = (unsigned char) in->EVSEID[i];
  2030. }
  2031. // ====== [BODY (3/3) DateTimeNow ======
  2032. out->DateTimeNow_isUsed = 1u;
  2033. out->DateTimeNow = (int64_t) in->EVSETimeStamp; //Format: Unix Time Stamp
  2034. }
  2035. /*===========================================================================
  2036. FUNCTION: SHM_Read_din_ContractAuthenticationRes
  2037. DESCRIPTION:
  2038. PRE-CONDITION:
  2039. INPUT:
  2040. 1. shm_ccs
  2041. OUTPUT:
  2042. 2. exi_doc_DIN
  2043. GLOBAL VARIABLES:
  2044. =============================================================================*/
  2045. void SHM_Read_din_ContractAuthenticationRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2046. {
  2047. struct dinContractAuthenticationResType *out;
  2048. struct ContractAuthenticationResponse_DIN70121 *in;
  2049. out = &exi_doc_DIN->V2G_Message.Body.ContractAuthenticationRes;
  2050. in = &shm_ccs->V2GMessage_DIN70121.ContractAuthenticationResponse;
  2051. //[BODY (2/2)] EVSEProcessing
  2052. out->EVSEProcessing = (BOOL)in->EVSEProcessing; //0(Finished) or 1(Ongoing)
  2053. }
  2054. /*===========================================================================
  2055. FUNCTION: SHM_Read_din_ChargeParameterDiscoveryRes
  2056. DESCRIPTION:
  2057. PRE-CONDITION:
  2058. INPUT:
  2059. 1. shm_ccs
  2060. OUTPUT:
  2061. 2. exi_doc_DIN
  2062. GLOBAL VARIABLES:
  2063. =============================================================================*/
  2064. void SHM_Read_din_ChargeParameterDiscoveryRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2065. {
  2066. struct dinChargeParameterDiscoveryResType *out;
  2067. struct ChargeParameterDiscoveryResponse_DIN70121 *in;
  2068. out = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryRes;
  2069. in = &shm_ccs->V2GMessage_DIN70121.ChargeParameterDiscoveryResponse;
  2070. //Initialize
  2071. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2072. init_dinChargeParameterDiscoveryResType(out);
  2073. exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryRes_isUsed = 1u;
  2074. //----- [BODY (1/5)] ResponseCode -----
  2075. out->ResponseCode = (unsigned char) in->ResponseCode;
  2076. //----- [BODY (2/5)] EVSEProcessing -----
  2077. out->EVSEProcessing = (BOOL) in->EVSEProcessing;
  2078. // dinEVSEProcessingType_Finished = 0,
  2079. // dinEVSEProcessingType_Ongoing = 1
  2080. //----- [BODY (3/5)] SAScheduleList of SASchedules -----
  2081. //[Joseph] Here keep constant values and not copy from share memory, yet.
  2082. out->SAScheduleList_isUsed = 1u;
  2083. struct dinSAScheduleListType *list;
  2084. list = &out->SAScheduleList;
  2085. //
  2086. list->SAScheduleTuple.arrayLen = 1;
  2087. list->SAScheduleTuple.array[0].SAScheduleTupleID = 0;
  2088. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleID = 0;
  2089. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.arrayLen = 1;
  2090. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval_isUsed = 1u;
  2091. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.start = 0;
  2092. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.duration = 86400; //24Hrs at least, unit:second
  2093. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.duration_isUsed = 1u;
  2094. /*+++ 20200808, vern, add Pmax parameters in chargeParameters discovery +++*/
  2095. in->DC_EVSEChargeParameter.EVSEMaximumPowerLimit.Value*=10;
  2096. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].PMax = in->DC_EVSEChargeParameter.EVSEMaximumPowerLimit.Value;
  2097. /*--- 20200808, vern, add Pmax parameters in chargeParameters discovery ---*/
  2098. //list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].TimeInterval_isUsed = 1u;
  2099. //list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].TimeInterval = 600;
  2100. //list->SAScheduleTuple.array[0].SalesTariff.xxx
  2101. //list->SAScheduleTuple.array[0].SalesTariff_isUsed = 0u;
  2102. //----- [BODY (4/5)] AC_EVSEChargeParameter of EVSEChargeParameter -----
  2103. //ignore, since DIN doesn't support AC
  2104. //----- [BODY (5/5)] DC_EVSEChargeParameter of EVSEChargeParameter -----
  2105. out->DC_EVSEChargeParameter_isUsed = 1u;
  2106. struct dinDC_EVSEChargeParameterType *out_dc_para;
  2107. struct DC_EVSEChargeParameterType_DIN70121 *in_dc_para;
  2108. out_dc_para = &out->DC_EVSEChargeParameter;
  2109. in_dc_para = &in->DC_EVSEChargeParameter;
  2110. //DC_EVSEStatus
  2111. out_dc_para->DC_EVSEStatus.EVSEIsolationStatus_isUsed = 1u;
  2112. SHM_Read_dinDC_EVSEStatusType(&out_dc_para->DC_EVSEStatus, &in_dc_para->DC_EVSEStatus);
  2113. //EVSEMaximumCurrentLimit
  2114. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEMaximumCurrentLimit, &in_dc_para->EVSEMaximumCurrentLimit);
  2115. //EVSEMaximumPowerLimit
  2116. out_dc_para->EVSEMaximumPowerLimit_isUsed = 1u;
  2117. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEMaximumPowerLimit, &in_dc_para->EVSEMaximumPowerLimit);
  2118. //EVSEMaximumVoltageLimit
  2119. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEMaximumVoltageLimit, &in_dc_para->EVSEMaximumVoltageLimit);
  2120. //EVSEMinimumVoltageLimit
  2121. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEMinimumVoltageLimit, &in_dc_para->EVSEMinimumVoltageLimit);
  2122. //EVSEMinimumCurrentLimit
  2123. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEMinimumCurrentLimit, &in_dc_para->EVSEMinimumCurrentLimit);
  2124. //EVSECurrentRegulationTolerance_isUsed
  2125. out_dc_para->EVSECurrentRegulationTolerance_isUsed = 1u;
  2126. //EVSECurrentRegulationTolerance
  2127. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSECurrentRegulationTolerance, &in_dc_para->EVSECurrentRegulationTolerance);
  2128. //EVSEEnergyToBeDelivered_isUsed
  2129. out_dc_para->EVSEEnergyToBeDelivered_isUsed = 0u;
  2130. //EVSEEnergyToBeDelivered (optional)
  2131. //SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEEnergyToBeDelivered, &in_dc_para->EVSEEnergyToBeDelivered);
  2132. //EVSEPeakCurrentRipple
  2133. SHM_Read_dinPhysicalValueType(&out_dc_para->EVSEPeakCurrentRipple, &in_dc_para->EVSEPeakCurrentRipple);
  2134. }
  2135. /*===========================================================================
  2136. FUNCTION: SHM_Read_iso1_ChargeParameterDiscoveryRes
  2137. DESCRIPTION:
  2138. PRE-CONDITION:
  2139. INPUT:
  2140. 1. shm_ccs
  2141. OUTPUT:
  2142. 2. exi_doc_ISO1
  2143. GLOBAL VARIABLES:
  2144. =============================================================================*/
  2145. void SHM_Read_iso1_ChargeParameterDiscoveryRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2146. {
  2147. struct iso1ChargeParameterDiscoveryResType *out;
  2148. struct ChargeParameterDiscoveryResponse_ISO15118_2014 *in;
  2149. out = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryRes;
  2150. in = &shm_ccs->V2GMessage_ISO15118_2014.ChargeParameterDiscoveryResponse;
  2151. //Initialize
  2152. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2153. init_iso1ChargeParameterDiscoveryResType(out);
  2154. exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryRes_isUsed = 1u;
  2155. //----- [BODY (1/5)] ResponseCode -----
  2156. out->ResponseCode = (unsigned char) in->ResponseCode;
  2157. //----- [BODY (2/5)] EVSEProcessing -----
  2158. out->EVSEProcessing = (BOOL) in->EVSEProcessing;
  2159. // iso1EVSEProcessingType_Finished = 0,
  2160. // iso1EVSEProcessingType_Ongoing = 1
  2161. //----- [BODY (3/5)] SAScheduleList of SASchedules -----
  2162. //[Joseph] Here keep constant values and not copy from share memory, yet.
  2163. out->SAScheduleList_isUsed = 1u;
  2164. struct iso1SAScheduleListType *list;
  2165. list = &out->SAScheduleList;
  2166. //
  2167. list->SAScheduleTuple.arrayLen = 1;
  2168. list->SAScheduleTuple.array[0].SAScheduleTupleID = 0;
  2169. //list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleID = 0;
  2170. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.arrayLen = 1;
  2171. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval_isUsed = 1u;
  2172. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.start = 0;
  2173. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.duration = 86400; //24Hrs at least, unit:second
  2174. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].RelativeTimeInterval.duration_isUsed = 1u;
  2175. //list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].TimeInterval_isUsed = 1u;
  2176. //list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].TimeInterval = 86400;
  2177. /*+++ 20200808, vern, add Pmax parameters in chargeParameters discovery +++*/
  2178. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].PMax.Unit = iso1unitSymbolType_W; //iso1unitSymbolType_W
  2179. in->DC_EVSEChargeParameter.EVSEMaximumPowerLimit.Value*=10; /*+++ 20200808, vern, lack one more 0 ---*/
  2180. list->SAScheduleTuple.array[0].PMaxSchedule.PMaxScheduleEntry.array[0].PMax.Value =in->DC_EVSEChargeParameter.EVSEMaximumPowerLimit.Value; //30000 if DW/DM product
  2181. /*--- 20200808, vern, add Pmax parameters in chargeParameters discovery ---*/
  2182. //list->SAScheduleTuple.array[0].SalesTariff.xxx
  2183. //list->SAScheduleTuple.array[0].SalesTariff_isUsed = 0u;
  2184. //----- [BODY (4/5)] AC/DC EVSEChargeParameter -----
  2185. #if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) | (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
  2186. {
  2187. //----- [BODY (4/5)] AC_EVSEChargeParameter -----
  2188. out->AC_EVSEChargeParameter_isUsed = 1u;
  2189. struct iso1AC_EVSEChargeParameterType *out_ac_para;
  2190. struct AC_EVSEChargeParameterType_ISO15118_2014 *in_ac_para;
  2191. out_ac_para = &out->AC_EVSEChargeParameter;
  2192. in_ac_para = &in->AC_EVSEChargeParameter;
  2193. //[1/3] AC_EVSEStatus
  2194. SHM_Read_iso1AC_EVSEStatusType(&out_ac_para->AC_EVSEStatus, &in_ac_para->AC_EVSEStatus);
  2195. //[2/3] EVSENominalVoltage
  2196. SHM_Read_iso1PhysicalValueType(&out_ac_para->EVSENominalVoltage, &in_ac_para->EVSENominalVoltage);
  2197. //[3/3] EVSEMaxCurrent
  2198. SHM_Read_iso1PhysicalValueType(&out_ac_para->EVSEMaxCurrent, &in_ac_para->EVSEMaxCurrent);
  2199. }
  2200. #else //CCS_ENERGY_TRANSFER_MODE == MODE_DC_EXTENDED
  2201. {
  2202. //----- [BODY (5/5)] DC_EVSEChargeParameter -----
  2203. out->DC_EVSEChargeParameter_isUsed = 1u;
  2204. struct iso1DC_EVSEChargeParameterType *out_dc_para;
  2205. struct DC_EVSEChargeParameterType_ISO15118_2014 *in_dc_para;
  2206. out_dc_para = &out->DC_EVSEChargeParameter;
  2207. in_dc_para = &in->DC_EVSEChargeParameter;
  2208. //DC_EVSEStatus
  2209. out_dc_para->DC_EVSEStatus.EVSEIsolationStatus_isUsed = 1u;
  2210. SHM_Read_iso1DC_EVSEStatusType(&out_dc_para->DC_EVSEStatus, &in_dc_para->DC_EVSEStatus);
  2211. //EVSEMaximumCurrentLimit
  2212. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEMaximumCurrentLimit, &in_dc_para->EVSEMaximumCurrentLimit);
  2213. //EVSEMaximumPowerLimit
  2214. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEMaximumPowerLimit, &in_dc_para->EVSEMaximumPowerLimit);
  2215. //EVSEMaximumVoltageLimit
  2216. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEMaximumVoltageLimit, &in_dc_para->EVSEMaximumVoltageLimit);
  2217. //EVSEMinimumVoltageLimit
  2218. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEMinimumVoltageLimit, &in_dc_para->EVSEMinimumVoltageLimit);
  2219. //EVSEMinimumCurrentLimit
  2220. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEMinimumCurrentLimit, &in_dc_para->EVSEMinimumCurrentLimit);
  2221. //EVSECurrentRegulationTolerance_isUsed
  2222. out_dc_para->EVSECurrentRegulationTolerance_isUsed = 1u;
  2223. //EVSECurrentRegulationTolerance
  2224. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSECurrentRegulationTolerance, &in_dc_para->EVSECurrentRegulationTolerance);
  2225. //EVSEEnergyToBeDelivered_isUsed
  2226. out_dc_para->EVSEEnergyToBeDelivered_isUsed = 0u;
  2227. //EVSEEnergyToBeDelivered (optional)
  2228. //SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEEnergyToBeDelivered, &in_dc_para->EVSEEnergyToBeDelivered);
  2229. //EVSEPeakCurrentRipple
  2230. SHM_Read_iso1PhysicalValueType(&out_dc_para->EVSEPeakCurrentRipple, &in_dc_para->EVSEPeakCurrentRipple);
  2231. }
  2232. #endif
  2233. }
  2234. /*===========================================================================
  2235. FUNCTION: SHM_Read_din_CableCheckRes
  2236. DESCRIPTION:
  2237. PRE-CONDITION:
  2238. INPUT:
  2239. 1. shm_ccs
  2240. OUTPUT:
  2241. 2. exi_doc_DIN
  2242. GLOBAL VARIABLES:
  2243. =============================================================================*/
  2244. void SHM_Read_din_CableCheckRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2245. {
  2246. struct dinCableCheckResType *out;
  2247. struct CableCheckResponse_DIN70121 *in;
  2248. out = &exi_doc_DIN->V2G_Message.Body.CableCheckRes;
  2249. in = &shm_ccs->V2GMessage_DIN70121.CableCheckResponse;
  2250. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2251. init_dinCableCheckResType(out);
  2252. exi_doc_DIN->V2G_Message.Body.CableCheckRes_isUsed = 1u;
  2253. //----- [BODY (1/3)] ResponseCode -----
  2254. out->ResponseCode = (unsigned char) in->ResponseCode;
  2255. //----- [BODY (2/3)] EVSEProcessing -----
  2256. out->EVSEProcessing = (BOOL) in->EVSEProcessing;
  2257. // dinEVSEProcessingType_Finished = 0,
  2258. // dinEVSEProcessingType_Ongoing = 1
  2259. //----- [BODY (3/3)] DC_EVSEStatus -----
  2260. SHM_Read_dinDC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2261. }
  2262. /*===========================================================================
  2263. FUNCTION: SHM_Read_iso1_CableCheckRes
  2264. DESCRIPTION:
  2265. PRE-CONDITION:
  2266. INPUT:
  2267. 1. shm_ccs
  2268. OUTPUT:
  2269. 2. exi_doc_ISO1
  2270. GLOBAL VARIABLES:
  2271. =============================================================================*/
  2272. void SHM_Read_iso1_CableCheckRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2273. {
  2274. struct iso1CableCheckResType *out;
  2275. struct CableCheckResponse_ISO15118_2014 *in;
  2276. out = &exi_doc_ISO1->V2G_Message.Body.CableCheckRes;
  2277. in = &shm_ccs->V2GMessage_ISO15118_2014.CableCheckResponse;
  2278. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2279. init_iso1CableCheckResType(out);
  2280. exi_doc_ISO1->V2G_Message.Body.CableCheckRes_isUsed = 1u;
  2281. //----- [BODY (1/3)] ResponseCode -----
  2282. out->ResponseCode = (unsigned char) in->ResponseCode;
  2283. //----- [BODY (2/3)] EVSEProcessing -----
  2284. out->EVSEProcessing = (BOOL) in->EVSEProcessing;
  2285. // iso1EVSEProcessingType_Finished = 0,
  2286. // iso1EVSEProcessingType_Ongoing = 1
  2287. //----- [BODY (3/3)] DC_EVSEStatus -----
  2288. SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2289. }
  2290. /*===========================================================================
  2291. FUNCTION: SHM_Read_din_PreChargeRes
  2292. DESCRIPTION:
  2293. PRE-CONDITION:
  2294. INPUT:
  2295. 1. shm_ccs
  2296. OUTPUT:
  2297. 2. exi_doc_DIN
  2298. GLOBAL VARIABLES:
  2299. =============================================================================*/
  2300. void SHM_Read_din_PreChargeRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2301. {
  2302. struct dinPreChargeResType *out;
  2303. struct PreChargeResponse_DIN70121 *in;
  2304. out = &exi_doc_DIN->V2G_Message.Body.PreChargeRes;
  2305. in = &shm_ccs->V2GMessage_DIN70121.PreChargeResponse;
  2306. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2307. init_dinPreChargeResType(&exi_doc_DIN->V2G_Message.Body.PreChargeRes);
  2308. exi_doc_DIN->V2G_Message.Body.PreChargeRes_isUsed = 1u;
  2309. //----- [BODY (1/3)] ResponseCode -----
  2310. out->ResponseCode = (unsigned char) in->ResponseCode;
  2311. //----- [BODY (2/3)] EVSEPresentVoltage -----
  2312. SHM_Read_dinPhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2313. // dinunitSymbolType_h = 0,
  2314. // dinunitSymbolType_m = 1,
  2315. // dinunitSymbolType_s = 2,
  2316. // dinunitSymbolType_A = 3,
  2317. // dinunitSymbolType_Ah = 4,
  2318. // dinunitSymbolType_V = 5,
  2319. // dinunitSymbolType_VA = 6,
  2320. // dinunitSymbolType_W = 7,
  2321. // dinunitSymbolType_W_s = 8,
  2322. // dinunitSymbolType_Wh = 9
  2323. //----- [BODY (3/3)] DC_EVSEStatus -----
  2324. SHM_Read_dinDC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2325. }
  2326. /*===========================================================================
  2327. FUNCTION: SHM_Read_iso1_PreChargeRes
  2328. DESCRIPTION:
  2329. PRE-CONDITION:
  2330. INPUT:
  2331. 1. shm_ccs
  2332. OUTPUT:
  2333. 2. exi_doc_ISO1
  2334. GLOBAL VARIABLES:
  2335. =============================================================================*/
  2336. void SHM_Read_iso1_PreChargeRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2337. {
  2338. struct iso1PreChargeResType *out;
  2339. struct PreChargeResponse_ISO15118_2014 *in;
  2340. out = &exi_doc_ISO1->V2G_Message.Body.PreChargeRes;
  2341. in = &shm_ccs->V2GMessage_ISO15118_2014.PreChargeResponse;
  2342. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2343. init_iso1PreChargeResType(&exi_doc_ISO1->V2G_Message.Body.PreChargeRes);
  2344. exi_doc_ISO1->V2G_Message.Body.PreChargeRes_isUsed = 1u;
  2345. //----- [BODY (1/3)] ResponseCode -----
  2346. out->ResponseCode = (unsigned char) in->ResponseCode;
  2347. //----- [BODY (2/3)] EVSEPresentVoltage -----
  2348. SHM_Read_iso1PhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2349. //iso1unitSymbolType_h = 0,
  2350. //iso1unitSymbolType_m = 1,
  2351. //iso1unitSymbolType_s = 2,
  2352. //iso1unitSymbolType_A = 3,
  2353. //iso1unitSymbolType_V = 4,
  2354. //iso1unitSymbolType_W = 5,
  2355. //iso1unitSymbolType_Wh = 6
  2356. //----- [BODY (3/3)] DC_EVSEStatus -----
  2357. SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2358. }
  2359. /*===========================================================================
  2360. FUNCTION: SHM_Read_din_PowerDeliveryRes
  2361. DESCRIPTION:
  2362. PRE-CONDITION:
  2363. INPUT:
  2364. 1. shm_ccs
  2365. OUTPUT:
  2366. 2. exi_doc_DIN
  2367. GLOBAL VARIABLES:
  2368. =============================================================================*/
  2369. void SHM_Read_din_PowerDeliveryRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2370. {
  2371. struct dinPowerDeliveryResType *out;
  2372. struct PowerDeliveryResponse_DIN70121 *in;
  2373. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2374. init_dinPowerDeliveryResType(&exi_doc_DIN->V2G_Message.Body.PowerDeliveryRes);
  2375. out = &exi_doc_DIN->V2G_Message.Body.PowerDeliveryRes;
  2376. in = &shm_ccs->V2GMessage_DIN70121.PowerDeliveryResponse;
  2377. exi_doc_DIN->V2G_Message.Body.PowerDeliveryRes_isUsed = 1u;
  2378. //----- [BODY (1/3)] ResponseCode -----
  2379. out->ResponseCode = (unsigned char) in->ResponseCode;
  2380. //----- [BODY (2/3)] AC_EVSEStatus -----
  2381. //ignore, since DIN 70121 doesn't support AC, yet.
  2382. //----- [BODY (2/3)] DC_EVSEStatus -----
  2383. out->DC_EVSEStatus_isUsed = 1u;
  2384. SHM_Read_dinDC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2385. }
  2386. /*===========================================================================
  2387. FUNCTION: SHM_Read_iso1_PowerDeliveryRes
  2388. DESCRIPTION:
  2389. PRE-CONDITION:
  2390. INPUT:
  2391. 1. shm_ccs
  2392. OUTPUT:
  2393. 2. exi_doc_ISO1
  2394. GLOBAL VARIABLES:
  2395. =============================================================================*/
  2396. void SHM_Read_iso1_PowerDeliveryRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2397. {
  2398. struct iso1PowerDeliveryResType *out;
  2399. struct PowerDeliveryResponse_ISO15118_2014 *in;
  2400. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2401. init_iso1PowerDeliveryResType(&exi_doc_ISO1->V2G_Message.Body.PowerDeliveryRes);
  2402. out = &exi_doc_ISO1->V2G_Message.Body.PowerDeliveryRes;
  2403. in = &shm_ccs->V2GMessage_ISO15118_2014.PowerDeliveryResponse;
  2404. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryRes_isUsed = 1u;
  2405. //----- [BODY (1/3)] ResponseCode -----
  2406. out->ResponseCode = (unsigned char) in->ResponseCode;
  2407. //----- [BODY (2/3)] AC_EVSEStatus -----
  2408. //ignore, since our ISO1 70121 doesn't support AC, yet.
  2409. //----- [BODY (2/3)] DC_EVSEStatus -----
  2410. #if ((CCS_ENERGY_TRANSFER_MODE == MODE_AC_SINGLE_PHASE_CORE) | (CCS_ENERGY_TRANSFER_MODE == MODE_AC_THREE_PHASE_CORE))
  2411. {
  2412. //out->DC_EVSEStatus_isUsed = 0u;
  2413. }
  2414. #else //CCS_ENERGY_TRANSFER_MODE == MODE_DC_EXTENDED
  2415. {
  2416. out->DC_EVSEStatus_isUsed = 1u;
  2417. SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2418. }
  2419. #endif
  2420. }
  2421. /*===========================================================================
  2422. FUNCTION: SHM_Read_din_CurrentDemandRes
  2423. DESCRIPTION:
  2424. PRE-CONDITION:
  2425. INPUT:
  2426. 1. shm_ccs
  2427. OUTPUT:
  2428. 2. exi_doc_DIN
  2429. GLOBAL VARIABLES:
  2430. =============================================================================*/
  2431. void SHM_Read_din_CurrentDemandRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2432. {
  2433. struct dinCurrentDemandResType *out;
  2434. struct CurrentDemandResponse_DIN70121 *in;
  2435. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2436. init_dinCurrentDemandResType(&exi_doc_DIN->V2G_Message.Body.CurrentDemandRes);
  2437. out = &exi_doc_DIN->V2G_Message.Body.CurrentDemandRes;
  2438. in = &shm_ccs->V2GMessage_DIN70121.CurrentDemandResponse;
  2439. exi_doc_DIN->V2G_Message.Body.CurrentDemandRes_isUsed = 1u;
  2440. //----- [BODY (1/10)] ResponseCode -----
  2441. out->ResponseCode = (unsigned char) in->ResponseCode;
  2442. //----- [BODY (2/10)] DC_EVSEStatus -----
  2443. SHM_Read_dinDC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2444. //----- [BODY (3/10)] EVSEPresentVoltage -----
  2445. SHM_Read_dinPhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2446. //----- [BODY (4/10)] EVSEPresentCurrent -----
  2447. SHM_Read_dinPhysicalValueType(&out->EVSEPresentCurrent, &in->EVSEPresentCurrent);
  2448. //----- [BODY (5/10)] EVSECurrentLimitAchieved -----
  2449. out->EVSECurrentLimitAchieved = in->EVSECurrentLimitAchieved;
  2450. //----- [BODY (6/10)] EVSEVoltageLimitAchieved -----
  2451. out->EVSEVoltageLimitAchieved = in->EVSEVoltageLimitAchieved;
  2452. //----- [BODY (7/10)] EVSEPowerLimitAchieved -----
  2453. out->EVSEPowerLimitAchieved = in->EVSEPowerLimitAchieved;
  2454. //----- [BODY (8/10)] EVSEMaximumVoltageLimit -----
  2455. out->EVSEMaximumVoltageLimit_isUsed = 1u;
  2456. SHM_Read_dinPhysicalValueType(&out->EVSEMaximumVoltageLimit, &in->EVSEMaximumVoltageLimit);
  2457. //----- [BODY (9/10)] EVSEMaximumCurrentLimit -----
  2458. out->EVSEMaximumCurrentLimit_isUsed = 1u;
  2459. SHM_Read_dinPhysicalValueType(&out->EVSEMaximumCurrentLimit, &in->EVSEMaximumCurrentLimit);
  2460. //----- [BODY (10/10)] EVSEMaximumPowerLimit -----
  2461. out->EVSEMaximumPowerLimit_isUsed = 1u;
  2462. SHM_Read_dinPhysicalValueType(&out->EVSEMaximumPowerLimit, &in->EVSEMaximumPowerLimit);
  2463. }
  2464. /*===========================================================================
  2465. FUNCTION: SHM_Read_iso1_CurrentDemandRes
  2466. DESCRIPTION:
  2467. PRE-CONDITION:
  2468. INPUT:
  2469. 1. shm_ccs
  2470. OUTPUT:
  2471. 2. exi_doc_ISO1
  2472. GLOBAL VARIABLES:
  2473. =============================================================================*/
  2474. void SHM_Read_iso1_CurrentDemandRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2475. {
  2476. struct iso1CurrentDemandResType *out;
  2477. struct CurrentDemandResponse_ISO15118_2014 *in;
  2478. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2479. init_iso1CurrentDemandResType(&exi_doc_ISO1->V2G_Message.Body.CurrentDemandRes);
  2480. out = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandRes;
  2481. in = &shm_ccs->V2GMessage_ISO15118_2014.CurrentDemandResponse;
  2482. exi_doc_ISO1->V2G_Message.Body.CurrentDemandRes_isUsed = 1u;
  2483. //vern, fill up necessary
  2484. out->EVSEID.charactersLen=7;
  2485. out->EVSEID.characters[0]='Z';
  2486. out->EVSEID.characters[1]='Z';
  2487. out->EVSEID.characters[2]='0';
  2488. out->EVSEID.characters[3]='0';
  2489. out->EVSEID.characters[4]='0';
  2490. out->EVSEID.characters[5]='0';
  2491. out->EVSEID.characters[6]='0';
  2492. out->SAScheduleTupleID=1;
  2493. out->MeterInfo_isUsed=0u;
  2494. out->ReceiptRequired_isUsed=0u;
  2495. //----- [BODY (1/10)] ResponseCode -----
  2496. out->ResponseCode = (unsigned char) in->ResponseCode;
  2497. //----- [BODY (2/10)] DC_EVSEStatus -----
  2498. SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2499. //----- [BODY (3/10)] EVSEPresentVoltage -----
  2500. SHM_Read_iso1PhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2501. //----- [BODY (4/10)] EVSEPresentCurrent -----
  2502. SHM_Read_iso1PhysicalValueType(&out->EVSEPresentCurrent, &in->EVSEPresentCurrent);
  2503. //----- [BODY (5/10)] EVSECurrentLimitAchieved -----
  2504. out->EVSECurrentLimitAchieved = in->EVSECurrentLimitAchieved;
  2505. //----- [BODY (6/10)] EVSEVoltageLimitAchieved -----
  2506. out->EVSEVoltageLimitAchieved = in->EVSEVoltageLimitAchieved;
  2507. //----- [BODY (7/10)] EVSEPowerLimitAchieved -----
  2508. out->EVSEPowerLimitAchieved = in->EVSEPowerLimitAchieved;
  2509. //----- [BODY (8/10)] EVSEMaximumVoltageLimit -----
  2510. out->EVSEMaximumVoltageLimit_isUsed = 1u;
  2511. SHM_Read_iso1PhysicalValueType(&out->EVSEMaximumVoltageLimit, &in->EVSEMaximumVoltageLimit);
  2512. //----- [BODY (9/10)] EVSEMaximumCurrentLimit -----
  2513. out->EVSEMaximumCurrentLimit_isUsed = 1u;
  2514. SHM_Read_iso1PhysicalValueType(&out->EVSEMaximumCurrentLimit, &in->EVSEMaximumCurrentLimit);
  2515. //----- [BODY (10/10)] EVSEMaximumPowerLimit -----
  2516. out->EVSEMaximumPowerLimit_isUsed = 1u;
  2517. SHM_Read_iso1PhysicalValueType(&out->EVSEMaximumPowerLimit, &in->EVSEMaximumPowerLimit);
  2518. }
  2519. /*===========================================================================
  2520. FUNCTION: SHM_Read_iso1_ChargingStatusRes
  2521. DESCRIPTION:
  2522. PRE-CONDITION:
  2523. INPUT:
  2524. 1. shm_ccs
  2525. OUTPUT:
  2526. 2. exi_doc_ISO1
  2527. GLOBAL VARIABLES:
  2528. =============================================================================*/
  2529. void SHM_Read_iso1_ChargingStatusRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2530. {
  2531. int i = 0;
  2532. struct iso1ChargingStatusResType *out;
  2533. struct ChargingStatusResponse_ISO15118_2014 *in;
  2534. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2535. init_iso1ChargingStatusResType(&exi_doc_ISO1->V2G_Message.Body.ChargingStatusRes);
  2536. out = &exi_doc_ISO1->V2G_Message.Body.ChargingStatusRes;
  2537. in = &shm_ccs->V2GMessage_ISO15118_2014.ChargingStatusResponse;
  2538. exi_doc_ISO1->V2G_Message.Body.ChargingStatusRes_isUsed = 1u;
  2539. //----- [BODY (1/10)] ResponseCode -----
  2540. out->ResponseCode = (unsigned char)in->ResponseCode;
  2541. //----- [BODY (2/10)] AC_EVSEStatus -----
  2542. SHM_Read_iso1AC_EVSEStatusType(&out->AC_EVSEStatus, &in->AC_EVSEStatus);
  2543. //----- [BODY (3/10)] EVSEMaxCurrent -----
  2544. out->EVSEMaxCurrent_isUsed = 1u;
  2545. SHM_Read_iso1PhysicalValueType(&out->EVSEMaxCurrent, &in->EVSEMaxCurrent);
  2546. //----- [BODY (4/10)] SAScheduleTupleID -----
  2547. out->SAScheduleTupleID = (unsigned char)in->SAScheduleTupleID; //[CAUTION] data type
  2548. //----- [BODY (5/10)] EVSEID -----
  2549. out->EVSEID.charactersLen = 37; //min length: 7, max length:37 bytes(ISO1, AC)
  2550. for (i = 0; i< out->EVSEID.charactersLen; i++)
  2551. {
  2552. out->EVSEID.characters[i] = (unsigned char)in->EVSEID[i];
  2553. }
  2554. //----- [BODY (6/10)] MeterInfo -----
  2555. out->MeterInfo_isUsed = 1u;
  2556. SHM_Read_iso1MeterInfo(&out->MeterInfo, &in->MeterInfo);
  2557. //----- [BODY (7/10)] ReceiptRequired -----
  2558. out->ReceiptRequired_isUsed = 1u;
  2559. out->ReceiptRequired = (int)in->ReceiptRequired;
  2560. }
  2561. /*===========================================================================
  2562. FUNCTION: SHM_Read_din_WeldingDetectionRes
  2563. DESCRIPTION:
  2564. PRE-CONDITION:
  2565. INPUT:
  2566. 1. shm_ccs
  2567. OUTPUT:
  2568. 2. exi_doc_DIN
  2569. GLOBAL VARIABLES:
  2570. =============================================================================*/
  2571. void SHM_Read_din_WeldingDetectionRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2572. {
  2573. struct dinWeldingDetectionResType *out;
  2574. struct WeldingDetectionResponse_DIN70121 *in;
  2575. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2576. init_dinWeldingDetectionResType(&exi_doc_DIN->V2G_Message.Body.WeldingDetectionRes);
  2577. out = &exi_doc_DIN->V2G_Message.Body.WeldingDetectionRes;
  2578. in = &shm_ccs->V2GMessage_DIN70121.WeldingDetectionResponse;
  2579. exi_doc_DIN->V2G_Message.Body.WeldingDetectionRes_isUsed = 1u;
  2580. //----- [BODY (1/3)] ResponseCode -----
  2581. out->ResponseCode = (unsigned char) in->ResponseCode;
  2582. //----- [BODY (2/3)] EVSEPresentVoltage -----
  2583. SHM_Read_dinPhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2584. //----- [BODY (3/3)] DC_EVSEStatus -----
  2585. SHM_Read_dinDC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2586. }
  2587. /*===========================================================================
  2588. FUNCTION: SHM_Read_iso1_WeldingDetectionRes
  2589. DESCRIPTION:
  2590. PRE-CONDITION:
  2591. INPUT:
  2592. 1. shm_ccs
  2593. OUTPUT:
  2594. 2. exi_doc_ISO1
  2595. GLOBAL VARIABLES:
  2596. =============================================================================*/
  2597. void SHM_Read_iso1_WeldingDetectionRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2598. {
  2599. struct iso1WeldingDetectionResType *out;
  2600. struct WeldingDetectionResponse_ISO15118_2014 *in;
  2601. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2602. init_iso1WeldingDetectionResType(&exi_doc_ISO1->V2G_Message.Body.WeldingDetectionRes);
  2603. out = &exi_doc_ISO1->V2G_Message.Body.WeldingDetectionRes;
  2604. in = &shm_ccs->V2GMessage_ISO15118_2014.WeldingDetectionResponse;
  2605. exi_doc_ISO1->V2G_Message.Body.WeldingDetectionRes_isUsed = 1u;
  2606. //----- [BODY (1/3)] ResponseCode -----
  2607. out->ResponseCode = (unsigned char) in->ResponseCode;
  2608. //----- [BODY (2/3)] EVSEPresentVoltage -----
  2609. SHM_Read_iso1PhysicalValueType(&out->EVSEPresentVoltage, &in->EVSEPresentVoltage);
  2610. //----- [BODY (3/3)] DC_EVSEStatus -----
  2611. SHM_Read_iso1DC_EVSEStatusType(&out->DC_EVSEStatus, &in->DC_EVSEStatus);
  2612. }
  2613. /*===========================================================================
  2614. FUNCTION: SHM_Read_din_SessionStopRes
  2615. DESCRIPTION:
  2616. PRE-CONDITION:
  2617. INPUT:
  2618. 1. shm_ccs
  2619. OUTPUT:
  2620. 2. exi_doc_DIN
  2621. GLOBAL VARIABLES:
  2622. =============================================================================*/
  2623. void SHM_Read_din_SessionStopRes(struct dinEXIDocument *exi_doc_DIN, struct CcsData *shm_ccs)
  2624. {
  2625. struct dinSessionStopResType *out;
  2626. struct SessionStopResponse_DIN70121 *in;
  2627. init_dinBodyType(&exi_doc_DIN->V2G_Message.Body);
  2628. init_dinSessionStopResType(&exi_doc_DIN->V2G_Message.Body.SessionStopRes);
  2629. out = &exi_doc_DIN->V2G_Message.Body.SessionStopRes;
  2630. in = &shm_ccs->V2GMessage_DIN70121.SessionStopResponse;
  2631. exi_doc_DIN->V2G_Message.Body.SessionStopRes_isUsed = 1u;
  2632. //----- [BODY (1/3)] ResponseCode -----
  2633. out->ResponseCode = (unsigned char) in->ResponseCode;
  2634. }
  2635. /*===========================================================================
  2636. FUNCTION: SHM_Read_iso1_SessionStopRes
  2637. DESCRIPTION:
  2638. PRE-CONDITION:
  2639. INPUT:
  2640. 1. shm_ccs
  2641. OUTPUT:
  2642. 2. exi_doc_ISO1
  2643. GLOBAL VARIABLES:
  2644. =============================================================================*/
  2645. void SHM_Read_iso1_SessionStopRes(struct iso1EXIDocument *exi_doc_ISO1, struct CcsData *shm_ccs)
  2646. {
  2647. struct iso1SessionStopResType *out;
  2648. struct SessionStopResponse_ISO15118_2014 *in;
  2649. init_iso1BodyType(&exi_doc_ISO1->V2G_Message.Body);
  2650. init_iso1SessionStopResType(&exi_doc_ISO1->V2G_Message.Body.SessionStopRes);
  2651. out = &exi_doc_ISO1->V2G_Message.Body.SessionStopRes;
  2652. in = &shm_ccs->V2GMessage_ISO15118_2014.SessionStopResponse;
  2653. exi_doc_ISO1->V2G_Message.Body.SessionStopRes_isUsed = 1u;
  2654. //----- [BODY (1/3)] ResponseCode -----
  2655. out->ResponseCode = (unsigned char) in->ResponseCode;
  2656. }
  2657. /*===========================================================================
  2658. FUNCTION: PRINT_V2G_MSG_din_Header
  2659. DESCRIPTION:
  2660. PRE-CONDITION:
  2661. INPUT:
  2662. OUTPUT:
  2663. GLOBAL VARIABLES:
  2664. =============================================================================*/
  2665. void PRINT_V2G_MSG_din_Header(struct dinEXIDocument *exi_doc_DIN)
  2666. {
  2667. int i = 0;
  2668. int leng = 0;
  2669. unsigned char buffer[1024]={0};
  2670. leng = exi_doc_DIN->V2G_Message.Header.SessionID.bytesLen;
  2671. for (i = 0; i <leng ; i++)
  2672. {
  2673. sprintf((char*)buffer, "%s%02x ", buffer, exi_doc_DIN->V2G_Message.Header.SessionID.bytes[i]);
  2674. }
  2675. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionID (%d Bytes): %s\n", leng, buffer);
  2676. }
  2677. /*===========================================================================
  2678. FUNCTION: PRINT_V2G_MSG_iso1_Header
  2679. DESCRIPTION:
  2680. PRE-CONDITION:
  2681. INPUT:
  2682. OUTPUT:
  2683. GLOBAL VARIABLES:
  2684. =============================================================================*/
  2685. void PRINT_V2G_MSG_iso1_Header(struct iso1EXIDocument *exi_doc_ISO1)
  2686. {
  2687. int i = 0;
  2688. int leng = 0;
  2689. unsigned char buffer[1024]={0};
  2690. leng = exi_doc_ISO1->V2G_Message.Header.SessionID.bytesLen;
  2691. for (i = 0; i <leng ; i++)
  2692. {
  2693. sprintf((char*)buffer, "%s%02x ", buffer, exi_doc_ISO1->V2G_Message.Header.SessionID.bytes[i]);
  2694. }
  2695. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionID (%d Bytes): %s\n", leng, buffer);
  2696. }
  2697. /*===========================================================================
  2698. FUNCTION: PRINT_V2G_MSG_iso1_Header
  2699. DESCRIPTION:
  2700. PRE-CONDITION:
  2701. INPUT:
  2702. OUTPUT:
  2703. GLOBAL VARIABLES:
  2704. =============================================================================*/
  2705. void PRINT_V2G_MSG_iso2_Header(struct iso2EXIDocument *exi_doc_ISO2)
  2706. {
  2707. int i = 0;
  2708. int leng = 0;
  2709. unsigned char buffer[1024]={0};
  2710. leng = exi_doc_ISO2->V2G_Message.Header.SessionID.bytesLen;
  2711. for (i = 0; i <leng ; i++)
  2712. {
  2713. sprintf((char*)buffer, "%s%02x ", buffer, exi_doc_ISO2->V2G_Message.Header.SessionID.bytes[i]);
  2714. }
  2715. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SessionID (%d Bytes): %s\n", leng, buffer);
  2716. }
  2717. /*===========================================================================
  2718. FUNCTION: DEBUG_PRINT_EXI_MSG_supportedAppProtocolReq
  2719. DESCRIPTION:
  2720. PRE-CONDITION:
  2721. INPUT:
  2722. OUTPUT:
  2723. GLOBAL VARIABLES:
  2724. =============================================================================*/
  2725. void PRINT_XML_DOC_supportedAppProtocolReq(struct appHandEXIDocument *exi_doc)
  2726. {
  2727. int i = 0;
  2728. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVSE side: List of application handshake protocols of the EV\n");
  2729. for(i = 0; i < exi_doc->supportedAppProtocolReq.AppProtocol.arrayLen; i++)
  2730. {
  2731. DEBUG_PRINTF_EXI_ENGINE_DETAIL("Protocol entry #=%d\n",(i+1));
  2732. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ProtocolNamespace:\n");
  2733. printASCIIString(exi_doc->supportedAppProtocolReq.AppProtocol.array[i].ProtocolNamespace.characters,
  2734. exi_doc->supportedAppProtocolReq.AppProtocol.array[i].ProtocolNamespace.charactersLen);
  2735. DEBUG_PRINTF_EXI_ENGINE_DETAIL("Version= %d.%d\n",
  2736. exi_doc->supportedAppProtocolReq.AppProtocol.array[i].VersionNumberMajor,
  2737. exi_doc->supportedAppProtocolReq.AppProtocol.array[i].VersionNumberMinor);
  2738. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SchemaID: %d\n", exi_doc->supportedAppProtocolReq.AppProtocol.array[i].SchemaID);
  2739. DEBUG_PRINTF_EXI_ENGINE_DETAIL("Priority: %d\n", exi_doc->supportedAppProtocolReq.AppProtocol.array[i].Priority);
  2740. }
  2741. }
  2742. /*===========================================================================
  2743. FUNCTION: PRINT_XML_DOC_DIN_SessionSetupReq
  2744. DESCRIPTION:
  2745. PRE-CONDITION:
  2746. INPUT:
  2747. OUTPUT:
  2748. GLOBAL VARIABLES:
  2749. =============================================================================*/
  2750. void PRINT_XML_DOC_DIN_SessionSetupReq(struct dinEXIDocument *exi_doc_DIN)
  2751. {
  2752. int i = 0;
  2753. unsigned char buffer[1024]={0};
  2754. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing SessionSetupReq\n");
  2755. //===== [Header] SessionID =====
  2756. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  2757. for (i = 0; i < exi_doc_DIN->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen; i++)
  2758. {
  2759. sprintf((char*)buffer, "%s%02X ", buffer, exi_doc_DIN->V2G_Message.Body.SessionSetupReq.EVCCID.bytes[i]);
  2760. }
  2761. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVCCID (%d Bytes): %s\n", exi_doc_DIN->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen, buffer);
  2762. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionSetupReq\n");
  2763. }
  2764. /*===========================================================================
  2765. FUNCTION: PRINT_XML_DOC_ISO1_SessionSetupReq
  2766. DESCRIPTION:
  2767. PRE-CONDITION:
  2768. INPUT:
  2769. OUTPUT:
  2770. GLOBAL VARIABLES:
  2771. =============================================================================*/
  2772. void PRINT_XML_DOC_ISO1_SessionSetupReq(struct iso1EXIDocument *exi_doc_ISO1)
  2773. {
  2774. int i = 0;
  2775. unsigned char buffer[1024]={0};
  2776. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing SessionSetupReq\n");
  2777. //===== [Header] SessionID =====
  2778. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  2779. for (i = 0; i < exi_doc_ISO1->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen; i++)
  2780. {
  2781. sprintf((char*)buffer, "%s%02X ", buffer, exi_doc_ISO1->V2G_Message.Body.SessionSetupReq.EVCCID.bytes[i]);
  2782. }
  2783. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVCCID (%d Bytes): %s\n", exi_doc_ISO1->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen, buffer);
  2784. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionSetupReq\n");
  2785. }
  2786. /*===========================================================================
  2787. FUNCTION: PRINT_XML_DOC_ISO2_SessionSetupReq
  2788. DESCRIPTION:
  2789. PRE-CONDITION:
  2790. INPUT:
  2791. OUTPUT:
  2792. GLOBAL VARIABLES:
  2793. =============================================================================*/
  2794. void PRINT_XML_DOC_ISO2_SessionSetupReq(struct iso2EXIDocument *exi_doc_ISO2)
  2795. {
  2796. int i = 0;
  2797. unsigned char buffer[1024]={0};
  2798. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing SessionSetupReq\n");
  2799. //===== [Header] SessionID =====
  2800. PRINT_V2G_MSG_iso2_Header(exi_doc_ISO2);
  2801. DEBUG_PRINTF_EXI_ENGINE_DETAIL("\n\t\tEVCCID (%d Bytes) = ", exi_doc_ISO2->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen);
  2802. for (i = 0; i < exi_doc_ISO2->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen; i++)
  2803. {
  2804. sprintf((char*)buffer, "%s%02X ", buffer, exi_doc_ISO2->V2G_Message.Body.SessionSetupReq.EVCCID.bytes[i]);
  2805. }
  2806. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVCCID (%d Bytes): %s\n", exi_doc_ISO2->V2G_Message.Body.SessionSetupReq.EVCCID.bytesLen, buffer);
  2807. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionSetupReq\n");
  2808. }
  2809. /*===========================================================================
  2810. FUNCTION: PRINT_XML_DOC_DIN_ServiceDiscoveryReq
  2811. DESCRIPTION:
  2812. PRE-CONDITION:
  2813. INPUT:
  2814. OUTPUT:
  2815. GLOBAL VARIABLES:
  2816. =============================================================================*/
  2817. void PRINT_XML_DOC_DIN_ServiceDiscoveryReq(struct dinEXIDocument *exi_doc_DIN)
  2818. {
  2819. int i = 0;
  2820. int leng = 0;
  2821. unsigned char buffer[1024]={0};
  2822. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing ServiceDiscoveryReq\n");
  2823. //===== [Header] SessionID =====
  2824. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  2825. //[BODY(1/2)] Service Scope
  2826. leng = exi_doc_DIN->V2G_Message.Body.ServiceDiscoveryReq.ServiceScope.charactersLen;
  2827. for (i = 0; i <leng ; i++)
  2828. {
  2829. sprintf((char*)buffer, "%s%02X ", buffer, exi_doc_DIN->V2G_Message.Body.ServiceDiscoveryReq.ServiceScope.characters[i]);
  2830. }
  2831. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceScope (%d Bytes, optional): %s\n", leng, buffer);
  2832. //[BODY(2/2)] Service Category
  2833. int cat = 0;
  2834. cat = exi_doc_DIN->V2G_Message.Body.ServiceDiscoveryReq.ServiceCategory;
  2835. switch (cat)
  2836. {
  2837. case dinserviceCategoryType_EVCharging: //0
  2838. {
  2839. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (EVCharging)\n", cat);
  2840. break;
  2841. }
  2842. case dinserviceCategoryType_Internet: //1
  2843. {
  2844. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (Internet: not supported)\n", cat);
  2845. break;
  2846. }
  2847. case dinserviceCategoryType_ContractCertificate: //2
  2848. {
  2849. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (ContractCertificate: not supported)\n", cat);
  2850. break;
  2851. }
  2852. case dinserviceCategoryType_OtherCustom: //3
  2853. {
  2854. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (OtherCustom: not supported)\n", cat);
  2855. break;
  2856. }
  2857. default:
  2858. {
  2859. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (Unexpected Service Category: %d)\n", cat);
  2860. break;
  2861. }
  2862. }
  2863. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("\n\t([0]EVCharging, [1]Internet, [2]ContractCertificate, [3]OtherCustom)\n");
  2864. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ServiceDiscoveryReq\n");
  2865. }
  2866. /*===========================================================================
  2867. FUNCTION: PRINT_XML_DOC_ISO1_ServiceDiscoveryReq
  2868. DESCRIPTION:
  2869. PRE-CONDITION:
  2870. INPUT:
  2871. OUTPUT:
  2872. GLOBAL VARIABLES:
  2873. =============================================================================*/
  2874. void PRINT_XML_DOC_ISO1_ServiceDiscoveryReq(struct iso1EXIDocument *exi_doc_ISO1)
  2875. {
  2876. int i = 0;
  2877. int leng = 0;
  2878. unsigned char buffer[1024]={0};
  2879. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing ServiceDiscoveryReq\n");
  2880. //===== [Header] SessionID =====
  2881. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  2882. //[BODY(1/2)] Service Scope
  2883. leng = exi_doc_ISO1->V2G_Message.Body.ServiceDiscoveryReq.ServiceScope.charactersLen;
  2884. for (i = 0; i <leng ; i++)
  2885. {
  2886. sprintf((char*)buffer, "%s%02X ", buffer, exi_doc_ISO1->V2G_Message.Body.ServiceDiscoveryReq.ServiceScope.characters[i]);
  2887. }
  2888. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceScope (%d Bytes, optional): %s\n", leng, buffer);
  2889. //[BODY(2/2)] Service Category
  2890. int cat = 0;
  2891. cat = exi_doc_ISO1->V2G_Message.Body.ServiceDiscoveryReq.ServiceCategory;
  2892. switch (cat)
  2893. {
  2894. case iso1serviceCategoryType_EVCharging: //0
  2895. {
  2896. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (EVCharging)\n", cat);
  2897. break;
  2898. }
  2899. case iso1serviceCategoryType_Internet: //1
  2900. {
  2901. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (Internet: not supported)\n", cat);
  2902. break;
  2903. }
  2904. case iso1serviceCategoryType_ContractCertificate: //2
  2905. {
  2906. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (ContractCertificate: not supported)\n", cat);
  2907. break;
  2908. }
  2909. case iso1serviceCategoryType_OtherCustom: //3
  2910. {
  2911. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (OtherCustom: not supported)\n", cat);
  2912. break;
  2913. }
  2914. default:
  2915. {
  2916. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ServiceCategory: %d (Unexpected Service Category)\n", cat);
  2917. break;
  2918. }
  2919. }
  2920. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("\n\t([0]EVCharging, [1]Internet, [2]ContractCertificate, [3]OtherCustom)\n");
  2921. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ServiceDiscoveryReq\n");
  2922. }
  2923. /*===========================================================================
  2924. FUNCTION: PRINT_XML_DOC_DIN_ServiceAndPaymentSelectionReq
  2925. DESCRIPTION:
  2926. PRE-CONDITION:
  2927. INPUT:
  2928. OUTPUT:
  2929. GLOBAL VARIABLES:
  2930. =============================================================================*/
  2931. void PRINT_XML_DOC_DIN_ServiceAndPaymentSelectionReq(struct dinEXIDocument *exi_doc_DIN)
  2932. {
  2933. int i = 0;
  2934. int leng = 0;
  2935. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing ServicePaymentSelectionReq\n");
  2936. //===== [Header] SessionID =====
  2937. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  2938. //[BODY(1/2)] SelectedPaymentOption
  2939. int opt = 0;
  2940. opt = exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq.SelectedPaymentOption;
  2941. switch (opt)
  2942. {
  2943. case dinpaymentOptionType_Contract: //0
  2944. {
  2945. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d (Contract)\n", opt);
  2946. break;
  2947. }
  2948. case dinpaymentOptionType_ExternalPayment: //1
  2949. {
  2950. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d (ExternalPayment)\n", opt);
  2951. break;
  2952. }
  2953. default:
  2954. {
  2955. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d ([ERROR] Unexpected SelectedPaymentOption)\n", opt);
  2956. break;
  2957. }
  2958. }
  2959. //[BODY(2/2)] SelectedServiceList
  2960. leng = exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq.SelectedServiceList.SelectedService.arrayLen;
  2961. for (i = 0; i< leng; i++)
  2962. {
  2963. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedServiceList (%d items): [%d-th](ServiceID, ParameterSetID, ParameterSetID_isUsed) = {%d, %d, %d}\n",
  2964. leng,
  2965. (i+1),
  2966. exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq.SelectedServiceList.SelectedService.array[i].ServiceID,
  2967. exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq.SelectedServiceList.SelectedService.array[i].ParameterSetID,
  2968. exi_doc_DIN->V2G_Message.Body.ServicePaymentSelectionReq.SelectedServiceList.SelectedService.array[i].ParameterSetID_isUsed);
  2969. }
  2970. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ServicePaymentSelectionReq\n");
  2971. }
  2972. /*===========================================================================
  2973. FUNCTION: PRINT_XML_DOC_ISO1_ServiceAndPaymentSelectionReq
  2974. DESCRIPTION:
  2975. PRE-CONDITION:
  2976. INPUT:
  2977. OUTPUT:
  2978. GLOBAL VARIABLES:
  2979. =============================================================================*/
  2980. void PRINT_XML_DOC_ISO1_ServiceAndPaymentSelectionReq(struct iso1EXIDocument *exi_doc_ISO1)
  2981. {
  2982. int i = 0;
  2983. int leng = 0;
  2984. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing PaymentServiceSelectionReq\n");
  2985. //===== [Header] SessionID =====
  2986. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  2987. //[BODY(1/2)] SelectedPaymentOption
  2988. int opt = 0;
  2989. opt = exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq.SelectedPaymentOption;
  2990. switch (opt)
  2991. {
  2992. case iso1paymentOptionType_Contract: //0
  2993. {
  2994. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d (Contract)\n", opt);
  2995. break;
  2996. }
  2997. case iso1paymentOptionType_ExternalPayment: //1
  2998. {
  2999. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d (ExternalPayment)\n", opt);
  3000. break;
  3001. }
  3002. default:
  3003. {
  3004. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedPaymentOption: %d (Unexpected SelectedPaymentOption)\n", opt);
  3005. break;
  3006. }
  3007. }
  3008. //[BODY(2/2)] SelectedServiceList
  3009. leng = exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq.SelectedServiceList.SelectedService.arrayLen;
  3010. for (i = 0; i< leng; i++)
  3011. {
  3012. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SelectedServiceList (%d items): [%d-th](ServiceID, ParameterSetID, ParameterSetID_isUsed) = {%d, %d, %d}\n",
  3013. leng,
  3014. (i+1),
  3015. exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq.SelectedServiceList.SelectedService.array[i].ServiceID,
  3016. exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq.SelectedServiceList.SelectedService.array[i].ParameterSetID,
  3017. exi_doc_ISO1->V2G_Message.Body.PaymentServiceSelectionReq.SelectedServiceList.SelectedService.array[i].ParameterSetID_isUsed);
  3018. }
  3019. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [END] Parsing PaymentServiceSelectionReq\n");
  3020. }
  3021. /*===========================================================================
  3022. FUNCTION: PRINT_XML_DOC_DIN_ContractAuthenticationReq
  3023. DESCRIPTION:
  3024. PRE-CONDITION:
  3025. INPUT:
  3026. OUTPUT:
  3027. GLOBAL VARIABLES:
  3028. =============================================================================*/
  3029. void PRINT_XML_DOC_DIN_ContractAuthenticationReq(struct dinEXIDocument *exi_doc_DIN)
  3030. {
  3031. //int i = 0;
  3032. static int cnt = 0;
  3033. cnt++;
  3034. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing ContractAuthenticationReq (%d-th)\n", cnt);
  3035. //===== [Header] SessionID =====
  3036. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3037. //[BODY(1/2)] Id
  3038. //[Joseph, To-Do, not full implemented, yet]
  3039. DEBUG_PRINTF_EXI_ENGINE_DETAIL("Id_isUsed: %d\n",
  3040. exi_doc_DIN->V2G_Message.Body.ContractAuthenticationReq.Id_isUsed);
  3041. //[BODY(2/2)] GenChallenge
  3042. //[Joseph, To-Do, not full implemented, yet]
  3043. DEBUG_PRINTF_EXI_ENGINE_DETAIL("GenChallenge_isUsed: %d\n",
  3044. exi_doc_DIN->V2G_Message.Body.ContractAuthenticationReq.GenChallenge_isUsed);
  3045. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ContractAuthenticationReq (%d-th)\n", cnt);
  3046. }
  3047. /*===========================================================================
  3048. FUNCTION: PRINT_XML_DOC_ISO1_AuthorizationReq
  3049. DESCRIPTION:
  3050. PRE-CONDITION:
  3051. INPUT:
  3052. OUTPUT:
  3053. GLOBAL VARIABLES:
  3054. =============================================================================*/
  3055. void PRINT_XML_DOC_ISO1_AuthorizationReq(struct iso1EXIDocument *exi_doc_ISO1)
  3056. {
  3057. //int i = 0;
  3058. static int cnt = 0;
  3059. cnt++;
  3060. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing AuthorizationReq (%d-th)\n", cnt);
  3061. //===== [Header] SessionID =====
  3062. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3063. //[BODY(1/2)] Id
  3064. //[Joseph, To-Do, not full implemented, yet]
  3065. DEBUG_PRINTF_EXI_ENGINE_DETAIL("Id_isUsed: %d\n",
  3066. exi_doc_ISO1->V2G_Message.Body.AuthorizationReq.Id_isUsed);
  3067. //[BODY(2/2)] GenChallenge
  3068. //[Joseph, To-Do, not full implemented, yet]
  3069. DEBUG_PRINTF_EXI_ENGINE_DETAIL("GenChallenge_isUsed: %d\n",
  3070. exi_doc_ISO1->V2G_Message.Body.AuthorizationReq.GenChallenge_isUsed);
  3071. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing AuthorizationReq (%d-th)\n", cnt);
  3072. }
  3073. /*===========================================================================
  3074. FUNCTION: PRINT_XML_DOC_DIN_ChargeParameterDiscoveryReq
  3075. DESCRIPTION:
  3076. PRE-CONDITION:
  3077. INPUT:
  3078. OUTPUT:
  3079. GLOBAL VARIABLES:
  3080. =============================================================================*/
  3081. void PRINT_XML_DOC_DIN_ChargeParameterDiscoveryReq(struct dinEXIDocument *exi_doc_DIN)
  3082. {
  3083. //int i = 0;
  3084. static int cnt = 0;
  3085. cnt++;
  3086. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing ChargeParameterDiscoveryReq (%d-th)\n", cnt);
  3087. //===== [Header] SessionID =====
  3088. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3089. //===== [BODY (1/3)] EVRequestedEnergyTransferType =====
  3090. int type = 0;
  3091. type = exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.EVRequestedEnergyTransferType;
  3092. switch (type)
  3093. {
  3094. case dinEVRequestedEnergyTransferType_AC_single_phase_core: //0,
  3095. {
  3096. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (AC_single_phase_core)\n", type);
  3097. break;
  3098. }
  3099. case dinEVRequestedEnergyTransferType_AC_three_phase_core: //1,
  3100. {
  3101. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (AC_three_phase_core)\n", type);
  3102. break;
  3103. }
  3104. case dinEVRequestedEnergyTransferType_DC_core: //2,
  3105. {
  3106. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (DC_core)\n", type);
  3107. break;
  3108. }
  3109. case dinEVRequestedEnergyTransferType_DC_extended: //3,
  3110. {
  3111. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (DC_extended)\n", type); //expected
  3112. //[Joseph, To-Do]
  3113. //If this parameter is different from previous message,
  3114. //a warning should be noted.
  3115. break;
  3116. }
  3117. case dinEVRequestedEnergyTransferType_DC_combo_core: //4,
  3118. {
  3119. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (DC_combo_core)\n", type);
  3120. break;
  3121. }
  3122. case dinEVRequestedEnergyTransferType_DC_unique: //5
  3123. {
  3124. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRequestedEnergyTransferType: %d (DC_unique)\n", type);
  3125. break;
  3126. }
  3127. }
  3128. //===== [BODY (2/3)] AC_EVChargeParameter of EVChargeParameter =====
  3129. //ignored, since DIN doesn't support AC.
  3130. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.AC_EVChargeParameter_isUsed);
  3131. //===== [BODY (3/3)] DC_EVChargeParameter of EVChargeParameter =====
  3132. struct dinPhysicalValueType *obj;
  3133. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter_isUsed);
  3134. //DC_EVStatus
  3135. struct dinDC_EVStatusType *status;
  3136. status = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.DC_EVStatus;
  3137. PRINT_dinDC_EVStatusType(status);
  3138. //EVMaximumCurrentLimit
  3139. obj = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumCurrentLimit;
  3140. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumCurrentLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3141. PRINT_dinPhysicalValueType_UNIT(obj);
  3142. //EVMaximumPowerLimit
  3143. obj = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumPowerLimit;
  3144. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumPowerLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3145. PRINT_dinPhysicalValueType_UNIT(obj);
  3146. //EVMaximumVoltageLimit
  3147. obj = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumVoltageLimit;
  3148. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumVoltageLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3149. PRINT_dinPhysicalValueType_UNIT(obj);
  3150. //EVEnergyCapacity
  3151. obj = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVEnergyCapacity;
  3152. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVEnergyCapacity: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3153. PRINT_dinPhysicalValueType_UNIT(obj);
  3154. //EVEnergyRequest
  3155. obj = &exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVEnergyRequest;
  3156. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVEnergyRequest: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3157. PRINT_dinPhysicalValueType_UNIT(obj);
  3158. //FullSOC
  3159. DEBUG_PRINTF_EXI_ENGINE_DETAIL("FullSOC: %d \% (DEC)\n", exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.FullSOC);
  3160. //BulkSOC
  3161. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkSOC: %d \% (DEC)\n", exi_doc_DIN->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.BulkSOC);
  3162. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ChargeParameterDiscoveryReq (%d-th)\n", cnt);
  3163. }
  3164. /*===========================================================================
  3165. FUNCTION: PRINT_XML_DOC_ISO1_ChargeParameterDiscoveryReq
  3166. DESCRIPTION:
  3167. PRE-CONDITION:
  3168. INPUT:
  3169. OUTPUT:
  3170. GLOBAL VARIABLES:
  3171. =============================================================================*/
  3172. void PRINT_XML_DOC_ISO1_ChargeParameterDiscoveryReq(struct iso1EXIDocument *exi_doc_ISO1)
  3173. {
  3174. //int i = 0;
  3175. static int cnt = 0;
  3176. cnt++;
  3177. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing ChargeParameterDiscoveryReq (%d-th)\n", cnt);
  3178. //===== [Header] SessionID =====
  3179. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3180. //===== [BODY (1/3)] RequestedEnergyTransferMode =====
  3181. int type = 0;
  3182. type = exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.RequestedEnergyTransferMode;
  3183. switch (type)
  3184. {
  3185. case iso1EnergyTransferModeType_AC_single_phase_core: //0,
  3186. {
  3187. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (AC_single_phase_core)\n", type);
  3188. break;
  3189. }
  3190. case iso1EnergyTransferModeType_AC_three_phase_core: //1,
  3191. {
  3192. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (AC_three_phase_core)\n", type);
  3193. break;
  3194. }
  3195. case iso1EnergyTransferModeType_DC_core: //2,
  3196. {
  3197. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (DC_core)\n", type);
  3198. break;
  3199. }
  3200. case iso1EnergyTransferModeType_DC_extended: //3,
  3201. {
  3202. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (DC_extended)\n", type); //expected
  3203. //[Joseph, To-Do]
  3204. //If this parameter is different from previous message,
  3205. //a warning should be noted.
  3206. break;
  3207. }
  3208. case iso1EnergyTransferModeType_DC_combo_core: //4,
  3209. {
  3210. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (DC_combo_core)\n", type);
  3211. break;
  3212. }
  3213. case iso1EnergyTransferModeType_DC_unique: //5
  3214. {
  3215. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RequestedEnergyTransferMode: %d (DC_unique)\n", type);
  3216. break;
  3217. }
  3218. }
  3219. //===== [BODY (2/3)] AC_EVChargeParameter of EVChargeParameter =====
  3220. //ignored, since our ISO1 doesn't support AC.
  3221. DEBUG_PRINTF_EXI_ENGINE_DETAIL("AC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.AC_EVChargeParameter_isUsed);
  3222. //===== [BODY (3/3)] DC_EVChargeParameter of EVChargeParameter =====
  3223. struct iso1PhysicalValueType *obj;
  3224. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter_isUsed);
  3225. //DC_EVStatus
  3226. struct iso1DC_EVStatusType *status;
  3227. status = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.DC_EVStatus;
  3228. PRINT_iso1DC_EVStatusType(status);
  3229. //EVMaximumCurrentLimit
  3230. obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumCurrentLimit;
  3231. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumCurrentLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3232. PRINT_iso1PhysicalValueType_UNIT(obj);
  3233. //EVMaximumPowerLimit
  3234. obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumPowerLimit;
  3235. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumPowerLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3236. PRINT_iso1PhysicalValueType_UNIT(obj);
  3237. //EVMaximumVoltageLimit
  3238. obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVMaximumVoltageLimit;
  3239. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumVoltageLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3240. PRINT_iso1PhysicalValueType_UNIT(obj);
  3241. //EVEnergyCapacity
  3242. obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVEnergyCapacity;
  3243. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVEnergyCapacity: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3244. PRINT_iso1PhysicalValueType_UNIT(obj);
  3245. //EVEnergyRequest
  3246. obj = &exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.EVEnergyRequest;
  3247. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVEnergyRequest: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3248. PRINT_iso1PhysicalValueType_UNIT(obj);
  3249. //FullSOC
  3250. DEBUG_PRINTF_EXI_ENGINE_DETAIL("FullSOC: %d \% (DEC)\n", exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.FullSOC);
  3251. //BulkSOC
  3252. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkSOC: %d \% (DEC)\n", exi_doc_ISO1->V2G_Message.Body.ChargeParameterDiscoveryReq.DC_EVChargeParameter.BulkSOC);
  3253. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ChargeParameterDiscoveryReq (%d-th)\n", cnt);
  3254. }
  3255. /*===========================================================================
  3256. FUNCTION: PRINT_XML_DOC_DIN_CableCheckReq
  3257. DESCRIPTION:
  3258. PRE-CONDITION:
  3259. INPUT:
  3260. OUTPUT:
  3261. GLOBAL VARIABLES:
  3262. =============================================================================*/
  3263. void PRINT_XML_DOC_DIN_CableCheckReq(struct dinEXIDocument *exi_doc_DIN)
  3264. {
  3265. //int i = 0;
  3266. static int cnt = 0;
  3267. cnt++;
  3268. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing CableCheckReq (%d-th)\n", cnt);
  3269. //===== [Header] SessionID =====
  3270. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3271. //===== [BODY (1/1)] DC_EVStatus =====
  3272. struct dinDC_EVStatusType *status;
  3273. status = &exi_doc_DIN->V2G_Message.Body.CableCheckReq.DC_EVStatus;
  3274. PRINT_dinDC_EVStatusType(status);
  3275. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing CableCheckReq (%d-th)\n", cnt);
  3276. }
  3277. /*===========================================================================
  3278. FUNCTION: PRINT_XML_DOC_ISO1_CableCheckReq
  3279. DESCRIPTION:
  3280. PRE-CONDITION:
  3281. INPUT:
  3282. OUTPUT:
  3283. GLOBAL VARIABLES:
  3284. =============================================================================*/
  3285. void PRINT_XML_DOC_ISO1_CableCheckReq(struct iso1EXIDocument *exi_doc_ISO1)
  3286. {
  3287. //int i = 0;
  3288. static int cnt = 0;
  3289. cnt++;
  3290. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing CableCheckReq (%d-th)\n", cnt);
  3291. //===== [Header] SessionID =====
  3292. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3293. //===== [BODY (1/1)] DC_EVStatus =====
  3294. struct iso1DC_EVStatusType *status;
  3295. status = &exi_doc_ISO1->V2G_Message.Body.CableCheckReq.DC_EVStatus;
  3296. PRINT_iso1DC_EVStatusType(status);
  3297. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing CableCheckReq (%d-th)\n", cnt);
  3298. }
  3299. /*===========================================================================
  3300. FUNCTION: PRINT_XML_DOC_DIN_PreChargeReq
  3301. DESCRIPTION:
  3302. PRE-CONDITION:
  3303. INPUT:
  3304. OUTPUT:
  3305. GLOBAL VARIABLES:
  3306. =============================================================================*/
  3307. void PRINT_XML_DOC_DIN_PreChargeReq(struct dinEXIDocument *exi_doc_DIN)
  3308. {
  3309. //int i = 0;
  3310. static int cnt = 0;
  3311. cnt++;
  3312. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing PreChargeReq (%d-th)\n", cnt);
  3313. //===== [Header] SessionID =====
  3314. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3315. //===== [BODY (1/3)] DC_EVStatus =====
  3316. struct dinDC_EVStatusType *status;
  3317. status = &exi_doc_DIN->V2G_Message.Body.PreChargeReq.DC_EVStatus;
  3318. PRINT_dinDC_EVStatusType(status);
  3319. //===== [BODY (2/3)] EVTargetVoltage =====
  3320. struct dinPhysicalValueType *obj;
  3321. obj = &exi_doc_DIN->V2G_Message.Body.PreChargeReq.EVTargetVoltage;
  3322. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetVoltage: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3323. PRINT_dinPhysicalValueType_UNIT(obj);
  3324. //===== [BODY (3/3)] EVTargetCurrent =====
  3325. obj = &exi_doc_DIN->V2G_Message.Body.PreChargeReq.EVTargetCurrent;
  3326. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetCurrent: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3327. PRINT_dinPhysicalValueType_UNIT(obj);
  3328. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PreChargeReq (%d-th)\n", cnt);
  3329. }
  3330. /*===========================================================================
  3331. FUNCTION: PRINT_XML_DOC_ISO1_PreChargeReq
  3332. DESCRIPTION:
  3333. PRE-CONDITION:
  3334. INPUT:
  3335. OUTPUT:
  3336. GLOBAL VARIABLES:
  3337. =============================================================================*/
  3338. void PRINT_XML_DOC_ISO1_PreChargeReq(struct iso1EXIDocument *exi_doc_ISO1)
  3339. {
  3340. //int i = 0;
  3341. static int cnt = 0;
  3342. cnt++;
  3343. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing PreChargeReq (%d-th)\n", cnt);
  3344. //===== [Header] SessionID =====
  3345. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3346. //===== [BODY (1/3)] DC_EVStatus =====
  3347. struct iso1DC_EVStatusType *status;
  3348. status = &exi_doc_ISO1->V2G_Message.Body.PreChargeReq.DC_EVStatus;
  3349. PRINT_iso1DC_EVStatusType(status);
  3350. //===== [BODY (2/3)] EVTargetVoltage =====
  3351. struct iso1PhysicalValueType *obj;
  3352. obj = &exi_doc_ISO1->V2G_Message.Body.PreChargeReq.EVTargetVoltage;
  3353. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetVoltage: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3354. PRINT_iso1PhysicalValueType_UNIT(obj);
  3355. //===== [BODY (3/3)] EVTargetCurrent =====
  3356. obj = &exi_doc_ISO1->V2G_Message.Body.PreChargeReq.EVTargetCurrent;
  3357. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetCurrent: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3358. PRINT_iso1PhysicalValueType_UNIT(obj);
  3359. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PreChargeReq (%d-th)\n", cnt);
  3360. }
  3361. /*===========================================================================
  3362. FUNCTION: PRINT_XML_DOC_DIN_PowerDeliveryReq
  3363. DESCRIPTION:
  3364. PRE-CONDITION:
  3365. INPUT:
  3366. OUTPUT:
  3367. GLOBAL VARIABLES:
  3368. =============================================================================*/
  3369. void PRINT_XML_DOC_DIN_PowerDeliveryReq(struct dinEXIDocument *exi_doc_DIN)
  3370. {
  3371. //int i = 0;
  3372. static int cnt = 0;
  3373. cnt++;
  3374. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing PowerDeliveryReq (%d-th)\n", cnt);
  3375. //===== [Header] SessionID =====
  3376. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3377. //===== [BODY (1/3)] ReadyToChargeState =====
  3378. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ReadyToChargeState: %d (DEC)\n",
  3379. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.ReadyToChargeState);
  3380. //===== [BODY (2/3)] ChargingProfile =====
  3381. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingProfile_isUsed: %d (DEC)\n",
  3382. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.ChargingProfile_isUsed);
  3383. //===== [BODY (3/3)] DC_EVPowerDeliveryParameter =====
  3384. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVPowerDeliveryParameter_isUsed: %d (DEC)\n",
  3385. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter_isUsed);
  3386. //DC_EVStatus
  3387. struct dinDC_EVStatusType *status;
  3388. status = &exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.DC_EVStatus;
  3389. PRINT_dinDC_EVStatusType(status);
  3390. //BulkChargingComplete
  3391. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete: %d (DEC)\n",
  3392. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.BulkChargingComplete);
  3393. //BulkChargingComplete_isUsed
  3394. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete_isUsed: %d (DEC)\n",
  3395. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.BulkChargingComplete_isUsed);
  3396. //ChargingComplete
  3397. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingComplete: %d (DEC)\n",
  3398. exi_doc_DIN->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.ChargingComplete);
  3399. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PowerDeliveryReq (%d-th)\n", cnt);
  3400. }
  3401. /*===========================================================================
  3402. FUNCTION: PRINT_XML_DOC_ISO1_PowerDeliveryReq
  3403. DESCRIPTION:
  3404. PRE-CONDITION:
  3405. INPUT:
  3406. OUTPUT:
  3407. GLOBAL VARIABLES:
  3408. =============================================================================*/
  3409. void PRINT_XML_DOC_ISO1_PowerDeliveryReq(struct iso1EXIDocument *exi_doc_ISO1)
  3410. {
  3411. //int i = 0;
  3412. static int cnt = 0;
  3413. cnt++;
  3414. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing PowerDeliveryReq (%d-th)\n", cnt);
  3415. //===== [Header] SessionID =====
  3416. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3417. //===== [BODY (1/3)] ChargeProgress =====
  3418. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargeProgress: %d (DEC, 0:start, 1:stop, 2:renegotiate)\n",
  3419. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.ChargeProgress);
  3420. //iso1chargeProgressType_Start = 0,
  3421. //iso1chargeProgressType_Stop = 1,
  3422. //iso1chargeProgressType_Renegotiate = 2
  3423. //===== [BODY (2/3)] ChargingProfile =====
  3424. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingProfile_isUsed = %d (DEC)\n",
  3425. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.ChargingProfile_isUsed);
  3426. //===== [BODY (3/3)] DC_EVPowerDeliveryParameter =====
  3427. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVPowerDeliveryParameter_isUsed = %d (DEC)\n",
  3428. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter_isUsed);
  3429. //DC_EVStatus
  3430. struct iso1DC_EVStatusType *status;
  3431. status = &exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.DC_EVStatus;
  3432. PRINT_iso1DC_EVStatusType(status);
  3433. //BulkChargingComplete
  3434. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete = %d (DEC)\n",
  3435. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.BulkChargingComplete);
  3436. //BulkChargingComplete_isUsed
  3437. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete_isUsed = %d (DEC)\n",
  3438. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.BulkChargingComplete_isUsed);
  3439. //ChargingComplete
  3440. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingComplete = %d (DEC)\n",
  3441. exi_doc_ISO1->V2G_Message.Body.PowerDeliveryReq.DC_EVPowerDeliveryParameter.ChargingComplete);
  3442. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing PowerDeliveryReq (%d-th)\n", cnt);
  3443. }
  3444. /*===========================================================================
  3445. FUNCTION: PRINT_XML_DOC_DIN_CurrentDemandReq
  3446. DESCRIPTION:
  3447. PRE-CONDITION:
  3448. INPUT:
  3449. OUTPUT:
  3450. GLOBAL VARIABLES:
  3451. =============================================================================*/
  3452. void PRINT_XML_DOC_DIN_CurrentDemandReq(struct dinEXIDocument *exi_doc_DIN)
  3453. {
  3454. //int i = 0;
  3455. static int cnt = 0;
  3456. cnt++;
  3457. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing CurrentDemandReq (%d-th)\n", cnt);
  3458. //===== [Header] SessionID =====
  3459. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3460. //===== [BODY (1/10)] DC_EVStatus =====
  3461. struct dinDC_EVStatusType *status;
  3462. status = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.DC_EVStatus;
  3463. PRINT_dinDC_EVStatusType(status);
  3464. //===== [BODY (2/10)] EVTargetCurrent =====
  3465. struct dinPhysicalValueType *obj;
  3466. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent;
  3467. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetCurrent: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3468. PRINT_dinPhysicalValueType_UNIT(obj);
  3469. //===== [BODY (3/10)] EVMaximumVoltageLimit =====
  3470. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed);
  3471. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit;
  3472. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumVoltageLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3473. PRINT_dinPhysicalValueType_UNIT(obj);
  3474. //===== [BODY (4/10)] EVMaximumCurrentLimit =====
  3475. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed);
  3476. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit;
  3477. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumCurrentLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3478. PRINT_dinPhysicalValueType_UNIT(obj);
  3479. //===== [BODY (5/10)] EVMaximumPowerLimit =====
  3480. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed);
  3481. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit;
  3482. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumPowerLimit: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3483. PRINT_dinPhysicalValueType_UNIT(obj);
  3484. //===== [BODY (6/10)] BulkChargingComplete =====
  3485. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed);
  3486. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete);
  3487. //===== [BODY (7/10)] ChargingComplete =====
  3488. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingComplete: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.ChargingComplete);
  3489. //===== [BODY (8/10)] RemainingTimeToFullSoC =====
  3490. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed);
  3491. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC;
  3492. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RemainingTimeToFullSoC: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3493. PRINT_dinPhysicalValueType_UNIT(obj);
  3494. //===== [BODY (9/10)] RemainingTimeToBulkSoC =====
  3495. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed);
  3496. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC;
  3497. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RemainingTimeToBulkSoC: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3498. PRINT_dinPhysicalValueType_UNIT(obj);
  3499. //===== [BODY (10/10)] EVTargetVoltage =====
  3500. obj = &exi_doc_DIN->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage;
  3501. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetVoltage: %d (DEC)\n", GetValue_dinPhysicalValueType(obj));
  3502. PRINT_dinPhysicalValueType_UNIT(obj);
  3503. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing CurrentDemandReq (%d-th)\n", cnt);
  3504. }
  3505. /*===========================================================================
  3506. FUNCTION: PRINT_XML_DOC_ISO1_CurrentDemandReq
  3507. DESCRIPTION:
  3508. PRE-CONDITION:
  3509. INPUT:
  3510. OUTPUT:
  3511. GLOBAL VARIABLES:
  3512. =============================================================================*/
  3513. void PRINT_XML_DOC_ISO1_CurrentDemandReq(struct iso1EXIDocument *exi_doc_ISO1)
  3514. {
  3515. //int i = 0;
  3516. static int cnt = 0;
  3517. cnt++;
  3518. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing CurrentDemandReq (%d-th)\n", cnt);
  3519. //===== [Header] SessionID =====
  3520. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3521. //===== [BODY (1/10)] DC_EVStatus =====
  3522. struct iso1DC_EVStatusType *status;
  3523. status = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.DC_EVStatus;
  3524. PRINT_iso1DC_EVStatusType(status);
  3525. //===== [BODY (2/10)] EVTargetCurrent =====
  3526. struct iso1PhysicalValueType *obj;
  3527. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVTargetCurrent;
  3528. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetCurrent: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3529. PRINT_iso1PhysicalValueType_UNIT(obj);
  3530. //===== [BODY (3/10)] EVMaximumVoltageLimit =====
  3531. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit_isUsed);
  3532. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumVoltageLimit;
  3533. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumVoltageLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3534. PRINT_iso1PhysicalValueType_UNIT(obj);
  3535. //===== [BODY (4/10)] EVMaximumCurrentLimit =====
  3536. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n",
  3537. exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit_isUsed);
  3538. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumCurrentLimit;
  3539. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumCurrentLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3540. PRINT_iso1PhysicalValueType_UNIT(obj);
  3541. //===== [BODY (5/10)] EVMaximumPowerLimit =====
  3542. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit_isUsed);
  3543. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVMaximumPowerLimit;
  3544. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVMaximumPowerLimit: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3545. PRINT_iso1PhysicalValueType_UNIT(obj);
  3546. //===== [BODY (6/10)] BulkChargingComplete =====
  3547. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete_isUsed);
  3548. DEBUG_PRINTF_EXI_ENGINE_DETAIL("BulkChargingComplete: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.BulkChargingComplete);
  3549. //===== [BODY (7/10)] ChargingComplete =====
  3550. DEBUG_PRINTF_EXI_ENGINE_DETAIL("ChargingComplete: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.ChargingComplete);
  3551. //===== [BODY (8/10)] RemainingTimeToFullSoC =====
  3552. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC_isUsed);
  3553. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.RemainingTimeToFullSoC;
  3554. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RemainingTimeToFullSoC: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3555. PRINT_iso1PhysicalValueType_UNIT(obj);
  3556. //===== [BODY (9/10)] RemainingTimeToBulkSoC =====
  3557. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVChargeParameter_isUsed: %d\n", exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC_isUsed);
  3558. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.RemainingTimeToBulkSoC;
  3559. DEBUG_PRINTF_EXI_ENGINE_DETAIL("RemainingTimeToBulkSoC: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3560. PRINT_iso1PhysicalValueType_UNIT(obj);
  3561. //===== [BODY (10/10)] EVTargetVoltage =====
  3562. obj = &exi_doc_ISO1->V2G_Message.Body.CurrentDemandReq.EVTargetVoltage;
  3563. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVTargetVoltage: %d (DEC)\n", GetValue_iso1PhysicalValueType(obj));
  3564. PRINT_iso1PhysicalValueType_UNIT(obj);
  3565. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing CurrentDemandReq (%d-th)\n", cnt);
  3566. }
  3567. /*===========================================================================
  3568. FUNCTION: PRINT_XML_DOC_ISO1_ChargingStatusReq
  3569. DESCRIPTION:
  3570. PRE-CONDITION:
  3571. INPUT:
  3572. OUTPUT:
  3573. GLOBAL VARIABLES:
  3574. =============================================================================*/
  3575. void PRINT_XML_DOC_ISO1_ChargingStatusReq(struct iso1EXIDocument *exi_doc_ISO1)
  3576. {
  3577. static int cnt = 0;
  3578. cnt++;
  3579. DEBUG_PRINTF_EXI_ENGINE_DETAIL(" [START] Parsing ChargingStatusReq (%d-th)\n", cnt);
  3580. //===== [Header] SessionID =====
  3581. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3582. //===== [BODY (0/0)] =====
  3583. //ISO1: no content
  3584. DEBUG_PRINTF_EXI_ENGINE_DETAIL("no content (ISO1)\n");
  3585. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing ChargingStatusReq (%d-th)\n", cnt);
  3586. }
  3587. /*===========================================================================
  3588. FUNCTION: PRINT_XML_DOC_DIN_WeldingDetectionReq
  3589. DESCRIPTION:
  3590. PRE-CONDITION:
  3591. INPUT:
  3592. OUTPUT:
  3593. GLOBAL VARIABLES:
  3594. =============================================================================*/
  3595. void PRINT_XML_DOC_DIN_WeldingDetectionReq(struct dinEXIDocument *exi_doc_DIN)
  3596. {
  3597. //int i = 0;
  3598. static int cnt = 0;
  3599. cnt++;
  3600. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing WeldingDetectionReq (%d-th)\n", cnt);
  3601. //===== [Header] SessionID =====
  3602. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3603. //===== [BODY (1/3)] DC_EVStatus =====
  3604. struct dinDC_EVStatusType *status;
  3605. status = &exi_doc_DIN->V2G_Message.Body.WeldingDetectionReq.DC_EVStatus;
  3606. PRINT_dinDC_EVStatusType(status);
  3607. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing WeldingDetectionReq (%d-th)\n", cnt);
  3608. }
  3609. /*===========================================================================
  3610. FUNCTION: PRINT_XML_DOC_ISO1_WeldingDetectionReq
  3611. DESCRIPTION:
  3612. PRE-CONDITION:
  3613. INPUT:
  3614. OUTPUT:
  3615. GLOBAL VARIABLES:
  3616. =============================================================================*/
  3617. void PRINT_XML_DOC_ISO1_WeldingDetectionReq(struct iso1EXIDocument *exi_doc_ISO1)
  3618. {
  3619. //int i = 0;
  3620. static int cnt = 0;
  3621. cnt++;
  3622. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing WeldingDetectionReq (%d-th)\n", cnt);
  3623. //===== [Header] SessionID =====
  3624. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3625. //===== [BODY (1/3)] DC_EVStatus =====
  3626. struct iso1DC_EVStatusType *status;
  3627. status = &exi_doc_ISO1->V2G_Message.Body.WeldingDetectionReq.DC_EVStatus;
  3628. PRINT_iso1DC_EVStatusType(status);
  3629. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing WeldingDetectionReq (%d-th)\n", cnt);
  3630. }
  3631. /*===========================================================================
  3632. FUNCTION: PRINT_XML_DOC_DIN_SessionStopReq
  3633. DESCRIPTION:
  3634. PRE-CONDITION:
  3635. INPUT:
  3636. OUTPUT:
  3637. GLOBAL VARIABLES:
  3638. =============================================================================*/
  3639. void PRINT_XML_DOC_DIN_SessionStopReq(struct dinEXIDocument *exi_doc_DIN)
  3640. {
  3641. //int i = 0;
  3642. static int cnt = 0;
  3643. cnt++;
  3644. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing SessionStopReq (%d-th)\n", cnt);
  3645. //===== [Header] SessionID =====
  3646. PRINT_V2G_MSG_din_Header(exi_doc_DIN);
  3647. //===== [BODY (0/0)] noContent =====
  3648. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionStopReq (%d-th)\n", cnt);
  3649. }
  3650. /*===========================================================================
  3651. FUNCTION: PRINT_XML_DOC_ISO1_SessionStopReq
  3652. DESCRIPTION:
  3653. PRE-CONDITION:
  3654. INPUT:
  3655. OUTPUT:
  3656. GLOBAL VARIABLES:
  3657. =============================================================================*/
  3658. void PRINT_XML_DOC_ISO1_SessionStopReq(struct iso1EXIDocument *exi_doc_ISO1)
  3659. {
  3660. //int i = 0;
  3661. static int cnt = 0;
  3662. cnt++;
  3663. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[START] Parsing SessionStopReq (%d-th)\n", cnt);
  3664. //===== [Header] SessionID =====
  3665. PRINT_V2G_MSG_iso1_Header(exi_doc_ISO1);
  3666. //===== [BODY (0/0)] noContent =====
  3667. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[END] Parsing SessionStopReq (%d-th)\n", cnt);
  3668. }
  3669. /*===========================================================================
  3670. FUNCTION: PRINT_V2GTP_STREAM
  3671. DESCRIPTION:
  3672. PRE-CONDITION:
  3673. INPUT:
  3674. OUTPUT:
  3675. GLOBAL VARIABLES:
  3676. =============================================================================*/
  3677. void PRINT_V2GTP_STREAM(bitstream_t *stream)
  3678. {
  3679. #if (DEBUG_PRINTF_EXI_ENGINE_SHOW == ENABLE)
  3680. int i = 0;
  3681. unsigned char buffer[1024] = {0};
  3682. DEBUG_PRINTF_EXI_ENGINE_DETAIL("========== Got a new V2GTP Message ==========\n");
  3683. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SIZE: %d (Bytes, DEC)\n", (int)stream->size);
  3684. for (i = 0; i < stream->size; i++)
  3685. {
  3686. sprintf((char*)buffer, "%s%02x ", buffer, stream->data[i]);
  3687. }
  3688. DEBUG_PRINTF_EXI_ENGINE_DETAIL("HEADER (HEX): %s\n", buffer);
  3689. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("EXI (HEX): \n");
  3690. #endif
  3691. }
  3692. /*===========================================================================
  3693. FUNCTION: API_V2GMSG_EXI_Decoder_AppProtocol
  3694. DESCRIPTION:
  3695. PRE-CONDITION:
  3696. 1. #define EXI_STREAM BYTE_ARRAY
  3697. INPUT:
  3698. 1. V2GTP_msg
  3699. 2. V2GTP_msg_length
  3700. OUTPUT:
  3701. 1. ccs_handshake //Share Memory
  3702. 2. V2gFlowStatus //Status Flag
  3703. GLOBAL VARIABLES:
  3704. 1. iStream
  3705. 2. exiDoc
  3706. =============================================================================*/
  3707. int API_V2GMSG_EXI_Decoder_AppProtocol(unsigned char *V2GTP_msg, unsigned int V2GTP_msg_length, struct appHandEXIDocument *exiDoc_handshake)
  3708. {
  3709. int errn = 0;
  3710. size_t pos = 0;
  3711. uint32_t payloadLengthDec = 0;
  3712. //Initialize iStream
  3713. iStream.size = V2GTP_msg_length; //V2GTP_MSG_RX_BUFFER_SIZE; //64*1024 = 65,536
  3714. iStream.pos = &pos;
  3715. iStream.data = V2GTP_msg;
  3716. //Initialize exiDoc
  3717. init_appHandEXIDocument(exiDoc_handshake);
  3718. //Print the original EXI message
  3719. PRINT_V2GTP_STREAM(&iStream);
  3720. //STEP 1: Parsing Header
  3721. errn = read_v2gtpHeader(iStream.data, &payloadLengthDec);
  3722. //TC_SECC_VTB_V2GTPSessionSetup_004
  3723. if (payloadLengthDec == 0)
  3724. {
  3725. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR][API_V2GMSG_EXI_Decoder_AppProtocol]payloadLengthDec = 0\n");
  3726. errn = -1;
  3727. }
  3728. if (errn == 0)
  3729. {
  3730. //STEP 2: Parsing Payload EXI Message
  3731. *iStream.pos = V2GTP_HEADER_LENGTH;
  3732. errn = decode_appHandExiDocument(&iStream, exiDoc_handshake);
  3733. if(errn == 0)
  3734. {
  3735. //Print the decoded XML Document
  3736. PRINT_XML_DOC_supportedAppProtocolReq(exiDoc_handshake);
  3737. //errn = SupportedAppProtocolRequest; //17 (define.h)
  3738. }
  3739. else
  3740. {
  3741. /* an error occured */
  3742. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR][API_V2GMSG_EXI_Decoder_AppProtocol]decode_appHandExiDocument()\n");
  3743. errn = -1;
  3744. }
  3745. }
  3746. return errn;
  3747. }
  3748. int API_V2GMSG_EXI_Encoder_AppProtocol(struct appHandEXIDocument *exi_doc, bitstream_t *exi_packet)
  3749. {
  3750. unsigned char buffer[1024]={0};
  3751. int i = 0;
  3752. int errn = 0;
  3753. size_t pos = 0;
  3754. exi_packet->pos = &pos;
  3755. //*exi_packet->pos = 0;
  3756. exi_packet->size = V2GTP_MSG_TX_BUFFER_SIZE; //(64*1024) //65,536 = 65.5KB
  3757. exi_packet->data = V2GTP_Tx_buf;
  3758. *exi_packet->pos = V2GTP_HEADER_LENGTH;
  3759. if( (errn = encode_appHandExiDocument(exi_packet, exi_doc)) == 0)
  3760. {
  3761. errn = write_v2gtpHeader(exi_packet->data, (*exi_packet->pos) - V2GTP_HEADER_LENGTH, V2GTP_EXI_TYPE);
  3762. //*exi_packet.pos = total length of the encoded V2GMSG.
  3763. //V2GTP_HEADER_LENGTH = 8 Bytes
  3764. }
  3765. exi_packet->size = *exi_packet->pos; //total length of the encoded V2GMSG.
  3766. DEBUG_PRINTF_EXI_ENGINE_DETAIL("----- supportedAppProtocolRes [START] -----\n");
  3767. DEBUG_PRINTF_EXI_ENGINE_DETAIL("SIZE: %d (Bytes, DEC)\n", (int)exi_packet->size);
  3768. for (i = 0; i < (int)exi_packet->size; i++)
  3769. {
  3770. sprintf((char*)buffer, "%s%02x ", buffer, exi_packet->data[i]);
  3771. }
  3772. DEBUG_PRINTF_EXI_ENGINE_DETAIL("HEADER (HEX): %s\n", buffer);
  3773. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EXI (HEX): \n");
  3774. DEBUG_PRINTF_EXI_ENGINE_DETAIL("----- supportedAppProtocolRes [END] -----\n");
  3775. return errn;
  3776. }
  3777. /*===========================================================================
  3778. FUNCTION: API_V2GMSG_EXI_Decoder_DIN
  3779. DESCRIPTION:
  3780. PRE-CONDITION:
  3781. INPUT:
  3782. OUTPUT:
  3783. GLOBAL VARIABLES:
  3784. =============================================================================*/
  3785. int API_V2GMSG_EXI_Decoder_DIN(unsigned char *V2GTP_msg, unsigned int V2GTP_msg_length, struct dinEXIDocument *exi_doc_DIN)
  3786. {
  3787. int errn = 0;
  3788. size_t pos = 0;
  3789. uint32_t payloadLengthDec = 0;
  3790. //Initialize iStream
  3791. iStream.size = V2GTP_msg_length; //V2GTP_MSG_RX_BUFFER_SIZE; //64*1024 = 65,536
  3792. iStream.pos = &pos;
  3793. iStream.data = V2GTP_msg;
  3794. iStream.buffer = 0;
  3795. iStream.capacity = 0;
  3796. //Print the original EXI message
  3797. PRINT_V2GTP_STREAM(&iStream);
  3798. //STEP 1: Parsing Header
  3799. errn = read_v2gtpHeader(iStream.data, &payloadLengthDec);
  3800. //TC_SECC_VTB_V2GTPSessionSetup_004
  3801. if (payloadLengthDec == 0)
  3802. {
  3803. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[Error] payloadLengthDec = 0\n");
  3804. errn = -1;
  3805. }
  3806. if (errn == 0)
  3807. {
  3808. //STEP 2: Parsing Payload EXI Message
  3809. *iStream.pos = V2GTP_HEADER_LENGTH;
  3810. errn = decode_dinExiDocument(&iStream, exi_doc_DIN);
  3811. //The "eventcode" inside this function could present which kind of message it is.
  3812. if (errn == 0)
  3813. {
  3814. // successfully received and parsed.
  3815. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("decode_dinExiDocument: %d (DEC) => OK!\n", errn);
  3816. errn = Check_V2G_Rx_Msg_Name_din(exi_doc_DIN);
  3817. if (errn < 0)
  3818. {
  3819. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] Check_V2G_Rx_Msg_Name_din: fail\n");
  3820. }
  3821. }
  3822. else
  3823. {
  3824. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] decode_dinExiDocument: %d (DEC)\n", errn);
  3825. errn = -1;
  3826. }
  3827. }
  3828. else
  3829. {
  3830. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR][API_V2GMSG_EXI_Decoder_DIN] read_v2gtpHeader: %d (DEC)\n", errn);
  3831. }
  3832. return errn;
  3833. }
  3834. /*===========================================================================
  3835. FUNCTION: API_V2GMSG_EXI_Decoder_ISO1
  3836. DESCRIPTION:
  3837. PRE-CONDITION:
  3838. INPUT:
  3839. OUTPUT:
  3840. GLOBAL VARIABLES:
  3841. =============================================================================*/
  3842. int API_V2GMSG_EXI_Decoder_ISO1(unsigned char *V2GTP_msg, unsigned int V2GTP_msg_length, struct iso1EXIDocument *exi_doc_ISO1)
  3843. {
  3844. int errn = 0;
  3845. size_t pos = 0;
  3846. uint32_t payloadLengthDec = 0;
  3847. //Initialize iStream
  3848. iStream.size = V2GTP_msg_length; //V2GTP_MSG_RX_BUFFER_SIZE; //64*1024 = 65,536
  3849. iStream.pos = &pos;
  3850. iStream.data = V2GTP_msg;
  3851. iStream.buffer = 0;
  3852. iStream.capacity = 0;
  3853. //Print the original EXI message
  3854. PRINT_V2GTP_STREAM(&iStream);
  3855. //STEP 1: Parsing Header
  3856. errn = read_v2gtpHeader(iStream.data, &payloadLengthDec);
  3857. //TC_SECC_VTB_V2GTPSessionSetup_004
  3858. if (payloadLengthDec == 0)
  3859. {
  3860. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[Error] payloadLengthDec = 0\n");
  3861. errn = -1;
  3862. }
  3863. if (errn == 0)
  3864. {
  3865. //STEP 2: Parsing Payload EXI Message
  3866. *iStream.pos = V2GTP_HEADER_LENGTH;
  3867. errn = decode_iso1ExiDocument(&iStream, exi_doc_ISO1);
  3868. //The "event code" inside this function could present which kind of message it is.
  3869. if (errn == 0)
  3870. {
  3871. // successfully received and parsed.
  3872. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("decode_iso1ExiDocument: %d (DEC) => OK!\n", errn);
  3873. errn = Check_V2G_Rx_Msg_Name_iso1(exi_doc_ISO1);
  3874. if (errn < 0)
  3875. {
  3876. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] Check_V2G_Rx_Msg_Name_din: fail\n");
  3877. }
  3878. }
  3879. else
  3880. {
  3881. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] decode_iso1ExiDocument: %d (DEC)\n", errn);
  3882. errn = -1;
  3883. }
  3884. }
  3885. else
  3886. {
  3887. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] read_v2gtpHeader: %d (DEC)\n", errn);
  3888. }
  3889. return errn;
  3890. }
  3891. /*===========================================================================
  3892. FUNCTION: API_V2GMSG_EXI_Decoder_ISO2
  3893. DESCRIPTION:
  3894. PRE-CONDITION:
  3895. INPUT:
  3896. OUTPUT:
  3897. GLOBAL VARIABLES:
  3898. =============================================================================*/
  3899. int API_V2GMSG_EXI_Decoder_ISO2(unsigned char *V2GTP_msg, unsigned int V2GTP_msg_length, struct iso2EXIDocument *exi_doc_ISO2)
  3900. {
  3901. int errn = 0;
  3902. size_t pos = 0;
  3903. uint32_t payloadLengthDec = 0;
  3904. //Initialize iStream
  3905. iStream.size = V2GTP_msg_length; //V2GTP_MSG_RX_BUFFER_SIZE; //64*1024 = 65,536
  3906. iStream.pos = &pos;
  3907. iStream.data = V2GTP_msg;
  3908. iStream.buffer = 0;
  3909. iStream.capacity = 0;
  3910. //Print the original EXI message
  3911. PRINT_V2GTP_STREAM(&iStream);
  3912. //STEP 1: Parsing Header
  3913. errn = read_v2gtpHeader(iStream.data, &payloadLengthDec);
  3914. //TC_SECC_VTB_V2GTPSessionSetup_004
  3915. if (payloadLengthDec == 0)
  3916. {
  3917. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[Error] payloadLengthDec = 0\n");
  3918. errn = -1;
  3919. }
  3920. if (errn == 0)
  3921. {
  3922. //STEP 2: Parsing Payload EXI Message
  3923. *iStream.pos = V2GTP_HEADER_LENGTH;
  3924. errn = decode_iso2ExiDocument(&iStream, exi_doc_ISO2);
  3925. //The "eventcode" inside this function could present which kind of message it is.
  3926. if (errn == 0)
  3927. {
  3928. // successfully received and parsed.
  3929. //DEBUG_PRINTF_EXI_ENGINE_DETAIL("decode_iso2ExiDocument: %d (DEC) => OK!\n", errn);
  3930. errn = Check_V2G_Rx_Msg_Name_iso2(exi_doc_ISO2);
  3931. if (errn < 0)
  3932. {
  3933. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] Check_V2G_Rx_Msg_Name_din: fail\n");
  3934. }
  3935. }
  3936. else
  3937. {
  3938. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] decode_iso2ExiDocument: %d (DEC)\n", errn);
  3939. }
  3940. }
  3941. else
  3942. {
  3943. DEBUG_PRINTF_EXI_ENGINE_DETAIL("[ERROR] read_v2gtpHeader: %d (DEC)\n", errn);
  3944. }
  3945. return errn;
  3946. }
  3947. /*===========================================================================
  3948. FUNCTION: PRINT_dinPhysicalValueType_UNIT
  3949. DESCRIPTION:
  3950. PRE-CONDITION:
  3951. INPUT:
  3952. OUTPUT:
  3953. GLOBAL VARIABLES:
  3954. =============================================================================*/
  3955. void PRINT_dinPhysicalValueType_UNIT(struct dinPhysicalValueType *obj)
  3956. {
  3957. if (obj->Unit_isUsed == TRUE)
  3958. {
  3959. switch (obj->Unit)
  3960. {
  3961. case dinunitSymbolType_h: // = 0,
  3962. {
  3963. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: h)");
  3964. break;
  3965. }
  3966. case dinunitSymbolType_m: // = 1,
  3967. {
  3968. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: m)");
  3969. break;
  3970. }
  3971. case dinunitSymbolType_s: // = 2,
  3972. {
  3973. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: s)");
  3974. break;
  3975. }
  3976. case dinunitSymbolType_A: // = 3,
  3977. {
  3978. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: A)");
  3979. break;
  3980. }
  3981. case dinunitSymbolType_Ah: // = 4,
  3982. {
  3983. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: Ah)");
  3984. break;
  3985. }
  3986. case dinunitSymbolType_V: // = 5,
  3987. {
  3988. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: V)");
  3989. break;
  3990. }
  3991. case dinunitSymbolType_VA: // = 6,
  3992. {
  3993. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: VA)");
  3994. break;
  3995. }
  3996. case dinunitSymbolType_W: // = 7,
  3997. {
  3998. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: W)");
  3999. break;
  4000. }
  4001. case dinunitSymbolType_W_s: // = 8,
  4002. {
  4003. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: W_s)");
  4004. break;
  4005. }
  4006. case dinunitSymbolType_Wh: // = 9
  4007. {
  4008. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: Wh)");
  4009. break;
  4010. }
  4011. default:
  4012. {
  4013. DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] unit: unexpected dinPhysicalValueType unit)");
  4014. break;
  4015. }
  4016. }
  4017. }
  4018. else
  4019. {
  4020. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: null)");
  4021. }
  4022. }
  4023. /*===========================================================================
  4024. FUNCTION: PRINT_iso1PhysicalValueType_UNIT
  4025. DESCRIPTION:
  4026. PRE-CONDITION:
  4027. INPUT:
  4028. OUTPUT:
  4029. GLOBAL VARIABLES:
  4030. =============================================================================*/
  4031. void PRINT_iso1PhysicalValueType_UNIT(struct iso1PhysicalValueType *obj)
  4032. {
  4033. switch (obj->Unit)
  4034. {
  4035. case iso1unitSymbolType_h: // = 0,
  4036. {
  4037. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: h)\n");
  4038. break;
  4039. }
  4040. case iso1unitSymbolType_m: // = 1,
  4041. {
  4042. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: m)\n");
  4043. break;
  4044. }
  4045. case iso1unitSymbolType_s: // = 2,
  4046. {
  4047. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: s)\n");
  4048. break;
  4049. }
  4050. case iso1unitSymbolType_A: // = 3,
  4051. {
  4052. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: A)\n");
  4053. break;
  4054. }
  4055. case iso1unitSymbolType_V: // = 4,
  4056. {
  4057. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: V)\n");
  4058. break;
  4059. }
  4060. case iso1unitSymbolType_W: // = 5,
  4061. {
  4062. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: W)\n");
  4063. break;
  4064. }
  4065. case iso1unitSymbolType_Wh: // = 6
  4066. {
  4067. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(unit: Wh)\n");
  4068. break;
  4069. }
  4070. default:
  4071. {
  4072. DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] unit: unexpected iso1PhysicalValueType unit)\n");
  4073. break;
  4074. }
  4075. }
  4076. }
  4077. /*===========================================================================
  4078. FUNCTION: GetValue_dinPhysicalValueType
  4079. DESCRIPTION:
  4080. PRE-CONDITION:
  4081. INPUT:
  4082. OUTPUT:
  4083. GLOBAL VARIABLES:
  4084. =============================================================================*/
  4085. int GetValue_dinPhysicalValueType(struct dinPhysicalValueType *obj)
  4086. {
  4087. int result;
  4088. result = (obj->Value) * pow(10, obj->Multiplier);
  4089. return result;
  4090. }
  4091. /*===========================================================================
  4092. FUNCTION: GetValue_iso1PhysicalValueType
  4093. DESCRIPTION:
  4094. PRE-CONDITION:
  4095. INPUT:
  4096. OUTPUT:
  4097. GLOBAL VARIABLES:
  4098. =============================================================================*/
  4099. int GetValue_iso1PhysicalValueType(struct iso1PhysicalValueType *obj)
  4100. {
  4101. int result;
  4102. result = (obj->Value) * pow(10, obj->Multiplier);
  4103. return result;
  4104. }
  4105. /*===========================================================================
  4106. FUNCTION: PRINT_dinDC_EVErrorCodeType
  4107. DESCRIPTION:
  4108. PRE-CONDITION:
  4109. INPUT:
  4110. OUTPUT:
  4111. GLOBAL VARIABLES:
  4112. =============================================================================*/
  4113. void PRINT_dinDC_EVErrorCodeType(struct dinDC_EVStatusType *status)
  4114. {
  4115. switch (status->EVErrorCode)
  4116. {
  4117. case dinDC_EVErrorCodeType_NO_ERROR: // = 0,
  4118. {
  4119. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NO_ERROR)");
  4120. break;
  4121. }
  4122. case dinDC_EVErrorCodeType_FAILED_RESSTemperatureInhibit: // = 1,
  4123. {
  4124. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_RESSTemperatureInhibit)");
  4125. break;
  4126. }
  4127. case dinDC_EVErrorCodeType_FAILED_EVShiftPosition: // = 2,
  4128. {
  4129. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVShiftPosition)");
  4130. break;
  4131. }
  4132. case dinDC_EVErrorCodeType_FAILED_ChargerConnectorLockFault: // = 3,
  4133. {
  4134. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(ChargerConnectorLockFault)");
  4135. break;
  4136. }
  4137. case dinDC_EVErrorCodeType_FAILED_EVRESSMalfunction: // = 4,
  4138. {
  4139. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVRESSMalfunction)");
  4140. break;
  4141. }
  4142. case dinDC_EVErrorCodeType_FAILED_ChargingCurrentdifferential: // = 5,
  4143. {
  4144. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingCurrentdifferential)");
  4145. break;
  4146. }
  4147. case dinDC_EVErrorCodeType_FAILED_ChargingVoltageOutOfRange: // = 6,
  4148. {
  4149. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingVoltageOutOfRange)");
  4150. break;
  4151. }
  4152. case dinDC_EVErrorCodeType_Reserved_A: // = 7,
  4153. {
  4154. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_A)");
  4155. break;
  4156. }
  4157. case dinDC_EVErrorCodeType_Reserved_B: // = 8,
  4158. {
  4159. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_B)");
  4160. break;
  4161. }
  4162. case dinDC_EVErrorCodeType_Reserved_C: // = 9,
  4163. {
  4164. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_C)");
  4165. break;
  4166. }
  4167. case dinDC_EVErrorCodeType_FAILED_ChargingSystemIncompatibility:// = 10,
  4168. {
  4169. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingSystemIncompatibility)");
  4170. break;
  4171. }
  4172. case dinDC_EVErrorCodeType_NoData: // = 11
  4173. {
  4174. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NoData)");
  4175. break;
  4176. }
  4177. default:
  4178. {
  4179. DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] Unexpected din EVErrorCode)");
  4180. break;
  4181. }
  4182. }
  4183. }
  4184. /*===========================================================================
  4185. FUNCTION: PRINT_iso1DC_EVErrorCodeType
  4186. DESCRIPTION:
  4187. PRE-CONDITION:
  4188. INPUT:
  4189. OUTPUT:
  4190. GLOBAL VARIABLES:
  4191. =============================================================================*/
  4192. void PRINT_iso1DC_EVErrorCodeType(struct iso1DC_EVStatusType *status)
  4193. {
  4194. switch (status->EVErrorCode)
  4195. {
  4196. case iso1DC_EVErrorCodeType_NO_ERROR: // = 0,
  4197. {
  4198. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NO_ERROR)");
  4199. break;
  4200. }
  4201. case iso1DC_EVErrorCodeType_FAILED_RESSTemperatureInhibit: // = 1,
  4202. {
  4203. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_RESSTemperatureInhibit)");
  4204. break;
  4205. }
  4206. case iso1DC_EVErrorCodeType_FAILED_EVShiftPosition: // = 2,
  4207. {
  4208. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVShiftPosition)");
  4209. break;
  4210. }
  4211. case iso1DC_EVErrorCodeType_FAILED_ChargerConnectorLockFault: // = 3,
  4212. {
  4213. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(ChargerConnectorLockFault)");
  4214. break;
  4215. }
  4216. case iso1DC_EVErrorCodeType_FAILED_EVRESSMalfunction: // = 4,
  4217. {
  4218. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_EVRESSMalfunction)");
  4219. break;
  4220. }
  4221. case iso1DC_EVErrorCodeType_FAILED_ChargingCurrentdifferential: // = 5,
  4222. {
  4223. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingCurrentdifferential)");
  4224. break;
  4225. }
  4226. case iso1DC_EVErrorCodeType_FAILED_ChargingVoltageOutOfRange: // = 6,
  4227. {
  4228. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingVoltageOutOfRange)");
  4229. break;
  4230. }
  4231. case iso1DC_EVErrorCodeType_Reserved_A: // = 7,
  4232. {
  4233. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_A)");
  4234. break;
  4235. }
  4236. case iso1DC_EVErrorCodeType_Reserved_B: // = 8,
  4237. {
  4238. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_B)");
  4239. break;
  4240. }
  4241. case iso1DC_EVErrorCodeType_Reserved_C: // = 9,
  4242. {
  4243. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(Reserved_C)");
  4244. break;
  4245. }
  4246. case iso1DC_EVErrorCodeType_FAILED_ChargingSystemIncompatibility:// = 10,
  4247. {
  4248. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(FAILED_ChargingSystemIncompatibility)");
  4249. break;
  4250. }
  4251. case iso1DC_EVErrorCodeType_NoData: // = 11
  4252. {
  4253. DEBUG_PRINTF_EXI_ENGINE_DETAIL("(NoData)");
  4254. break;
  4255. }
  4256. default:
  4257. {
  4258. DEBUG_PRINTF_EXI_ENGINE_DETAIL("([WARNING] Unexpected iso1 EVErrorCode)");
  4259. break;
  4260. }
  4261. }
  4262. }
  4263. /*===========================================================================
  4264. FUNCTION: PRINT_dinDC_EVStatusType
  4265. DESCRIPTION:
  4266. PRE-CONDITION:
  4267. INPUT:
  4268. OUTPUT:
  4269. GLOBAL VARIABLES:
  4270. =============================================================================*/
  4271. void PRINT_dinDC_EVStatusType(struct dinDC_EVStatusType *status)
  4272. {
  4273. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVStatus:\n");
  4274. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVReady = %d (DEC)\n", status->EVReady);
  4275. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVErrorCode = %d (DEC)\n", status->EVErrorCode);
  4276. PRINT_dinDC_EVErrorCodeType(status);
  4277. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRESSSOC = %d \%(DEC)\n", status->EVRESSSOC);
  4278. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVCabinConditioning = %d (DEC)\n", status->EVCabinConditioning);
  4279. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVCabinConditioning_isUsed = %d (DEC)\n", status->EVCabinConditioning_isUsed);
  4280. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRESSConditioning = %d (DEC)\n", status->EVRESSConditioning);
  4281. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRESSConditioning_isUsed = %d (DEC)\n", status->EVRESSConditioning_isUsed);
  4282. }
  4283. /*===========================================================================
  4284. FUNCTION: PRINT_iso1DC_EVStatusType
  4285. DESCRIPTION:
  4286. PRE-CONDITION:
  4287. INPUT:
  4288. OUTPUT:
  4289. GLOBAL VARIABLES:
  4290. =============================================================================*/
  4291. void PRINT_iso1DC_EVStatusType(struct iso1DC_EVStatusType *status)
  4292. {
  4293. DEBUG_PRINTF_EXI_ENGINE_DETAIL("DC_EVStatus:\n");
  4294. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVReady = %d (DEC)\n", status->EVReady);
  4295. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVErrorCode = %d (DEC)\n", status->EVErrorCode);
  4296. PRINT_iso1DC_EVErrorCodeType(status);
  4297. DEBUG_PRINTF_EXI_ENGINE_DETAIL("EVRESSSOC = %d \%(DEC)\n", status->EVRESSSOC);
  4298. }