evse_serviceMethods.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * Copyright (C) 2007-2012 Siemens AG
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published
  6. * by the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*******************************************************************
  18. *
  19. * @author Sebastian.Kaebisch.EXT@siemens.com
  20. * @version 0.6
  21. * @contact Joerg.Heuer@siemens.com
  22. *
  23. ********************************************************************/
  24. #include "v2g_serviceMethods.h"
  25. #include "v2g_serviceDataTypes.h"
  26. #include <stdio.h>
  27. static void printBinaryArray(uint8_t* byte, uint32_t len);
  28. int sessionSetup(struct MessageHeaderType* header, struct SessionSetupReqType* param, struct SessionSetupResType* result)
  29. {
  30. printf("EVSE side: sessionSetup called\n" );
  31. printf("\tReceived data:\n");
  32. printf("\tHeader SessionID=");
  33. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  34. printf("\t\t EVCCID=%d\n",param->EVCCID.data[0]);
  35. /* generate an unique sessionID */
  36. header->SessionID.data[0] = 0;
  37. header->SessionID.data[1] = 0;
  38. header->SessionID.data[2] = 0;
  39. header->SessionID.data[3] = 0;
  40. header->SessionID.data[4] = 0;
  41. header->SessionID.data[5] = 0;
  42. header->SessionID.data[6] = 0;
  43. header->SessionID.data[7] = 10;
  44. header->SessionID.arraylen.data=8;
  45. /* Prepare data for EV */
  46. result->ResponseCode = OK_responseCodeType;
  47. result->EVSEID.data[0]=1;
  48. result->EVSEID.arraylen.data=1;
  49. result->DateTimeNow=123456789;
  50. result->isused.DateTimeNow=1;
  51. return 0;
  52. }
  53. int serviceDiscovery(struct MessageHeaderType* header, struct ServiceDiscoveryReqType* param, struct ServiceDiscoveryResType* result)
  54. {
  55. printf("EVSE side: serviceDiscovery called\n" );
  56. printf("\tReceived data:\n");
  57. printf("\tHeader SessionID=");
  58. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  59. printf("\t\t ServiceCategory=%d\n", param->ServiceCategory);
  60. result->isused.ServiceList=0; /* we do not provide VAS */
  61. result->ResponseCode= OK_responseCodeType;
  62. result->ChargeService.EnergyTransferType = AC_single_DC_core_EVSESupportedEnergyTransferType;
  63. result->ChargeService.ServiceTag.ServiceID=1; /* ID of the charge service */
  64. result->ChargeService.ServiceTag.ServiceName.data[0]='A';
  65. result->ChargeService.ServiceTag.ServiceName.data[1]='C';
  66. result->ChargeService.ServiceTag.ServiceName.data[2]='_';
  67. result->ChargeService.ServiceTag.ServiceName.data[3]='D';
  68. result->ChargeService.ServiceTag.ServiceName.data[4]='C';
  69. result->ChargeService.ServiceTag.ServiceName.arraylen.data=5;
  70. result->ChargeService.ServiceTag.isused.ServiceName=1;
  71. result->ChargeService.ServiceTag.isused.ServiceCategory=0;
  72. result->ChargeService.ServiceTag.isused.ServiceScope=0;
  73. result->ChargeService.FreeService = 1;
  74. result->PaymentOptions.PaymentOption[0] = ExternalPayment_paymentOptionType; /* EVSE handles the payment */
  75. result->PaymentOptions.arraylen.PaymentOption=1;
  76. result->ServiceList.Service[0].FreeService=1;
  77. result->ServiceList.Service[0].ServiceTag.ServiceID=22; /* ID of the charge service */
  78. result->ServiceList.Service[0].ServiceTag.ServiceName.data[0]='W';
  79. result->ServiceList.Service[0].ServiceTag.ServiceName.data[1]='W';
  80. result->ServiceList.Service[0].ServiceTag.ServiceName.data[2]='W';
  81. result->ServiceList.Service[0].ServiceTag.ServiceName.arraylen.data=3;
  82. result->ServiceList.Service[0].ServiceTag.ServiceCategory=Internet_serviceCategoryType;
  83. result->ServiceList.Service[0].ServiceTag.isused.ServiceName=1;
  84. result->ServiceList.Service[0].ServiceTag.isused.ServiceCategory=1;
  85. result->ServiceList.Service[0].ServiceTag.isused.ServiceScope=0;
  86. result->ServiceList.arraylen.Service=1;
  87. result->isused.ServiceList=1;
  88. return 0;
  89. }
  90. int servicePaymentSelection(struct MessageHeaderType* header, struct ServicePaymentSelectionReqType* param, struct ServicePaymentSelectionResType* result)
  91. {
  92. printf("EVSE side: servicePaymentSelection called\n" );
  93. printf("\tReceived data:\n");
  94. printf("\tHeader SessionID=");
  95. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  96. if(param->SelectedPaymentOption == ExternalPayment_paymentOptionType)
  97. printf("\t\t SelectedPaymentOption=ExternalPayment\n");
  98. printf("\t\t ServiceID=%d\n",param->SelectedServiceList.SelectedService[0].ServiceID);
  99. result->ResponseCode = OK_responseCodeType;
  100. return 0;
  101. }
  102. int paymentDetails(struct MessageHeaderType* header, struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result)
  103. {
  104. return 0;
  105. }
  106. int chargeParameterDiscovery(struct MessageHeaderType* header, struct ChargeParameterDiscoveryReqType* param, struct ChargeParameterDiscoveryResType* result)
  107. {
  108. struct PhysicalValueType f;
  109. printf("EVSE side: chargeParameterDiscovery called\n" );
  110. printf("\tReceived data:\n");
  111. printf("\t\t EVRequestedEnergyTransferType=%d\n",param->EVRequestedEnergyTransferType);
  112. /* check,if DC or AC is requested */
  113. if(param->EVRequestedEnergyTransferType==DC_core_EVRequestedEnergyTransferType || param->isused.DC_EVChargeParameter==1)
  114. {
  115. printf("\t\t EVStatus:\n");
  116. printf("\t\t\t EVReady=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVReady);
  117. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVRESSSOC);
  118. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVErrorCode);
  119. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVRESSConditioning);
  120. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVCabinConditioning);
  121. printf("\t\t EVMaximumCurrentLimit=%d\n", param->DC_EVChargeParameter->EVMaximumCurrentLimit.Value);
  122. printf("\t\t EVMaximumPowerLimit=%d\n", param->DC_EVChargeParameter->EVMaximumPowerLimit.Value);
  123. printf("\t\t EVMaximumVoltageLimit=%d\n", param->DC_EVChargeParameter->EVMaximumVoltageLimit.Value);
  124. printf("\t\t EVEnergyCapacity=%d\n", param->DC_EVChargeParameter->EVEnergyCapacity.Value);
  125. printf("\t\t EVEnergyRequest=%d\n", param->DC_EVChargeParameter->EVEnergyRequest.Value);
  126. printf("\t\t FullSOC=%d\n", param->DC_EVChargeParameter->FullSOC);
  127. printf("\t\t BulkSOC=%d\n", param->DC_EVChargeParameter->BulkSOC);
  128. result->ResponseCode = OK_responseCodeType;
  129. result->isused.SAScheduleList=0;
  130. result->isused.DC_EVSEChargeParameter = 1;
  131. result->isused.AC_EVSEChargeParameter = 0;
  132. result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  133. result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEIsolationStatus = Safe_isolationLevelType;
  134. result->DC_EVSEChargeParameter->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  135. f.Multiplier = 0;
  136. f.Unit = A_unitSymbolType;
  137. f.Value = 50;
  138. result->DC_EVSEChargeParameter->EVSEMaximumCurrentLimit=f;
  139. f.Unit = W_unitSymbolType;
  140. f.Value = 20000;
  141. result->DC_EVSEChargeParameter->EVSEMaximumPowerLimit=f;
  142. result->DC_EVSEChargeParameter->isused.EVSEMaximumPowerLimit=1;
  143. f.Unit = V_unitSymbolType;
  144. f.Value = 400;
  145. result->DC_EVSEChargeParameter->EVSEMaximumVoltageLimit=f;
  146. f.Unit = A_unitSymbolType;
  147. f.Value = 5;
  148. result->DC_EVSEChargeParameter->EVSEMinimumCurrentLimit=f;
  149. f.Unit = V_unitSymbolType;
  150. f.Value = 200;
  151. result->DC_EVSEChargeParameter->EVSEMinimumVoltageLimit=f;
  152. f.Unit = A_unitSymbolType;
  153. f.Value = 2;
  154. result->DC_EVSEChargeParameter->EVSECurrentRegulationTolerance=f;
  155. result->DC_EVSEChargeParameter->isused.EVSECurrentRegulationTolerance=1;
  156. f.Unit = A_unitSymbolType;
  157. f.Value = 1;
  158. result->DC_EVSEChargeParameter->EVSEPeakCurrentRipple=f;
  159. f.Unit = W_unitSymbolType;
  160. f.Value = 5000;
  161. result->DC_EVSEChargeParameter->EVSEEnergyToBeDelivered=f;
  162. result->DC_EVSEChargeParameter->isused.EVSEEnergyToBeDelivered=1;
  163. /* set up a PMax schedule */
  164. result->isused.SAScheduleList=1;
  165. result->SAScheduleList->SAScheduleTuple[0].SAScheduleTupleID=10;
  166. result->SAScheduleList->SAScheduleTuple[0].isused.SalesTariff=0; /* no tariffs */
  167. /* set up two PMax entries */
  168. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleID=20;
  169. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax=20000;
  170. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
  171. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax=0;
  172. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1200; /* 20 min */
  173. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
  174. /* set up two PMax entries */
  175. result->SAScheduleList->SAScheduleTuple[1].SAScheduleTupleID=15;
  176. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleID=30;
  177. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].PMax=10000;
  178. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
  179. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].PMax=0;
  180. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1800; /* 30 min */
  181. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
  182. result->SAScheduleList->arraylen.SAScheduleTuple=2; /* we used only 1 tuple */
  183. } else { /* AC related */
  184. printf("\t\t DepartureTime=%d\n", param->AC_EVChargeParameter->DepartureTime);
  185. printf("\t\t EAmount=%d\n", param->AC_EVChargeParameter->EAmount.Value);
  186. printf("\t\t EVMaxCurrent=%d\n", param->AC_EVChargeParameter->EVMaxCurrent.Value);
  187. printf("\t\t EVMaxVoltage=%d\n", param->AC_EVChargeParameter->EVMaxVoltage.Value);
  188. printf("\t\t EVMinCurrent=%d\n", param->AC_EVChargeParameter->EVMinCurrent.Value);
  189. result->ResponseCode = OK_responseCodeType;
  190. result->isused.AC_EVSEChargeParameter = 1;
  191. result->isused.DC_EVSEChargeParameter = 0;
  192. result->isused.SAScheduleList = 0;
  193. result->AC_EVSEChargeParameter->AC_EVSEStatus.PowerSwitchClosed=1;
  194. result->AC_EVSEChargeParameter->AC_EVSEStatus.RCD=1;
  195. result->AC_EVSEChargeParameter->AC_EVSEStatus.ShutDownTime=12345;
  196. result->AC_EVSEChargeParameter->AC_EVSEStatus.StopCharging=0;
  197. f.Multiplier = 0;
  198. f.Unit = A_unitSymbolType;
  199. f.Value = 100;
  200. result->AC_EVSEChargeParameter->EVSEMaxCurrent=f;
  201. f.Unit = V_unitSymbolType;
  202. f.Value = 200;
  203. result->AC_EVSEChargeParameter->EVSEMaxVoltage=f;
  204. f.Unit = A_unitSymbolType;
  205. f.Value = 300;
  206. result->AC_EVSEChargeParameter->EVSEMinCurrent=f;
  207. /* no sales schedule used */
  208. result->isused.SAScheduleList=0;
  209. }
  210. return 0;
  211. }
  212. int powerDelivery(struct MessageHeaderType* header, struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result)
  213. {
  214. size_t i;
  215. printf("EVSE side: powerDelivery called\n" );
  216. printf("\tReceived data:\n");
  217. printf("\t\t\t ReadyToChargeState=%d\n", param->ReadyToChargeState);
  218. if(param->isused.DC_EVPowerDeliveryParameter)
  219. {
  220. printf("\t\t EVStatus:\n");
  221. printf("\t\t\t EVReady=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVReady);
  222. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVRESSSOC);
  223. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVErrorCode);
  224. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVRESSConditioning);
  225. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVCabinConditioning);
  226. if(param->isused.ChargingProfile)
  227. {
  228. printf("\t\t\tChargingProfile:\n");
  229. printf("\t\t\t SAScheduleTupleID=%d\n",param->ChargingProfile.SAScheduleTupleID );
  230. for(i=0;i<param->ChargingProfile.arraylen.ProfileEntry;i++)
  231. {
  232. printf("\t\t\t Entry#%d\n",i);
  233. printf("\t\t\t\t ChargingProfileEntryMaxPower=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxPower);
  234. printf("\t\t\t\t ChargingProfileEntryStart=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryStart);
  235. }
  236. }
  237. result->ResponseCode = OK_responseCodeType;
  238. result->DC_EVSEStatus->EVSEIsolationStatus =1;
  239. result->DC_EVSEStatus->isused.EVSEIsolationStatus = 1;
  240. result->DC_EVSEStatus->EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  241. result->isused.DC_EVSEStatus=1;
  242. result->isused.AC_EVSEStatus=0;
  243. } else {
  244. result->ResponseCode = OK_responseCodeType;
  245. result->AC_EVSEStatus->PowerSwitchClosed=1;
  246. result->AC_EVSEStatus->RCD=1;
  247. result->AC_EVSEStatus->ShutDownTime=12345;
  248. result->AC_EVSEStatus->StopCharging=1;
  249. result->isused.AC_EVSEStatus=1;
  250. result->isused.DC_EVSEStatus=0;
  251. }
  252. return 0;
  253. }
  254. int chargingStatus(struct MessageHeaderType* header, struct ChargingStatusReqType* param, struct ChargingStatusResType* result)
  255. {
  256. printf("EVSE side: chargingStatus called\n" );
  257. result->ResponseCode=OK_responseCodeType;
  258. result->EVSEID.data[0]=1;
  259. result->EVSEID.arraylen.data=1;
  260. result->AC_EVSEStatus.PowerSwitchClosed=1;
  261. result->AC_EVSEStatus.RCD=1;
  262. result->AC_EVSEStatus.ShutDownTime=12345;
  263. result->AC_EVSEStatus.StopCharging=1;
  264. result->ReceiptRequired=0;
  265. result->EVSEMaxCurrent.Multiplier = 2;
  266. result->EVSEMaxCurrent.Unit = A_unitSymbolType;
  267. result->EVSEMaxCurrent.isused.Unit=1;
  268. result->EVSEMaxCurrent.Value = 400;
  269. result->isused.EVSEMaxCurrent=1;
  270. result->SAScheduleTupleID=10;
  271. result->isused.SAScheduleTupleID=1;
  272. result->isused.MeterInfo=1;
  273. result->MeterInfo.MeterID.arraylen.data=1;
  274. result->MeterInfo.MeterID.data[0]=2;
  275. result->MeterInfo.MeterReading.Multiplier = 0;
  276. result->MeterInfo.MeterReading.Unit = A_unitSymbolType;
  277. result->MeterInfo.MeterReading.Value = 500;
  278. result->MeterInfo.MeterStatus = 4321;
  279. result->MeterInfo.TMeter =123456789;
  280. result->MeterInfo.isused.MeterReading = 1;
  281. result->MeterInfo.isused.MeterStatus=1;
  282. result->MeterInfo.isused.TMeter=1;
  283. result->MeterInfo.isused.SigMeterReading=0;
  284. return 0;
  285. }
  286. int meteringReceipt(struct MessageHeaderType* header, struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result)
  287. {
  288. printf("EVSE side: meteringReceipt called\n" );
  289. printf("\tReceived data:\n");
  290. printf("\t\t SAScheduleTupleID=%d\n", param->SAScheduleTupleID);
  291. printf("\t\t MeterInfo.MeterStatus=%d\n", param->MeterInfo.MeterStatus);
  292. printf("\t\t MeterInfo.MeterID=%d\n", param->MeterInfo.MeterID.data[0]);
  293. printf("\t\t MeterInfo.isused.MeterReading=%d\n", param->MeterInfo.isused.MeterReading);
  294. printf("\t\t MeterReading.Value=%d\n", param->MeterInfo.MeterReading.Value);
  295. printf("\t\t MeterInfo.TMeter=%d\n", param->MeterInfo.TMeter);
  296. result->ResponseCode = OK_responseCodeType;
  297. result->AC_EVSEStatus.PowerSwitchClosed=1;
  298. result->AC_EVSEStatus.RCD=1;
  299. result->AC_EVSEStatus.ShutDownTime=12345;
  300. result->AC_EVSEStatus.StopCharging=1;
  301. return 0;
  302. }
  303. int cableCheck(struct MessageHeaderType* header, struct CableCheckReqType* param, struct CableCheckResType* result)
  304. {
  305. printf("EVSE side: cableCheck called\n" );
  306. printf("\tReceived data:\n");
  307. printf("\t\t EVStatus:\n");
  308. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  309. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  310. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  311. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
  312. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
  313. result->ResponseCode = OK_responseCodeType;
  314. result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
  315. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  316. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  317. return 0;
  318. }
  319. int preCharge(struct MessageHeaderType* header, struct PreChargeReqType* param, struct PreChargeResType* result)
  320. {
  321. struct PhysicalValueType float_type;
  322. printf("EVSE side: preCharge called\n" );
  323. printf("\tReceived data:\n");
  324. printf("\t\t EVStatus:\n");
  325. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  326. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  327. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  328. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
  329. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
  330. result->ResponseCode = OK_responseCodeType;
  331. result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
  332. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  333. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  334. float_type.Multiplier = 0;
  335. float_type.Unit = V_unitSymbolType;
  336. float_type.Value = 100;
  337. result->EVSEPresentVoltage = float_type;
  338. return 0;
  339. }
  340. int currentDemand(struct MessageHeaderType* header, struct CurrentDemandReqType* param, struct CurrentDemandResType* result)
  341. {
  342. struct PhysicalValueType f;
  343. printf("EVSE side: currentDemand called\n" );
  344. printf("\tReceived data:\n");
  345. printf("\t\t EVStatus:\n");
  346. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  347. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  348. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  349. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
  350. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
  351. printf("\t\t EVTargetCurrent=%d\n", param->EVTargetCurrent.Value);
  352. printf("\t\t EVMaximumVoltageLimit=%d\n", param->EVMaximumVoltageLimit.Value);
  353. printf("\t\t EVMaximumPowerLimit=%d\n", param->EVMaximumPowerLimit.Value);
  354. printf("\t\t EVMaximumCurrentLimit=%d\n", param->EVMaximumCurrentLimit.Value);
  355. printf("\t\t BulkChargingComplete=%d\n", param->BulkChargingComplete);
  356. printf("\t\t ChargingComplete=%d\n", param->ChargingComplete);
  357. printf("\t\t RemainingTimeToFullSoC=%d\n", param->RemainingTimeToFullSoC.Value);
  358. printf("\t\t RemainingTimeToBulkSoC=%d\n", param->RemainingTimeToBulkSoC.Value);
  359. printf("\t\t EVTargetVoltage=%d\n", param->EVTargetVoltage.Value);
  360. result->ResponseCode = OK_responseCodeType;
  361. result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
  362. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  363. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  364. f.Multiplier = 0;
  365. f.Unit = V_unitSymbolType;
  366. f.Value = 400;
  367. result->EVSEPresentVoltage=f;
  368. f.Unit = A_unitSymbolType;
  369. f.Value = 45;
  370. result->EVSEPresentCurrent=f;
  371. result->EVSECurrentLimitAchieved=0;
  372. result->EVSEVoltageLimitAchieved=1;
  373. result->EVSEPowerLimitAchieved=0;
  374. f.Unit = V_unitSymbolType;
  375. f.Value = 400;
  376. result->EVSEMaximumVoltageLimit=f;
  377. result->isused.EVSEMaximumVoltageLimit=1;
  378. f.Unit = A_unitSymbolType;
  379. f.Value = 50;
  380. result->EVSEMaximumCurrentLimit=f;
  381. result->isused.EVSEMaximumCurrentLimit=1;
  382. f.Unit = W_unitSymbolType;
  383. f.Value = 20000;
  384. result->EVSEMaximumPowerLimit=f;
  385. result->isused.EVSEMaximumPowerLimit=1;
  386. return 0;
  387. }
  388. int weldingDetection(struct MessageHeaderType* header, struct WeldingDetectionReqType* param, struct WeldingDetectionResType* result)
  389. {
  390. printf("EVSE side: weldingDetection called\n" );
  391. printf("\tReceived data:\n");
  392. printf("\t\t EVStatus:\n");
  393. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  394. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  395. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  396. printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
  397. printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
  398. result->ResponseCode = OK_responseCodeType;
  399. result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
  400. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  401. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  402. result->EVSEPresentVoltage.Value = 123;
  403. result->EVSEPresentVoltage.Unit = V_unitSymbolType;
  404. result->EVSEPresentVoltage.Multiplier = 0;
  405. return 0;
  406. }
  407. int sessionStop(struct MessageHeaderType* header, struct SessionStopType* param, struct SessionStopResType* result)
  408. {
  409. printf("EVSE side: sessionStop called\n" );
  410. result->ResponseCode = OK_responseCodeType;
  411. return 0;
  412. }
  413. int serviceDetail(struct MessageHeaderType* header, struct ServiceDetailReqType* param, struct ServiceDetailResType* result)
  414. {
  415. return 0;
  416. }
  417. int contractAuthentication(struct MessageHeaderType* header, struct ContractAuthenticationReqType* param, struct ContractAuthenticationResType* result)
  418. {
  419. return 0;
  420. }
  421. int certificateUpdate(struct MessageHeaderType* header, struct CertificateUpdateReqType* param, struct CertificateUpdateResType* result)
  422. {
  423. return 0;
  424. }
  425. int certificateInstallation(struct MessageHeaderType* header, struct CertificateInstallationReqType* param, struct CertificateInstallationResType* result)
  426. {
  427. printf("EVSE: certificateInstallation called\n" );
  428. printf("\tReceived data:\n");
  429. printf("\t\t\t OEMProvisioningCert=%d\n", param->OEMProvisioningCert.data[0]);
  430. printf("\t\t\t RootCertificateID[0]=%d\n", param->ListOfRootCertificateIDs.RootCertificateID[0].data[0]);
  431. printf("\t\t\t DHParams[0]=%d\n", param->DHParams.data[0]);
  432. /* result->ContractEncryptionEncryptedPrivateKey.data[0]=200;
  433. result->ContractEncryptionEncryptedPrivateKey.arraylen.data=1;
  434. */
  435. result->ContractID.data[0]=50;
  436. result->ContractID.arraylen.data=1;
  437. result->ContractSignatureEncryptedPrivateKey.data[0]=12;
  438. result->ContractSignatureEncryptedPrivateKey.arraylen.data=1;
  439. result->ContractSignatureCertChain.Certificate.data[0]=40;
  440. result->ContractSignatureCertChain.Certificate.arraylen.data=1;
  441. result->ContractSignatureCertChain.SubCertificates.arraylen.Certificate=2;
  442. result->ContractSignatureCertChain.SubCertificates.Certificate[0].data[0]=20;
  443. result->ContractSignatureCertChain.SubCertificates.Certificate[0].arraylen.data=1;
  444. result->ContractSignatureCertChain.SubCertificates.Certificate[1].data[0]=40;
  445. result->ContractSignatureCertChain.SubCertificates.Certificate[1].arraylen.data=1;
  446. result->ContractSignatureCertChain.isused.SubCertificates=1;
  447. result->DHParams.data[0]=99;
  448. result->DHParams.arraylen.data=1;
  449. result->attr_Id.data[0]=33;
  450. result->attr_Id.arraylen.data=1;
  451. result->ResponseCode = OK_responseCodeType;
  452. return 0;
  453. }
  454. static void printBinaryArray(uint8_t* byte, uint32_t len) {
  455. unsigned int i;
  456. for(i=0; i<len; i++) {
  457. printf("%d ",byte[i]);
  458. }
  459. printf("\n");
  460. }