evse_serviceMethods.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  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@siemens.com
  20. * @version 0.8
  21. * @contact Joerg.Heuer@siemens.com
  22. *
  23. ********************************************************************/
  24. #include "v2g_serviceMethods.h"
  25. #include "v2g_dataTypes.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] = 1;
  37. header->SessionID.data[1] = 2;
  38. header->SessionID.data[2] = 3;
  39. header->SessionID.data[3] = 4;
  40. header->SessionID.data[4] = 5;
  41. header->SessionID.data[5] = 6;
  42. header->SessionID.data[6] = 7;
  43. header->SessionID.data[7] = 8;
  44. header->SessionID.arraylen.data=8;
  45. /* Prepare data for EV */
  46. result->ResponseCode = OK_responseCodeType;
  47. result->EVSEID.data[1]=20;
  48. result->EVSEID.arraylen.data=2;
  49. result->EVSETimeStamp=123456789;
  50. result->isused.EVSETimeStamp=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.SupportedEnergyTransferMode = AC_single_phase_core_EnergyTransferModeType; */
  63. result->ChargeService.ServiceID=1; /* ID of the charge service */
  64. result->ChargeService.ServiceName.data[0]='A';
  65. result->ChargeService.ServiceName.data[1]='C';
  66. result->ChargeService.ServiceName.data[2]='_';
  67. result->ChargeService.ServiceName.data[3]='D';
  68. result->ChargeService.ServiceName.data[4]='C';
  69. result->ChargeService.ServiceName.arraylen.data=5;
  70. result->ChargeService.isused.ServiceName=1;
  71. result->ChargeService.isused.ServiceScope=1;
  72. result->ChargeService.FreeService = 1;
  73. result->ChargeService.ServiceCategory = EVCharging_serviceCategoryType;
  74. result->ChargeService.ServiceScope.data[0] = 100;
  75. result->ChargeService.ServiceScope.arraylen.data = 1;
  76. result->ChargeService.SupportedEnergyTransferMode.EnergyTransferMode[0] = DC_combo_core_EnergyTransferModeType;
  77. result->ChargeService.SupportedEnergyTransferMode.EnergyTransferMode[1] = AC_single_phase_core_EnergyTransferModeType;
  78. result->ChargeService.SupportedEnergyTransferMode.arraylen.EnergyTransferMode=2;
  79. result->PaymentOptionList.PaymentOption[0] = ExternalPayment_paymentOptionType; /* EVSE handles the payment */
  80. result->PaymentOptionList.PaymentOption[1] = Contract_paymentOptionType;
  81. result->PaymentOptionList.arraylen.PaymentOption=2;
  82. if(param->ServiceCategory==Internet_serviceCategoryType || param->ServiceCategory==OtherCustom_serviceCategoryType || param->isused.ServiceCategory==0)
  83. {
  84. result->ServiceList.Service[0].FreeService=1;
  85. result->ServiceList.Service[0].ServiceID=22; /* ID of the charge service */
  86. result->ServiceList.Service[0].ServiceName.data[0]='W';
  87. result->ServiceList.Service[0].ServiceName.data[1]='W';
  88. result->ServiceList.Service[0].ServiceName.data[2]='W';
  89. result->ServiceList.Service[0].ServiceName.arraylen.data=3;
  90. result->ServiceList.Service[0].ServiceCategory=Internet_serviceCategoryType;
  91. result->ServiceList.Service[0].isused.ServiceName=1;
  92. result->ServiceList.Service[0].isused.ServiceScope=0;
  93. result->ServiceList.Service[1].FreeService=0;
  94. result->ServiceList.Service[1].ServiceID=33; /* ID of the charge service */
  95. result->ServiceList.Service[1].ServiceName.data[0]='H';
  96. result->ServiceList.Service[1].ServiceName.data[1]='T';
  97. result->ServiceList.Service[1].ServiceName.data[2]='T';
  98. result->ServiceList.Service[1].ServiceName.data[3]='P';
  99. result->ServiceList.Service[1].ServiceName.data[4]='S';
  100. result->ServiceList.Service[1].ServiceName.arraylen.data=5;
  101. result->ServiceList.Service[1].ServiceCategory=Internet_serviceCategoryType;
  102. result->ServiceList.Service[1].isused.ServiceName=1;
  103. result->ServiceList.Service[1].isused.ServiceScope=0;
  104. result->ServiceList.arraylen.Service=2;
  105. result->isused.ServiceList=1;
  106. } else {
  107. result->isused.ServiceList=0; /* no value added service requested */
  108. }
  109. return 0;
  110. }
  111. int paymentServiceSelection(struct MessageHeaderType* header, struct PaymentServiceSelectionReqType* param, struct PaymentServiceSelectionResType* result)
  112. {
  113. size_t i;
  114. printf("EVSE side: servicePaymentSelection called\n" );
  115. printf("\tReceived data:\n");
  116. printf("\tHeader SessionID=");
  117. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  118. if(param->SelectedPaymentOption == ExternalPayment_paymentOptionType)
  119. printf("\t\t SelectedPaymentOption=ExternalPayment\n");
  120. for(i=0; i<param->SelectedServiceList.arraylen.SelectedService;i++)
  121. {
  122. printf("\t\t ServiceID=%d\n",param->SelectedServiceList.SelectedService[i].ServiceID);
  123. if( param->SelectedServiceList.SelectedService[i].isused.ParameterSetID)
  124. printf("\t\t ParameterSetID=%d\n",param->SelectedServiceList.SelectedService[i].ParameterSetID);
  125. }
  126. result->ResponseCode = OK_responseCodeType;
  127. return 0;
  128. }
  129. int paymentDetails(struct MessageHeaderType* header, struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result)
  130. {
  131. printf("EVSE side: paymentDetails called\n" );
  132. printf("\tReceived data:\n");
  133. printf("\t\t eMAID=%d\n", param->eMAID.data[0]);
  134. printf("\t\t ID=%c%c\n", param->ContractSignatureCertChain.attr_Id.data[0], param->ContractSignatureCertChain.attr_Id.data[1]);
  135. printf("\t\t Certificate=%c%c\n", param->ContractSignatureCertChain.Certificate.data[0], param->ContractSignatureCertChain.Certificate.data[1]);
  136. printf("\t\t SubCertificate 1=%c%c\n", param->ContractSignatureCertChain.SubCertificates.Certificate[0].data[0], param->ContractSignatureCertChain.SubCertificates.Certificate[0].data[1]);
  137. printf("\t\t SubCertificate 2=%c%c%c\n", param->ContractSignatureCertChain.SubCertificates.Certificate[1].data[0], param->ContractSignatureCertChain.SubCertificates.Certificate[1].data[1], param->ContractSignatureCertChain.SubCertificates.Certificate[1].data[2]);
  138. result->ResponseCode = OK_responseCodeType;
  139. result->GenChallenge.data[0]=1;
  140. result->GenChallenge.arraylen.data=1;
  141. result->EVSETimeStamp=123456;
  142. return 0;
  143. }
  144. int chargeParameterDiscovery(struct MessageHeaderType* header, struct ChargeParameterDiscoveryReqType* param, struct ChargeParameterDiscoveryResType* result)
  145. {
  146. struct PhysicalValueType f;
  147. printf("EVSE side: chargeParameterDiscovery called\n" );
  148. printf("\tReceived data:\n");
  149. printf("\t\t EVRequestedEnergyTransferType=%d\n",param->RequestedEnergyTransferMode);
  150. /* check,if DC or AC is requested */
  151. if(param->RequestedEnergyTransferMode==DC_core_EnergyTransferModeType || param->isused.DC_EVChargeParameter==1)
  152. {
  153. printf("\t\t MaxEntriesSAScheduleTuple=%d\n", param->MaxEntriesSAScheduleTuple);
  154. printf("\t\t EVStatus:\n");
  155. printf("\t\t\t EVReady=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVReady);
  156. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVRESSSOC);
  157. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVErrorCode);
  158. printf("\t\t DepartureTime=%d\n", param->DC_EVChargeParameter->DepartureTime);
  159. printf("\t\t EVMaximumCurrentLimit=%d\n", param->DC_EVChargeParameter->EVMaximumCurrentLimit.Value);
  160. printf("\t\t EVMaximumPowerLimit=%d\n", param->DC_EVChargeParameter->EVMaximumPowerLimit.Value);
  161. printf("\t\t EVMaximumVoltageLimit=%d\n", param->DC_EVChargeParameter->EVMaximumVoltageLimit.Value);
  162. printf("\t\t EVEnergyCapacity=%d\n", param->DC_EVChargeParameter->EVEnergyCapacity.Value);
  163. printf("\t\t EVEnergyRequest=%d\n", param->DC_EVChargeParameter->EVEnergyRequest.Value);
  164. printf("\t\t FullSOC=%d\n", param->DC_EVChargeParameter->FullSOC);
  165. printf("\t\t BulkSOC=%d\n", param->DC_EVChargeParameter->BulkSOC);
  166. result->ResponseCode = OK_responseCodeType;
  167. result->EVSEProcessing = Finished_EVSEProcessingType;
  168. result->isused.DC_EVSEChargeParameter = 1;
  169. result->isused.AC_EVSEChargeParameter = 0;
  170. result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  171. result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEIsolationStatus = Valid_isolationLevelType;
  172. result->DC_EVSEChargeParameter->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  173. result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSENotification = None_EVSENotificationType;
  174. result->DC_EVSEChargeParameter->DC_EVSEStatus.NotificationMaxDelay = 10;
  175. f.Multiplier = 0;
  176. f.Unit = A_unitSymbolType;
  177. f.Value = 50;
  178. result->DC_EVSEChargeParameter->EVSEMaximumCurrentLimit=f;
  179. f.Unit = W_unitSymbolType;
  180. f.Value = 20000;
  181. result->DC_EVSEChargeParameter->EVSEMaximumPowerLimit=f;
  182. f.Unit = V_unitSymbolType;
  183. f.Value = 400;
  184. result->DC_EVSEChargeParameter->EVSEMaximumVoltageLimit=f;
  185. f.Unit = A_unitSymbolType;
  186. f.Value = 5;
  187. result->DC_EVSEChargeParameter->EVSEMinimumCurrentLimit=f;
  188. f.Unit = V_unitSymbolType;
  189. f.Value = 200;
  190. result->DC_EVSEChargeParameter->EVSEMinimumVoltageLimit=f;
  191. f.Unit = A_unitSymbolType;
  192. f.Value = 2;
  193. result->DC_EVSEChargeParameter->EVSECurrentRegulationTolerance=f;
  194. result->DC_EVSEChargeParameter->isused.EVSECurrentRegulationTolerance=1;
  195. f.Unit = A_unitSymbolType;
  196. f.Value = 1;
  197. result->DC_EVSEChargeParameter->EVSEPeakCurrentRipple=f;
  198. f.Unit = W_unitSymbolType;
  199. f.Value = 5000;
  200. result->DC_EVSEChargeParameter->EVSEEnergyToBeDelivered=f;
  201. result->DC_EVSEChargeParameter->isused.EVSEEnergyToBeDelivered=1;
  202. /* set up a PMax schedule */
  203. result->isused.SAScheduleList=1;
  204. result->SAScheduleList->SAScheduleTuple[0].SAScheduleTupleID=10;
  205. result->SAScheduleList->SAScheduleTuple[0].isused.SalesTariff=0; /* no tariffs */
  206. /* set up two PMax entries: #1 */
  207. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Value=20000;
  208. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Unit = W_unitSymbolType;
  209. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Multiplier =0;
  210. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
  211. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.isused.duration=0;
  212. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Value=0;
  213. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Unit = W_unitSymbolType;
  214. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Multiplier =0;
  215. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1200; /* 20 min */
  216. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.isused.duration=0;
  217. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
  218. /* #2 */
  219. result->SAScheduleList->SAScheduleTuple[1].SAScheduleTupleID=15;
  220. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].PMax.Value=10000;
  221. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].PMax.Unit = W_unitSymbolType;
  222. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].PMax.Multiplier =0;
  223. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
  224. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.isused.duration=0;
  225. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].PMax.Value=0;
  226. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].PMax.Unit = W_unitSymbolType;
  227. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].PMax.Multiplier =1;
  228. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1800; /* 30 min */
  229. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.duration=3600;
  230. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.isused.duration=1;
  231. result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
  232. result->SAScheduleList->arraylen.SAScheduleTuple=2; /* we used 2 tuple */
  233. } else { /* AC related */
  234. printf("\t\t DepartureTime=%d\n", param->AC_EVChargeParameter->DepartureTime);
  235. printf("\t\t EAmount=%d\n", param->AC_EVChargeParameter->EAmount.Value);
  236. printf("\t\t EVMaxCurrent=%d\n", param->AC_EVChargeParameter->EVMaxCurrent.Value);
  237. printf("\t\t EVMaxVoltage=%d\n", param->AC_EVChargeParameter->EVMaxVoltage.Value);
  238. printf("\t\t EVMinCurrent=%d\n", param->AC_EVChargeParameter->EVMinCurrent.Value);
  239. result->ResponseCode = OK_responseCodeType;
  240. result->EVSEProcessing = Finished_EVSEProcessingType;
  241. result->isused.AC_EVSEChargeParameter = 1;
  242. result->isused.DC_EVSEChargeParameter = 0;
  243. result->AC_EVSEChargeParameter->AC_EVSEStatus.RCD=1;
  244. result->AC_EVSEChargeParameter->AC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  245. result->AC_EVSEChargeParameter->AC_EVSEStatus.NotificationMaxDelay=123;
  246. f.Multiplier = 0;
  247. f.Unit = A_unitSymbolType;
  248. f.Value = 100;
  249. result->AC_EVSEChargeParameter->EVSEMaxCurrent=f;
  250. f.Unit = V_unitSymbolType;
  251. f.Value = 300;
  252. result->AC_EVSEChargeParameter->EVSENominalVoltage=f;
  253. result->EVSEProcessing=1;
  254. /* set up a PMax schedule */
  255. result->isused.SAScheduleList=1;
  256. result->SAScheduleList->SAScheduleTuple[0].SAScheduleTupleID=10;
  257. result->SAScheduleList->SAScheduleTuple[0].isused.SalesTariff=0; /* no tariffs */
  258. /* set up two PMax entries: #1 */
  259. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Value=20000;
  260. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Unit = W_unitSymbolType;
  261. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax.Multiplier =0;
  262. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
  263. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.isused.duration=0;
  264. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Value=0;
  265. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Unit = W_unitSymbolType;
  266. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax.Multiplier =0;
  267. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1200; /* 20 min */
  268. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.isused.duration=0;
  269. result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
  270. result->SAScheduleList->arraylen.SAScheduleTuple=1;
  271. result->isused.SAScheduleList=1;
  272. result->SAScheduleList->SAScheduleTuple[0].isused.SalesTariff=1;
  273. /* set up sale entries */
  274. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->NumEPriceLevels=2;
  275. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->isused.NumEPriceLevels=1;
  276. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffID=20;
  277. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->attr_Id.data[0]=100;
  278. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->attr_Id.arraylen.data=1;
  279. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->isused.attr_Id=1;
  280. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].EPriceLevel=2;
  281. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].isused.EPriceLevel=1;
  282. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].isused.ConsumptionCost=0;
  283. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].RelativeTimeInterval.start=0;
  284. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].RelativeTimeInterval.duration=10;
  285. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[0].RelativeTimeInterval.isused.duration=1;
  286. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].EPriceLevel=3;
  287. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].RelativeTimeInterval.start=11;
  288. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].RelativeTimeInterval.duration=10;
  289. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].RelativeTimeInterval.isused.duration=1;
  290. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].Cost[0].amount=10;
  291. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].Cost[0].amountMultiplier=1;
  292. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].Cost[0].isused.amountMultiplier=1;
  293. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].Cost[0].costKind=RenewableGenerationPercentage_costKindType;
  294. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].startValue.Value=123;
  295. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].ConsumptionCost[0].arraylen.Cost=1;
  296. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].isused.EPriceLevel=1;
  297. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].isused.ConsumptionCost=1;
  298. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->SalesTariffEntry[1].arraylen.ConsumptionCost=1;
  299. result->SAScheduleList->SAScheduleTuple[0].SalesTariff->arraylen.SalesTariffEntry=2;
  300. result->SAScheduleList->arraylen.SAScheduleTuple=1;
  301. }
  302. return 0;
  303. }
  304. int powerDelivery(struct MessageHeaderType* header, struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result)
  305. {
  306. size_t i;
  307. printf("EVSE side: powerDelivery called\n" );
  308. printf("\tReceived data:\n");
  309. printf("\t\t ChargeProgress=%d\n", param->ChargeProgress);
  310. printf("\t\t SAScheduleTupleID=%d\n", param->SAScheduleTupleID);
  311. if(param->isused.DC_EVPowerDeliveryParameter)
  312. {
  313. printf("\t\t EVStatus:\n");
  314. printf("\t\t\t EVReady=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVReady);
  315. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVRESSSOC);
  316. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVErrorCode);
  317. printf("\t\t BulkChargingComplete=%d\n", param->DC_EVPowerDeliveryParameter->BulkChargingComplete);
  318. printf("\t\t ChargingComplete=%d\n", param->DC_EVPowerDeliveryParameter->ChargingComplete);
  319. if(param->isused.ChargingProfile)
  320. {
  321. printf("\t\t\tChargingProfile:\n");
  322. printf("\t\t\t SAScheduleTupleID=%d\n",param->SAScheduleTupleID );
  323. for(i=0;i<param->ChargingProfile.arraylen.ProfileEntry;i++)
  324. {
  325. printf("\t\t\t Entry#%d\n",i);
  326. printf("\t\t\t\t ChargingProfileEntryMaxPower=%d (%d %d) \n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxPower.Value, param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxPower.Unit, param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxPower.Multiplier);
  327. printf("\t\t\t\t ChargingProfileEntryStart=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryStart);
  328. printf("\t\t\t\t ChargingProfileEntryMaxNumberOfPhasesInUse=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxNumberOfPhasesInUse);
  329. }
  330. }
  331. result->ResponseCode = OK_responseCodeType;
  332. result->DC_EVSEStatus->EVSEIsolationStatus =0;
  333. result->DC_EVSEStatus->isused.EVSEIsolationStatus = 1;
  334. result->DC_EVSEStatus->EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  335. result->DC_EVSEStatus->EVSENotification=None_EVSENotificationType;
  336. result->DC_EVSEStatus->NotificationMaxDelay=123;
  337. result->isused.DC_EVSEStatus=1;
  338. result->isused.AC_EVSEStatus=0;
  339. } else {
  340. result->ResponseCode = OK_responseCodeType;
  341. result->AC_EVSEStatus->RCD=0;
  342. result->AC_EVSEStatus->EVSENotification=3;
  343. result->AC_EVSEStatus->NotificationMaxDelay=12;
  344. result->isused.AC_EVSEStatus=1;
  345. result->isused.DC_EVSEStatus=0;
  346. }
  347. return 0;
  348. }
  349. int chargingStatus(struct MessageHeaderType* header, struct ChargingStatusReqType* param, struct ChargingStatusResType* result)
  350. {
  351. printf("EVSE side: chargingStatus called\n" );
  352. result->ResponseCode=OK_responseCodeType;
  353. result->EVSEID.data[0]=12;
  354. result->EVSEID.arraylen.data=1;
  355. result->AC_EVSEStatus.RCD=1;
  356. result->AC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  357. result->AC_EVSEStatus.NotificationMaxDelay=123;
  358. result->ReceiptRequired=1;
  359. result->isused.ReceiptRequired=1;
  360. result->EVSEMaxCurrent.Multiplier = 2;
  361. result->EVSEMaxCurrent.Unit = A_unitSymbolType;
  362. result->EVSEMaxCurrent.Value = 400;
  363. result->isused.EVSEMaxCurrent=1;
  364. result->SAScheduleTupleID=10;
  365. result->isused.MeterInfo=1;
  366. result->MeterInfo.MeterID.arraylen.data=1;
  367. result->MeterInfo.MeterID.data[0]=2;
  368. result->MeterInfo.MeterReading = 5000;
  369. result->MeterInfo.MeterStatus = 4321;
  370. result->MeterInfo.TMeter =123456789;
  371. result->MeterInfo.SigMeterReading.data[0]=123;
  372. result->MeterInfo.SigMeterReading.arraylen.data=1;
  373. result->MeterInfo.isused.MeterReading = 1;
  374. result->MeterInfo.isused.MeterStatus=1;
  375. result->MeterInfo.isused.TMeter=1;
  376. result->MeterInfo.isused.SigMeterReading=1;
  377. return 0;
  378. }
  379. int meteringReceipt(struct MessageHeaderType* header, struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result)
  380. {
  381. printf("EVSE side: meteringReceipt called\n" );
  382. printf("\tReceived data:\n");
  383. printf("\t\t ID=%c%c%c\n", param->attr_Id.data[0],param->attr_Id.data[1],param->attr_Id.data[2]);
  384. printf("\t\t SAScheduleTupleID=%d\n", param->SAScheduleTupleID);
  385. printf("\t\t SessionID=%d\n", param->SessionID.data[1]);
  386. printf("\t\t MeterInfo.MeterStatus=%d\n", param->MeterInfo.MeterStatus);
  387. printf("\t\t MeterInfo.MeterID=%d\n", param->MeterInfo.MeterID.data[0]);
  388. printf("\t\t MeterInfo.isused.MeterReading=%d\n", param->MeterInfo.isused.MeterReading);
  389. printf("\t\t MeterReading.Value=%d\n", param->MeterInfo.MeterReading);
  390. printf("\t\t MeterInfo.TMeter=%d\n", param->MeterInfo.TMeter);
  391. result->ResponseCode = OK_responseCodeType;
  392. result->AC_EVSEStatus->RCD=1;
  393. result->AC_EVSEStatus->EVSENotification=None_EVSENotificationType;
  394. result->AC_EVSEStatus->NotificationMaxDelay=123;
  395. return 0;
  396. }
  397. int cableCheck(struct MessageHeaderType* header, struct CableCheckReqType* param, struct CableCheckResType* result)
  398. {
  399. printf("EVSE side: cableCheck called\n" );
  400. printf("\tReceived data:\n");
  401. printf("\t\t EVStatus:\n");
  402. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  403. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  404. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  405. result->ResponseCode = OK_responseCodeType;
  406. result->EVSEProcessing = Finished_EVSEProcessingType;
  407. result->DC_EVSEStatus.EVSEIsolationStatus= Valid_isolationLevelType;
  408. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  409. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  410. result->DC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  411. result->DC_EVSEStatus.NotificationMaxDelay=1234;
  412. return 0;
  413. }
  414. int preCharge(struct MessageHeaderType* header, struct PreChargeReqType* param, struct PreChargeResType* result)
  415. {
  416. struct PhysicalValueType float_type;
  417. printf("EVSE side: preCharge called\n" );
  418. printf("\tReceived data:\n");
  419. printf("\t\t EVStatus:\n");
  420. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  421. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  422. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  423. printf("\t\t EVTargetCurrent=%d (%d %d)\n", param->EVTargetCurrent.Value,param->EVTargetCurrent.Unit, param->EVTargetCurrent.Multiplier);
  424. printf("\t\t EVTargetVoltage=%d (%d %d)\n", param->EVTargetVoltage.Value, param->EVTargetVoltage.Unit, param->EVTargetVoltage.Multiplier);
  425. result->ResponseCode = OK_responseCodeType;
  426. result->DC_EVSEStatus.EVSEIsolationStatus= Valid_isolationLevelType;
  427. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  428. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  429. result->DC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  430. result->DC_EVSEStatus.NotificationMaxDelay=1234;
  431. float_type.Multiplier = 0;
  432. float_type.Unit = V_unitSymbolType;
  433. float_type.Value = 100;
  434. result->EVSEPresentVoltage = float_type;
  435. return 0;
  436. }
  437. int currentDemand(struct MessageHeaderType* header, struct CurrentDemandReqType* param, struct CurrentDemandResType* result)
  438. {
  439. struct PhysicalValueType f;
  440. printf("EVSE side: currentDemand called\n" );
  441. printf("\tReceived data:\n");
  442. printf("\t\t EVStatus:\n");
  443. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  444. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  445. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  446. printf("\t\t EVTargetCurrent=%d\n", param->EVTargetCurrent.Value);
  447. printf("\t\t EVMaximumVoltageLimit=%d\n", param->EVMaximumVoltageLimit.Value);
  448. printf("\t\t EVMaximumPowerLimit=%d\n", param->EVMaximumPowerLimit.Value);
  449. printf("\t\t EVMaximumCurrentLimit=%d\n", param->EVMaximumCurrentLimit.Value);
  450. printf("\t\t BulkChargingComplete=%d\n", param->BulkChargingComplete);
  451. printf("\t\t ChargingComplete=%d\n", param->ChargingComplete);
  452. printf("\t\t RemainingTimeToFullSoC=%d\n", param->RemainingTimeToFullSoC.Value);
  453. printf("\t\t RemainingTimeToBulkSoC=%d\n", param->RemainingTimeToBulkSoC.Value);
  454. printf("\t\t EVTargetVoltage=%d\n", param->EVTargetVoltage.Value);
  455. result->ResponseCode = OK_responseCodeType;
  456. result->DC_EVSEStatus.EVSEIsolationStatus= Valid_isolationLevelType;
  457. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  458. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  459. result->DC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  460. result->DC_EVSEStatus.NotificationMaxDelay=1234;
  461. f.Multiplier = 0;
  462. f.Unit = V_unitSymbolType;
  463. f.Value = 400;
  464. result->EVSEPresentVoltage=f;
  465. f.Unit = A_unitSymbolType;
  466. f.Value = 45;
  467. result->EVSEPresentCurrent=f;
  468. result->EVSECurrentLimitAchieved=0;
  469. result->EVSEVoltageLimitAchieved=1;
  470. result->EVSEPowerLimitAchieved=0;
  471. f.Unit = V_unitSymbolType;
  472. f.Value = 400;
  473. result->EVSEMaximumVoltageLimit=f;
  474. result->isused.EVSEMaximumVoltageLimit=1;
  475. f.Unit = A_unitSymbolType;
  476. f.Value = 50;
  477. result->EVSEMaximumCurrentLimit=f;
  478. result->isused.EVSEMaximumCurrentLimit=1;
  479. f.Unit = W_unitSymbolType;
  480. f.Value = 20000;
  481. result->EVSEMaximumPowerLimit=f;
  482. result->isused.EVSEMaximumPowerLimit=1;
  483. result->EVSEID.data[0]=12;
  484. result->EVSEID.arraylen.data=1;
  485. result->SAScheduleTupleID = 123;
  486. result->isused.MeterInfo=1;
  487. result->MeterInfo.MeterID.arraylen.data=1;
  488. result->MeterInfo.MeterID.data[0]=2;
  489. result->MeterInfo.MeterReading = 500;
  490. result->MeterInfo.MeterStatus = 4321;
  491. result->MeterInfo.TMeter =123456789;
  492. result->MeterInfo.isused.MeterReading = 1;
  493. result->MeterInfo.isused.MeterStatus=1;
  494. result->MeterInfo.isused.TMeter=1;
  495. result->MeterInfo.isused.SigMeterReading=0;
  496. result->ReceiptRequired = 1;
  497. result->isused.ReceiptRequired=1;
  498. return 0;
  499. }
  500. int weldingDetection(struct MessageHeaderType* header, struct WeldingDetectionReqType* param, struct WeldingDetectionResType* result)
  501. {
  502. printf("EVSE side: weldingDetection called\n" );
  503. printf("\tReceived data:\n");
  504. printf("\t\t EVStatus:\n");
  505. printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
  506. printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
  507. printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
  508. result->ResponseCode = OK_responseCodeType;
  509. result->DC_EVSEStatus.EVSEIsolationStatus= Valid_isolationLevelType;
  510. result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
  511. result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
  512. result->DC_EVSEStatus.EVSENotification=None_EVSENotificationType;
  513. result->DC_EVSEStatus.NotificationMaxDelay=123;
  514. result->EVSEPresentVoltage.Value = 1234;
  515. result->EVSEPresentVoltage.Unit = V_unitSymbolType;
  516. result->EVSEPresentVoltage.Multiplier = 0;
  517. return 0;
  518. }
  519. int sessionStop(struct MessageHeaderType* header, struct SessionStopReqType* param, struct SessionStopResType* result)
  520. {
  521. printf("EVSE side: sessionStop called\n" );
  522. printf("\tReceived data:\n");
  523. printf("\tHeader SessionID=");
  524. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  525. printf("\t\t ChargingSession=%d\n", param->ChargingSession);
  526. result->ResponseCode = OK_responseCodeType;
  527. return 0;
  528. }
  529. int serviceDetail(struct MessageHeaderType* header, struct ServiceDetailReqType* param, struct ServiceDetailResType* result)
  530. {
  531. printf("EVSE side: serviceDetail called\n" );
  532. printf("\tReceived data:\n");
  533. printf("\tHeader SessionID=");
  534. printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
  535. printf("\t\t ServiceDetailID=%d\n", param->ServiceID);
  536. result->ServiceID = 1234;
  537. /* Parameter Set 1*/
  538. result->ServiceParameterList.ParameterSet[0].ParameterSetID = 1;
  539. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[0] = 'P';
  540. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[1] = 'r';
  541. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[2] = 'o';
  542. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[3] = 't';
  543. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[4] = 'o';
  544. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[5] = 'c';
  545. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[6] = 'o';
  546. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.data[7] = 'l';
  547. result->ServiceParameterList.ParameterSet[0].Parameter[0].attr_Name.arraylen.data = 8;
  548. result->ServiceParameterList.ParameterSet[0].Parameter[0].intValue=15119;
  549. result->ServiceParameterList.ParameterSet[0].Parameter[0].isused.intValue=1;
  550. result->ServiceParameterList.ParameterSet[0].Parameter[1].attr_Name.data[0] = 'N';
  551. result->ServiceParameterList.ParameterSet[0].Parameter[1].attr_Name.data[1] = 'a';
  552. result->ServiceParameterList.ParameterSet[0].Parameter[1].attr_Name.data[2] = 'm';
  553. result->ServiceParameterList.ParameterSet[0].Parameter[1].attr_Name.data[3] = 'e';
  554. result->ServiceParameterList.ParameterSet[0].Parameter[1].attr_Name.arraylen.data = 4;
  555. result->ServiceParameterList.ParameterSet[0].Parameter[1].stringValue.data[0] = 'V';
  556. result->ServiceParameterList.ParameterSet[0].Parameter[1].stringValue.data[1] = '2';
  557. result->ServiceParameterList.ParameterSet[0].Parameter[1].stringValue.data[2] = 'G';
  558. result->ServiceParameterList.ParameterSet[0].Parameter[1].stringValue.arraylen.data = 3;
  559. result->ServiceParameterList.ParameterSet[0].Parameter[1].isused.stringValue=1;
  560. result->ServiceParameterList.ParameterSet[0].arraylen.Parameter = 2;
  561. /* Parameter Set 2 */
  562. result->ServiceParameterList.ParameterSet[1].ParameterSetID = 2;
  563. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[0] = 'C';
  564. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[1] = 'h';
  565. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[2] = 'a';
  566. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[3] = 'n';
  567. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[4] = 'n';
  568. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[5] = 'e';
  569. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.data[6] = 'l';
  570. result->ServiceParameterList.ParameterSet[1].Parameter[0].attr_Name.arraylen.data = 7;
  571. result->ServiceParameterList.ParameterSet[1].Parameter[0].physicalValue.Value=1234;
  572. result->ServiceParameterList.ParameterSet[1].Parameter[0].physicalValue.Unit=m_unitSymbolType;
  573. result->ServiceParameterList.ParameterSet[1].Parameter[0].physicalValue.Multiplier=0;
  574. result->ServiceParameterList.ParameterSet[1].Parameter[0].isused.physicalValue=1;
  575. result->ServiceParameterList.ParameterSet[1].arraylen.Parameter =1;
  576. result->ServiceParameterList.arraylen.ParameterSet = 2;
  577. result->isused.ServiceParameterList = 1;
  578. result->ResponseCode = OK_responseCodeType;
  579. return 0;
  580. }
  581. int authorization(struct MessageHeaderType* header, struct AuthorizationReqType* param, struct AuthorizationResType* result)
  582. {
  583. printf("EVSE: contractAuthentication called\n" );
  584. printf("\tReceived data:\n");
  585. if(param->isused.GenChallenge)
  586. printf("\t\t\t GenChallenge=%d\n", param->GenChallenge.data[0]);
  587. if(param->isused.attr_Id)
  588. printf("\t\t\t ID=%c%c%c\n", param->attr_Id.data[0],param->attr_Id.data[1],param->attr_Id.data[2]);
  589. result->ResponseCode=OK_responseCodeType;
  590. result->EVSEProcessing=Finished_EVSEProcessingType;
  591. return 0;
  592. }
  593. int certificateUpdate(struct MessageHeaderType* header, struct CertificateUpdateReqType* param, struct CertificateUpdateResType* result)
  594. {
  595. return 0;
  596. }
  597. int certificateInstallation(struct MessageHeaderType* header, struct CertificateInstallationReqType* param, struct CertificateInstallationResType* result)
  598. {
  599. return 0;
  600. }
  601. static void printBinaryArray(uint8_t* byte, uint32_t len) {
  602. unsigned int i;
  603. for(i=0; i<len; i++) {
  604. printf("%d ",byte[i]);
  605. }
  606. printf("\n");
  607. }