mirror of
https://github.com/Martin-P/OpenV2G.git
synced 2024-11-08 12:45:42 +00:00
git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@72 d9f2db14-54d0-4bde-b00c-16405c910529
This commit is contained in:
parent
a342317852
commit
c4fcca04a4
7 changed files with 0 additions and 2963 deletions
|
@ -1,185 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Sebastian.Kaebisch.EXT@siemens.com
|
||||
* @@version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
|
||||
|
||||
/* includes for the application handshake protocol */
|
||||
#include "appHand_service.h"
|
||||
#include "appHand_dataTypes.h"
|
||||
|
||||
#include "evse_server.h"
|
||||
#include "v2g_service.h"
|
||||
#include "v2g_serviceDispatcher.h"
|
||||
#include "v2gtp.h"
|
||||
|
||||
#define MAX_BYTE_SIZE 64
|
||||
#define MAX_STRING_SIZE 64
|
||||
#define MAX_STREAM_SIZE 100
|
||||
|
||||
|
||||
static int appHandshakeHandler(struct EXIDatabinder* appHandService, uint8_t* inStream, uint16_t sizeInStream, uint8_t* outStream, uint16_t* outStreamLength);
|
||||
static void printASCIIString(uint32_t* string, uint32_t len);
|
||||
|
||||
int testV2GService(uint8_t* inStream, uint16_t inStreamLength, uint8_t* outStream, uint16_t* outStreamLength)
|
||||
{
|
||||
static uint8_t byte_array[MAX_BYTE_SIZE]; /* define MAX_BYTE_SIZE before*/
|
||||
static uint32_t string_array[MAX_STRING_SIZE]; /* define MAX_STRING_SIZE before*/
|
||||
uint16_t exiMsgLength;
|
||||
|
||||
struct EXIDatabinder appHandService;
|
||||
struct EXIService service;
|
||||
|
||||
static uint8_t isHandshake = 1;
|
||||
|
||||
/* BINARY memory setup */
|
||||
bytes_t bytes = { MAX_BYTE_SIZE, byte_array, 0 };
|
||||
|
||||
/* STRING memory setup */
|
||||
string_ucs_t string = { MAX_STRING_SIZE, string_array, 0 };
|
||||
|
||||
/**********************************************
|
||||
* Init V2G server and initialize array types *
|
||||
* for the EXI decoding as well as the offset *
|
||||
* for the transportation header *
|
||||
**********************************************/
|
||||
|
||||
init_v2gservice(&service, bytes, string, V2GTP_HEADER_LENGTH);
|
||||
|
||||
/* check, if the DoIP header is correct and determine payload */
|
||||
if(read_v2gtpHeader(inStream,inStreamLength, &exiMsgLength))
|
||||
{
|
||||
/* v2gtp header not correct */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Here, it is assumed the first message is always the application handshake protocol.
|
||||
* The successor messages are 15118 charging based messages and handled by the message
|
||||
* dispatcher. */
|
||||
|
||||
if(isHandshake)
|
||||
{
|
||||
|
||||
|
||||
|
||||
/* init the de- / serializer */
|
||||
init_appHandDeserializer(&appHandService,bytes,string,V2GTP_HEADER_LENGTH);
|
||||
init_appHandSerializer(&appHandService,bytes,string,MAX_STREAM_SIZE,V2GTP_HEADER_LENGTH);
|
||||
|
||||
if(appHandshakeHandler(&appHandService, inStream,inStreamLength,outStream,outStreamLength))
|
||||
{
|
||||
return -1; /* an error occured */
|
||||
}
|
||||
|
||||
isHandshake = 0; /* here: next time a charging message is expected */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Pass the received EXI message stream (inStream + exiMsgLength) to the *
|
||||
* v2g message dispatcher. The outStream contains the response message *
|
||||
* stream. *
|
||||
****************************************************************************/
|
||||
|
||||
if(messageDispatcher(&service, inStream, exiMsgLength, outStream, MAX_STREAM_SIZE, outStreamLength))
|
||||
{
|
||||
/* an error occured */
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* write v2gtp header */
|
||||
write_v2gtpHeader(outStream, outStreamLength, V2GTP_EXI_TYPE);
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/** Example implementation of the app handshake protocol for the EVSE side */
|
||||
static int appHandshakeHandler(struct EXIDatabinder* appHandService, uint8_t* inStream, uint16_t sizeInStream, uint8_t* outStream, uint16_t* outStreamLength)
|
||||
{
|
||||
struct EXIDocumentType_appHand exiDoc;
|
||||
struct AnonType_supportedAppProtocolReq handshake;
|
||||
struct AnonType_supportedAppProtocolRes resultHandshake;
|
||||
size_t i;
|
||||
|
||||
init_AnonType_supportedAppProtocolReq(&handshake);
|
||||
init_EXIDocumentType_appHand(&exiDoc);
|
||||
|
||||
/* we expect a supportedAppProtocolReq */
|
||||
exiDoc.supportedAppProtocolReq = &handshake;
|
||||
|
||||
|
||||
if(deserialize_appHand(appHandService,inStream,sizeInStream,&exiDoc))
|
||||
{
|
||||
/* an error occured */
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("EVSE side: List of application handshake protocols of the EV \n");
|
||||
|
||||
for(i=0;i<handshake.arraylen.AppProtocol;i++)
|
||||
{
|
||||
printf("\tProtocol entry #=%d\n",(i+1));
|
||||
printf("\t\tProtocolNamespace=");
|
||||
printASCIIString(handshake.AppProtocol[i].ProtocolNamespace.data,handshake.AppProtocol[i].ProtocolNamespace.arraylen.data);
|
||||
printf("\t\tVersion=%d.%d\n", handshake.AppProtocol[i].VersionNumberMajor,handshake.AppProtocol[i].VersionNumberMinor);
|
||||
printf("\t\tSchemaID=%d\n", handshake.AppProtocol[i].SchemaID);
|
||||
printf("\t\tPriority=%d\n", handshake.AppProtocol[i].Priority);
|
||||
}
|
||||
|
||||
/* prepare response handshake response:
|
||||
* it is assumed, we support the 15118 1.0 version :-) */
|
||||
resultHandshake.ResponseCode=OK_SuccessfulNegotiation_responseCodeType;
|
||||
resultHandshake.SchemaID=handshake.AppProtocol[0].SchemaID; /* signal the protocol by the provided schema id*/
|
||||
resultHandshake.isused.SchemaID=1;
|
||||
|
||||
/* assign the response message to the exiDoc */
|
||||
init_EXIDocumentType_appHand(&exiDoc);
|
||||
exiDoc.supportedAppProtocolRes=&resultHandshake;
|
||||
exiDoc.isused.supportedAppProtocolRes=1;
|
||||
|
||||
if(serialize_appHand(appHandService, outStream,outStreamLength, &exiDoc))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void printASCIIString(uint32_t* string, uint32_t len) {
|
||||
unsigned int i;
|
||||
for(i=0; i<len; i++) {
|
||||
printf("%c",(char)string[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Sebastian.Kaebisch.EXT@siemens.com
|
||||
* @@version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
#ifndef V2G_SERVER_H_
|
||||
#define V2G_SERVER_H_
|
||||
|
||||
#include "EXITypes.h"
|
||||
|
||||
int testV2GService(uint8_t* inStream, uint16_t inStreamLength, uint8_t* outStream,uint16_t* outStreamLength);
|
||||
|
||||
#endif /* V2G_SERVER_H_ */
|
|
@ -1,610 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Sebastian.Kaebisch.EXT@siemens.com
|
||||
* @version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
#include "v2g_serviceMethods.h"
|
||||
#include "v2g_serviceDataTypes.h"
|
||||
#include <stdio.h>
|
||||
|
||||
static void printBinaryArray(uint8_t* byte, uint32_t len);
|
||||
|
||||
int sessionSetup(struct MessageHeaderType* header, struct SessionSetupReqType* param, struct SessionSetupResType* result)
|
||||
{
|
||||
|
||||
printf("EVSE side: sessionSetup called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\tHeader SessionID=");
|
||||
printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
|
||||
printf("\t\t EVCCID=%d\n",param->EVCCID.data[0]);
|
||||
|
||||
/* generate an unique sessionID */
|
||||
header->SessionID.data[0] = 0;
|
||||
header->SessionID.data[1] = 0;
|
||||
header->SessionID.data[2] = 0;
|
||||
header->SessionID.data[3] = 0;
|
||||
header->SessionID.data[4] = 0;
|
||||
header->SessionID.data[5] = 0;
|
||||
header->SessionID.data[6] = 0;
|
||||
header->SessionID.data[7] = 10;
|
||||
header->SessionID.arraylen.data=8;
|
||||
|
||||
/* Prepare data for EV */
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->EVSEID.data[0]=1;
|
||||
result->EVSEID.arraylen.data=1;
|
||||
result->DateTimeNow=123456789;
|
||||
result->isused.DateTimeNow=1;
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int serviceDiscovery(struct MessageHeaderType* header, struct ServiceDiscoveryReqType* param, struct ServiceDiscoveryResType* result)
|
||||
{
|
||||
printf("EVSE side: serviceDiscovery called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\tHeader SessionID=");
|
||||
printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
|
||||
|
||||
printf("\t\t ServiceCategory=%d\n", param->ServiceCategory);
|
||||
|
||||
result->isused.ServiceList=0; /* we do not provide VAS */
|
||||
result->ResponseCode= OK_responseCodeType;
|
||||
|
||||
|
||||
result->ChargeService.EnergyTransferType = AC_single_DC_core_EVSESupportedEnergyTransferType;
|
||||
result->ChargeService.ServiceTag.ServiceID=1; /* ID of the charge service */
|
||||
result->ChargeService.ServiceTag.ServiceName.data[0]='A';
|
||||
result->ChargeService.ServiceTag.ServiceName.data[1]='C';
|
||||
result->ChargeService.ServiceTag.ServiceName.data[2]='_';
|
||||
result->ChargeService.ServiceTag.ServiceName.data[3]='D';
|
||||
result->ChargeService.ServiceTag.ServiceName.data[4]='C';
|
||||
result->ChargeService.ServiceTag.ServiceName.arraylen.data=5;
|
||||
result->ChargeService.ServiceTag.isused.ServiceName=1;
|
||||
result->ChargeService.ServiceTag.isused.ServiceCategory=0;
|
||||
result->ChargeService.ServiceTag.isused.ServiceScope=0;
|
||||
|
||||
result->ChargeService.FreeService = 1;
|
||||
result->PaymentOptions.PaymentOption[0] = ExternalPayment_paymentOptionType; /* EVSE handles the payment */
|
||||
result->PaymentOptions.arraylen.PaymentOption=1;
|
||||
|
||||
|
||||
result->ServiceList.Service[0].FreeService=1;
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceID=22; /* ID of the charge service */
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceName.data[0]='W';
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceName.data[1]='W';
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceName.data[2]='W';
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceName.arraylen.data=3;
|
||||
result->ServiceList.Service[0].ServiceTag.ServiceCategory=Internet_serviceCategoryType;
|
||||
result->ServiceList.Service[0].ServiceTag.isused.ServiceName=1;
|
||||
result->ServiceList.Service[0].ServiceTag.isused.ServiceCategory=1;
|
||||
result->ServiceList.Service[0].ServiceTag.isused.ServiceScope=0;
|
||||
|
||||
result->ServiceList.arraylen.Service=1;
|
||||
result->isused.ServiceList=1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int servicePaymentSelection(struct MessageHeaderType* header, struct ServicePaymentSelectionReqType* param, struct ServicePaymentSelectionResType* result)
|
||||
{
|
||||
printf("EVSE side: servicePaymentSelection called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\tHeader SessionID=");
|
||||
printBinaryArray(header->SessionID.data,header->SessionID.arraylen.data );
|
||||
|
||||
if(param->SelectedPaymentOption == ExternalPayment_paymentOptionType)
|
||||
printf("\t\t SelectedPaymentOption=ExternalPayment\n");
|
||||
|
||||
printf("\t\t ServiceID=%d\n",param->SelectedServiceList.SelectedService[0].ServiceID);
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int paymentDetails(struct MessageHeaderType* header, struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chargeParameterDiscovery(struct MessageHeaderType* header, struct ChargeParameterDiscoveryReqType* param, struct ChargeParameterDiscoveryResType* result)
|
||||
{
|
||||
struct PhysicalValueType f;
|
||||
|
||||
printf("EVSE side: chargeParameterDiscovery called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\t\t EVRequestedEnergyTransferType=%d\n",param->EVRequestedEnergyTransferType);
|
||||
|
||||
/* check,if DC or AC is requested */
|
||||
if(param->EVRequestedEnergyTransferType==DC_core_EVRequestedEnergyTransferType || param->isused.DC_EVChargeParameter==1)
|
||||
{
|
||||
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVChargeParameter->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
|
||||
printf("\t\t EVMaximumCurrentLimit=%d\n", param->DC_EVChargeParameter->EVMaximumCurrentLimit.Value);
|
||||
printf("\t\t EVMaximumPowerLimit=%d\n", param->DC_EVChargeParameter->EVMaximumPowerLimit.Value);
|
||||
printf("\t\t EVMaximumVoltageLimit=%d\n", param->DC_EVChargeParameter->EVMaximumVoltageLimit.Value);
|
||||
printf("\t\t EVEnergyCapacity=%d\n", param->DC_EVChargeParameter->EVEnergyCapacity.Value);
|
||||
printf("\t\t EVEnergyRequest=%d\n", param->DC_EVChargeParameter->EVEnergyRequest.Value);
|
||||
printf("\t\t FullSOC=%d\n", param->DC_EVChargeParameter->FullSOC);
|
||||
printf("\t\t BulkSOC=%d\n", param->DC_EVChargeParameter->BulkSOC);
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->isused.SAScheduleList=0;
|
||||
|
||||
|
||||
result->isused.DC_EVSEChargeParameter = 1;
|
||||
result->isused.AC_EVSEChargeParameter = 0;
|
||||
result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
result->DC_EVSEChargeParameter->DC_EVSEStatus.EVSEIsolationStatus = Safe_isolationLevelType;
|
||||
result->DC_EVSEChargeParameter->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
|
||||
|
||||
|
||||
f.Multiplier = 0;
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 50;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEMaximumCurrentLimit=f;
|
||||
|
||||
f.Unit = W_unitSymbolType;
|
||||
f.Value = 20000;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEMaximumPowerLimit=f;
|
||||
result->DC_EVSEChargeParameter->isused.EVSEMaximumPowerLimit=1;
|
||||
|
||||
f.Unit = V_unitSymbolType;
|
||||
f.Value = 400;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEMaximumVoltageLimit=f;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 5;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEMinimumCurrentLimit=f;
|
||||
|
||||
f.Unit = V_unitSymbolType;
|
||||
f.Value = 200;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEMinimumVoltageLimit=f;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 2;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSECurrentRegulationTolerance=f;
|
||||
result->DC_EVSEChargeParameter->isused.EVSECurrentRegulationTolerance=1;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 1;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEPeakCurrentRipple=f;
|
||||
|
||||
f.Unit = W_unitSymbolType;
|
||||
f.Value = 5000;
|
||||
|
||||
result->DC_EVSEChargeParameter->EVSEEnergyToBeDelivered=f;
|
||||
result->DC_EVSEChargeParameter->isused.EVSEEnergyToBeDelivered=1;
|
||||
|
||||
/* set up a PMax schedule */
|
||||
result->isused.SAScheduleList=1;
|
||||
result->SAScheduleList->SAScheduleTuple[0].SAScheduleTupleID=10;
|
||||
result->SAScheduleList->SAScheduleTuple[0].isused.SalesTariff=0; /* no tariffs */
|
||||
|
||||
/* set up two PMax entries */
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleID=20;
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].PMax=20000;
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
|
||||
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].PMax=0;
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1200; /* 20 min */
|
||||
|
||||
result->SAScheduleList->SAScheduleTuple[0].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
|
||||
|
||||
|
||||
/* set up two PMax entries */
|
||||
result->SAScheduleList->SAScheduleTuple[1].SAScheduleTupleID=15;
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleID=30;
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].PMax=10000;
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[0].RelativeTimeInterval.start=0;
|
||||
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].PMax=0;
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.PMaxScheduleEntry[1].RelativeTimeInterval.start=1800; /* 30 min */
|
||||
|
||||
result->SAScheduleList->SAScheduleTuple[1].PMaxSchedule.arraylen.PMaxScheduleEntry=2; /* we set up two time entries */
|
||||
|
||||
result->SAScheduleList->arraylen.SAScheduleTuple=2; /* we used only 1 tuple */
|
||||
|
||||
} else { /* AC related */
|
||||
|
||||
printf("\t\t DepartureTime=%d\n", param->AC_EVChargeParameter->DepartureTime);
|
||||
printf("\t\t EAmount=%d\n", param->AC_EVChargeParameter->EAmount.Value);
|
||||
printf("\t\t EVMaxCurrent=%d\n", param->AC_EVChargeParameter->EVMaxCurrent.Value);
|
||||
printf("\t\t EVMaxVoltage=%d\n", param->AC_EVChargeParameter->EVMaxVoltage.Value);
|
||||
printf("\t\t EVMinCurrent=%d\n", param->AC_EVChargeParameter->EVMinCurrent.Value);
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
|
||||
|
||||
result->isused.AC_EVSEChargeParameter = 1;
|
||||
result->isused.DC_EVSEChargeParameter = 0;
|
||||
result->isused.SAScheduleList = 0;
|
||||
|
||||
|
||||
result->AC_EVSEChargeParameter->AC_EVSEStatus.PowerSwitchClosed=1;
|
||||
result->AC_EVSEChargeParameter->AC_EVSEStatus.RCD=1;
|
||||
result->AC_EVSEChargeParameter->AC_EVSEStatus.ShutDownTime=12345;
|
||||
result->AC_EVSEChargeParameter->AC_EVSEStatus.StopCharging=0;
|
||||
|
||||
|
||||
f.Multiplier = 0;
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 100;
|
||||
|
||||
result->AC_EVSEChargeParameter->EVSEMaxCurrent=f;
|
||||
|
||||
f.Unit = V_unitSymbolType;
|
||||
f.Value = 200;
|
||||
result->AC_EVSEChargeParameter->EVSEMaxVoltage=f;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 300;
|
||||
result->AC_EVSEChargeParameter->EVSEMinCurrent=f;
|
||||
|
||||
/* no sales schedule used */
|
||||
result->isused.SAScheduleList=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int powerDelivery(struct MessageHeaderType* header, struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf("EVSE side: powerDelivery called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\t\t\t ReadyToChargeState=%d\n", param->ReadyToChargeState);
|
||||
|
||||
|
||||
|
||||
if(param->isused.DC_EVPowerDeliveryParameter)
|
||||
{
|
||||
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVPowerDeliveryParameter->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
|
||||
if(param->isused.ChargingProfile)
|
||||
{
|
||||
printf("\t\t\tChargingProfile:\n");
|
||||
printf("\t\t\t SAScheduleTupleID=%d\n",param->ChargingProfile.SAScheduleTupleID );
|
||||
for(i=0;i<param->ChargingProfile.arraylen.ProfileEntry;i++)
|
||||
{
|
||||
printf("\t\t\t Entry#%d\n",i);
|
||||
printf("\t\t\t\t ChargingProfileEntryMaxPower=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryMaxPower);
|
||||
printf("\t\t\t\t ChargingProfileEntryStart=%d\n", param->ChargingProfile.ProfileEntry[i].ChargingProfileEntryStart);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->DC_EVSEStatus->EVSEIsolationStatus =1;
|
||||
result->DC_EVSEStatus->isused.EVSEIsolationStatus = 1;
|
||||
result->DC_EVSEStatus->EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
result->isused.DC_EVSEStatus=1;
|
||||
result->isused.AC_EVSEStatus=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->AC_EVSEStatus->PowerSwitchClosed=1;
|
||||
result->AC_EVSEStatus->RCD=1;
|
||||
result->AC_EVSEStatus->ShutDownTime=12345;
|
||||
result->AC_EVSEStatus->StopCharging=1;
|
||||
|
||||
|
||||
result->isused.AC_EVSEStatus=1;
|
||||
result->isused.DC_EVSEStatus=0;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int chargingStatus(struct MessageHeaderType* header, struct ChargingStatusReqType* param, struct ChargingStatusResType* result)
|
||||
{
|
||||
printf("EVSE side: chargingStatus called\n" );
|
||||
|
||||
|
||||
|
||||
result->ResponseCode=OK_responseCodeType;
|
||||
result->EVSEID.data[0]=1;
|
||||
result->EVSEID.arraylen.data=1;
|
||||
result->AC_EVSEStatus.PowerSwitchClosed=1;
|
||||
result->AC_EVSEStatus.RCD=1;
|
||||
result->AC_EVSEStatus.ShutDownTime=12345;
|
||||
result->AC_EVSEStatus.StopCharging=1;
|
||||
result->ReceiptRequired=0;
|
||||
result->EVSEMaxCurrent.Multiplier = 2;
|
||||
result->EVSEMaxCurrent.Unit = A_unitSymbolType;
|
||||
result->EVSEMaxCurrent.isused.Unit=1;
|
||||
result->EVSEMaxCurrent.Value = 400;
|
||||
result->isused.EVSEMaxCurrent=1;
|
||||
result->SAScheduleTupleID=10;
|
||||
result->isused.SAScheduleTupleID=1;
|
||||
|
||||
result->isused.MeterInfo=1;
|
||||
result->MeterInfo.MeterID.arraylen.data=1;
|
||||
result->MeterInfo.MeterID.data[0]=2;
|
||||
result->MeterInfo.MeterReading.Multiplier = 0;
|
||||
result->MeterInfo.MeterReading.Unit = A_unitSymbolType;
|
||||
result->MeterInfo.MeterReading.Value = 500;
|
||||
result->MeterInfo.MeterStatus = 4321;
|
||||
result->MeterInfo.TMeter =123456789;
|
||||
result->MeterInfo.isused.MeterReading = 1;
|
||||
result->MeterInfo.isused.MeterStatus=1;
|
||||
result->MeterInfo.isused.TMeter=1;
|
||||
result->MeterInfo.isused.SigMeterReading=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int meteringReceipt(struct MessageHeaderType* header, struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result)
|
||||
{
|
||||
|
||||
printf("EVSE side: meteringReceipt called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
|
||||
printf("\t\t SAScheduleTupleID=%d\n", param->SAScheduleTupleID);
|
||||
printf("\t\t MeterInfo.MeterStatus=%d\n", param->MeterInfo.MeterStatus);
|
||||
printf("\t\t MeterInfo.MeterID=%d\n", param->MeterInfo.MeterID.data[0]);
|
||||
printf("\t\t MeterInfo.isused.MeterReading=%d\n", param->MeterInfo.isused.MeterReading);
|
||||
printf("\t\t MeterReading.Value=%d\n", param->MeterInfo.MeterReading.Value);
|
||||
printf("\t\t MeterInfo.TMeter=%d\n", param->MeterInfo.TMeter);
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
|
||||
result->AC_EVSEStatus.PowerSwitchClosed=1;
|
||||
result->AC_EVSEStatus.RCD=1;
|
||||
result->AC_EVSEStatus.ShutDownTime=12345;
|
||||
result->AC_EVSEStatus.StopCharging=1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cableCheck(struct MessageHeaderType* header, struct CableCheckReqType* param, struct CableCheckResType* result)
|
||||
{
|
||||
printf("EVSE side: cableCheck called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
|
||||
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
|
||||
result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
|
||||
result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int preCharge(struct MessageHeaderType* header, struct PreChargeReqType* param, struct PreChargeResType* result)
|
||||
{
|
||||
struct PhysicalValueType float_type;
|
||||
|
||||
|
||||
printf("EVSE side: preCharge called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
|
||||
result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
|
||||
result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
|
||||
float_type.Multiplier = 0;
|
||||
float_type.Unit = V_unitSymbolType;
|
||||
float_type.Value = 100;
|
||||
result->EVSEPresentVoltage = float_type;
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int currentDemand(struct MessageHeaderType* header, struct CurrentDemandReqType* param, struct CurrentDemandResType* result)
|
||||
{
|
||||
|
||||
struct PhysicalValueType f;
|
||||
|
||||
printf("EVSE side: currentDemand called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
printf("\t\t EVTargetCurrent=%d\n", param->EVTargetCurrent.Value);
|
||||
printf("\t\t EVMaximumVoltageLimit=%d\n", param->EVMaximumVoltageLimit.Value);
|
||||
printf("\t\t EVMaximumPowerLimit=%d\n", param->EVMaximumPowerLimit.Value);
|
||||
printf("\t\t EVMaximumCurrentLimit=%d\n", param->EVMaximumCurrentLimit.Value);
|
||||
printf("\t\t BulkChargingComplete=%d\n", param->BulkChargingComplete);
|
||||
printf("\t\t ChargingComplete=%d\n", param->ChargingComplete);
|
||||
printf("\t\t RemainingTimeToFullSoC=%d\n", param->RemainingTimeToFullSoC.Value);
|
||||
printf("\t\t RemainingTimeToBulkSoC=%d\n", param->RemainingTimeToBulkSoC.Value);
|
||||
|
||||
printf("\t\t EVTargetVoltage=%d\n", param->EVTargetVoltage.Value);
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
|
||||
result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
|
||||
result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
|
||||
f.Multiplier = 0;
|
||||
f.Unit = V_unitSymbolType;
|
||||
f.Value = 400;
|
||||
|
||||
result->EVSEPresentVoltage=f;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 45;
|
||||
|
||||
result->EVSEPresentCurrent=f;
|
||||
|
||||
result->EVSECurrentLimitAchieved=0;
|
||||
|
||||
result->EVSEVoltageLimitAchieved=1;
|
||||
|
||||
result->EVSEPowerLimitAchieved=0;
|
||||
|
||||
f.Unit = V_unitSymbolType;
|
||||
f.Value = 400;
|
||||
|
||||
result->EVSEMaximumVoltageLimit=f;
|
||||
result->isused.EVSEMaximumVoltageLimit=1;
|
||||
|
||||
f.Unit = A_unitSymbolType;
|
||||
f.Value = 50;
|
||||
|
||||
result->EVSEMaximumCurrentLimit=f;
|
||||
result->isused.EVSEMaximumCurrentLimit=1;
|
||||
|
||||
f.Unit = W_unitSymbolType;
|
||||
f.Value = 20000;
|
||||
|
||||
result->EVSEMaximumPowerLimit=f;
|
||||
result->isused.EVSEMaximumPowerLimit=1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int weldingDetection(struct MessageHeaderType* header, struct WeldingDetectionReqType* param, struct WeldingDetectionResType* result)
|
||||
{
|
||||
|
||||
printf("EVSE side: weldingDetection called\n" );
|
||||
printf("\tReceived data:\n");
|
||||
printf("\t\t EVStatus:\n");
|
||||
printf("\t\t\t EVReady=%d\n", param->DC_EVStatus.EVReady);
|
||||
printf("\t\t\t EVRESSSOC=%d\n", param->DC_EVStatus.EVRESSSOC);
|
||||
printf("\t\t\t EVErrorCode=%d\n", param->DC_EVStatus.EVErrorCode);
|
||||
printf("\t\t\t EVRESSConditioning=%d\n", param->DC_EVStatus.EVRESSConditioning);
|
||||
printf("\t\t\t EVCabinConditioning=%d\n", param->DC_EVStatus.EVCabinConditioning);
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
result->DC_EVSEStatus.EVSEIsolationStatus= Safe_isolationLevelType;
|
||||
result->DC_EVSEStatus.isused.EVSEIsolationStatus = 1;
|
||||
result->DC_EVSEStatus.EVSEStatusCode = EVSE_Ready_DC_EVSEStatusCodeType;
|
||||
result->EVSEPresentVoltage.Value = 123;
|
||||
result->EVSEPresentVoltage.Unit = V_unitSymbolType;
|
||||
result->EVSEPresentVoltage.Multiplier = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sessionStop(struct MessageHeaderType* header, struct SessionStopType* param, struct SessionStopResType* result)
|
||||
{
|
||||
|
||||
|
||||
printf("EVSE side: sessionStop called\n" );
|
||||
|
||||
|
||||
result->ResponseCode = OK_responseCodeType;
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int serviceDetail(struct MessageHeaderType* header, struct ServiceDetailReqType* param, struct ServiceDetailResType* result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int contractAuthentication(struct MessageHeaderType* header, struct ContractAuthenticationReqType* param, struct ContractAuthenticationResType* result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int certificateUpdate(struct MessageHeaderType* header, struct CertificateUpdateReqType* param, struct CertificateUpdateResType* result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int certificateInstallation(struct MessageHeaderType* header, struct CertificateInstallationReqType* param, struct CertificateInstallationResType* result)
|
||||
{
|
||||
|
||||
printf("EVSE: certificateInstallation called\n" );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void printBinaryArray(uint8_t* byte, uint32_t len) {
|
||||
unsigned int i;
|
||||
for(i=0; i<len; i++) {
|
||||
printf("%d ",byte[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
|
@ -1,538 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Daniel.Peintner.EXT@siemens.com
|
||||
* @version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
* <p>Code generated by EXIdizer</p>
|
||||
********************************************************************/
|
||||
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* <p>Sample program to illustrate how to read an EXI stream and
|
||||
* directly write it again to an output</p>
|
||||
*
|
||||
* <p>e.g., data/test/sessionSetupReq.xml.exi out/test/sessionSetupReq.xml.exi</p>
|
||||
********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "EXIDecoder.h"
|
||||
#include "StringTable.h"
|
||||
#include "EXIEncoder.h"
|
||||
#include "EXITypes.h"
|
||||
#include "ByteStream.h"
|
||||
|
||||
#if EXI_STREAM == BYTE_ARRAY
|
||||
/* 64 kilobytes = 65 536 bytes */
|
||||
/* 1 megabyte = 1 048 576 bytes*/
|
||||
#define BUFFER_SIZE 512
|
||||
uint8_t bufferIn[BUFFER_SIZE];
|
||||
uint8_t bufferOut[BUFFER_SIZE];
|
||||
#endif /* EXI_STREAM == BYTE_ARRAY */
|
||||
|
||||
/* avoids warning: initializer element is not computable at load time */
|
||||
#define ARRAY_SIZE_BYTES 100
|
||||
uint8_t bytesData[ARRAY_SIZE_BYTES];
|
||||
#define ARRAY_SIZE_STRINGS 100
|
||||
uint32_t codepoints[ARRAY_SIZE_STRINGS];
|
||||
#define ARRAY_SIZE_STRINGS_ASCII 100
|
||||
char charsNamespaceURI[ARRAY_SIZE_STRINGS_ASCII];
|
||||
char charsLocalName[ARRAY_SIZE_STRINGS_ASCII];
|
||||
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
static void debugValue(exi_value_t* val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
|
||||
|
||||
int main_codec(int argc, char *argv[]) {
|
||||
|
||||
int errn = 0;
|
||||
|
||||
unsigned int k;
|
||||
|
||||
bitstream_t iStream, oStream;
|
||||
uint32_t posDecode;
|
||||
uint32_t posEncode;
|
||||
|
||||
/* EXI set-up */
|
||||
exi_state_t stateDecode;
|
||||
exi_state_t stateEncode;
|
||||
exi_event_t event;
|
||||
eqname_t eqn; /* efficient qname */
|
||||
qname_t qn; /* ascii qname */
|
||||
exi_value_t val;
|
||||
|
||||
exi_name_table_runtime_t runtimeTableDecode;
|
||||
exi_name_table_runtime_t runtimeTableEncode;
|
||||
|
||||
/* BINARY memory setup */
|
||||
bytes_t bytes = { ARRAY_SIZE_BYTES, bytesData, 0 };
|
||||
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
const char * localName;
|
||||
const char * namespaceURI;
|
||||
#endif /*EXI_DEBUG*/
|
||||
int noEndOfDocument = 1; /* true */
|
||||
|
||||
/* STRING memory setup */
|
||||
string_ucs_t string = { ARRAY_SIZE_STRINGS, codepoints, 0 };
|
||||
string_ascii_t stringNamespaceURI = { ARRAY_SIZE_STRINGS_ASCII,
|
||||
charsNamespaceURI };
|
||||
string_ascii_t stringLocalName =
|
||||
{ ARRAY_SIZE_STRINGS_ASCII, charsLocalName };
|
||||
qn.namespaceURI = stringNamespaceURI;
|
||||
qn.localName = stringLocalName;
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: %s exiInput exiOutput\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* input pos */
|
||||
posDecode = 0;
|
||||
|
||||
#if EXI_STREAM == BYTE_ARRAY
|
||||
/* parse EXI stream to internal byte structures */
|
||||
errn = readBytesFromFile(argv[1], bufferIn, BUFFER_SIZE, posDecode);
|
||||
if (errn < 0) {
|
||||
printf("Problems while reading file into buffer\n");
|
||||
return errn;
|
||||
}
|
||||
#endif /* EXI_STREAM == BYTE_ARRAY */
|
||||
|
||||
/* setup input stream */
|
||||
#if EXI_STREAM == BYTE_ARRAY
|
||||
iStream.size = BUFFER_SIZE;
|
||||
iStream.data = bufferIn;
|
||||
iStream.pos = &posDecode;
|
||||
#endif /* EXI_STREAM == BYTE_ARRAY */
|
||||
#if EXI_STREAM == FILE_STREAM
|
||||
iStream.file = fopen(argv[1], "rb");
|
||||
#endif /* EXI_STREAM == FILE_STREAM */
|
||||
|
||||
iStream.buffer = 0;
|
||||
iStream.capacity = 0;
|
||||
|
||||
/* setup output stream */
|
||||
posEncode = 0;
|
||||
#if EXI_STREAM == BYTE_ARRAY
|
||||
oStream.size = BUFFER_SIZE;
|
||||
oStream.data = bufferOut;
|
||||
oStream.pos = &posEncode;
|
||||
#endif
|
||||
#if EXI_STREAM == FILE_STREAM
|
||||
oStream.file = fopen(argv[2], "wb");
|
||||
#endif /* EXI_STREAM == FILE_STREAM */
|
||||
oStream.buffer = 0;
|
||||
oStream.capacity = 8;
|
||||
|
||||
val.binary = bytes;
|
||||
val.string = string;
|
||||
|
||||
/* init decoder (read header, set initial state) */
|
||||
/* init runtime table */
|
||||
errn = exiInitNameTableRuntime(&runtimeTableDecode);
|
||||
exiInitDecoder(&iStream, &stateDecode, runtimeTableDecode);
|
||||
|
||||
/* init encoder (write header, set initial state) */
|
||||
errn = exiInitNameTableRuntime(&runtimeTableEncode);
|
||||
exiInitEncoder(&oStream, &stateEncode, runtimeTableEncode);
|
||||
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[DECODE] >>> EXI >>> [ENCODE] \n");
|
||||
#endif /*EXI_DEBUG*/
|
||||
|
||||
do {
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Encode-ERROR] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
|
||||
errn = exiDecodeNextEvent(&iStream, &stateDecode,
|
||||
&event);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case EXI_EVENT_START_DOCUMENT:
|
||||
/* decode */
|
||||
errn = exiDecodeStartDocument(&iStream,
|
||||
&stateDecode);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-SD] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf(">> START_DOCUMENT \n");
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeStartDocument(&oStream,
|
||||
&stateEncode);
|
||||
break;
|
||||
case EXI_EVENT_END_DOCUMENT:
|
||||
/* decode */
|
||||
errn = exiDecodeEndDocument(&iStream,
|
||||
&stateDecode);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-ED] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf(">> END_DOCUMENT \n");
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeEndDocument(&oStream,
|
||||
&stateEncode);
|
||||
/* signalize end of document */
|
||||
noEndOfDocument = 0; /* false */
|
||||
break;
|
||||
case EXI_EVENT_START_ELEMENT:
|
||||
/* decode */
|
||||
errn = exiDecodeStartElement(&iStream,
|
||||
&stateDecode, &eqn);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-SE] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
|
||||
eqn.localPart, &localName);
|
||||
exiGetUri(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
|
||||
&namespaceURI);
|
||||
printf(">> SE_{%s}%s \n", namespaceURI,
|
||||
localName);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeStartElement(&oStream,
|
||||
&stateEncode, &eqn);
|
||||
break;
|
||||
case EXI_EVENT_START_ELEMENT_GENERIC:
|
||||
/* decode */
|
||||
errn = exiDecodeStartElementGeneric(&iStream,
|
||||
&stateDecode, &qn);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-SEgen] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf(">> SE_Gen {%s}%s \n", stringNamespaceURI.chars,
|
||||
stringLocalName.chars);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeStartElementGeneric(&oStream,
|
||||
&stateEncode, &stringNamespaceURI, &stringLocalName);
|
||||
break;
|
||||
case EXI_EVENT_END_ELEMENT:
|
||||
/* decode */
|
||||
errn = exiDecodeEndElement(&iStream,
|
||||
&stateDecode, &eqn);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-EE] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("<< EE \n");
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn
|
||||
= exiEncodeEndElement(&oStream,
|
||||
&stateEncode);
|
||||
break;
|
||||
case EXI_EVENT_END_ELEMENT_UNDECLARED:
|
||||
/* decode */
|
||||
errn = exiDecodeEndElementUndeclared(&iStream,
|
||||
&stateDecode, &eqn);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-EE-Undecl] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("<< EEundecl \n");
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn
|
||||
= exiEncodeEndElement(&oStream,
|
||||
&stateEncode);
|
||||
break;
|
||||
case EXI_EVENT_CHARACTERS:
|
||||
/* decode */
|
||||
errn = exiDecodeCharacters(&iStream,
|
||||
&stateDecode, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-CH] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeCharacters(&oStream,
|
||||
&stateEncode, &val);
|
||||
|
||||
/* list value: special behavior */
|
||||
if (val.type == EXI_DATATYPE_LIST) {
|
||||
for(k=0; k<val.list.len; k++) {
|
||||
errn = exiDecodeListValue(&iStream, &val, val.list);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-CH_LIST] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode list value */
|
||||
errn = exiEncodeListValue(&oStream,
|
||||
&val, val.list);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EXI_EVENT_CHARACTERS_GENERIC:
|
||||
/* decode */
|
||||
errn = exiDecodeCharactersGeneric(&iStream,
|
||||
&stateDecode, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-CHgen] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeCharacters(&oStream,
|
||||
&stateEncode, &val);
|
||||
break;
|
||||
case EXI_EVENT_CHARACTERS_GENERIC_UNDECLARED:
|
||||
/* decode */
|
||||
errn = exiDecodeCharactersGenericUndeclared(
|
||||
&iStream, &stateDecode, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-CHgenUndecl] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeCharacters(&oStream,
|
||||
&stateEncode, &val);
|
||||
break;
|
||||
case EXI_EVENT_ATTRIBUTE:
|
||||
/* decode */
|
||||
errn = exiDecodeAttribute(&iStream, &stateDecode,
|
||||
&eqn, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-AT] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
|
||||
eqn.localPart, &localName);
|
||||
exiGetUri(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), eqn.namespaceURI,
|
||||
&namespaceURI);
|
||||
printf(" AT {%s}%s \n", namespaceURI, localName);
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeAttribute(&oStream, &stateEncode,
|
||||
&eqn, &val);
|
||||
break;
|
||||
case EXI_EVENT_ATTRIBUTE_XSI_NIL:
|
||||
/* decode */
|
||||
errn = exiDecodeAttributeXsiNil(&iStream,
|
||||
&stateDecode, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-AT-NIL] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf(" AT {xsi}nil == %i \n", val.boolean);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeAttributeXsiNil(&oStream,
|
||||
&stateEncode, &val);
|
||||
break;
|
||||
case EXI_EVENT_ATTRIBUTE_XSI_TYPE:
|
||||
/* decode */
|
||||
errn = exiDecodeAttributeXsiType(&iStream,
|
||||
&stateDecode, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-AT-TYPE] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
exiGetLocalName(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), val.eqname.namespaceURI,
|
||||
val.eqname.localPart, &localName);
|
||||
exiGetUri(&(stateDecode.nameTablePrepopulated),
|
||||
&(stateDecode.nameTableRuntime), val.eqname.namespaceURI,
|
||||
&namespaceURI);
|
||||
printf(" AT {type}type == {%s}%s \n", namespaceURI, localName);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeAttributeXsiType(&oStream,
|
||||
&stateEncode, &val);
|
||||
break;
|
||||
case EXI_EVENT_ATTRIBUTE_GENERIC_UNDECLARED:
|
||||
/* decode */
|
||||
errn = exiDecodeAttributeGenericUndeclared(
|
||||
&iStream, &stateDecode, &qn, &val);
|
||||
if (errn < 0) {
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Decode-ERROR-ATgenUnd] %d \n", errn);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return errn;
|
||||
}
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
/* exiGetLocalName(&(stateDecode.nameTablePrepopulated), &(stateDecode.nameTableRuntime), eqn.namespaceURI, eqn.localPart, &localName);
|
||||
exiGetUri(&(stateDecode.nameTablePrepopulated), &(stateDecode.nameTableRuntime), eqn.namespaceURI, &namespaceURI); */
|
||||
printf(" AT {%s}%s \n", qn.namespaceURI.chars, qn.localName.chars);
|
||||
debugValue(&val);
|
||||
#endif /*EXI_DEBUG*/
|
||||
/* encode */
|
||||
errn = exiEncodeAttribute(&oStream, &stateEncode,
|
||||
&eqn, &val);
|
||||
break;
|
||||
default:
|
||||
/* ERROR */
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
printf("[Unknown-Event] %d \n", event);
|
||||
#endif /*EXI_DEBUG*/
|
||||
return EXI_ERROR_UNKOWN_EVENT;
|
||||
}
|
||||
|
||||
} while (noEndOfDocument);
|
||||
|
||||
#if EXI_STREAM == BYTE_ARRAY
|
||||
/* write to file */
|
||||
writeBytesToFile(oStream.data, posEncode, argv[2]);
|
||||
#endif
|
||||
#if EXI_STREAM == FILE_STREAM
|
||||
fclose(iStream.file);
|
||||
fclose(oStream.file);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if EXI_DEBUG == EXI_DEBUG_ON
|
||||
static void debugValue(exi_value_t* val) {
|
||||
int i;
|
||||
switch (val->type) {
|
||||
case EXI_DATATYPE_INTEGER:
|
||||
switch (val->integer.type) {
|
||||
/* Unsigned Integer */
|
||||
case EXI_UNSIGNED_INTEGER_8:
|
||||
printf(" Value uint8 : %d \n", val->integer.val.uint8);
|
||||
break;
|
||||
case EXI_UNSIGNED_INTEGER_16:
|
||||
printf(" Value uint16 : %d \n", val->integer.val.uint16);
|
||||
break;
|
||||
case EXI_UNSIGNED_INTEGER_32:
|
||||
printf(" Value uint32 : %d \n", val->integer.val.uint32);
|
||||
break;
|
||||
case EXI_UNSIGNED_INTEGER_64:
|
||||
printf(" Value uint64 : %ld \n",
|
||||
(long unsigned int) val->integer.val.uint64);
|
||||
break;
|
||||
/* (Signed) Integer */
|
||||
case EXI_INTEGER_8:
|
||||
printf(" Value int8 : %d \n", val->integer.val.int8);
|
||||
break;
|
||||
case EXI_INTEGER_16:
|
||||
printf(" Value int16 : %d \n", val->integer.val.int16);
|
||||
break;
|
||||
case EXI_INTEGER_32:
|
||||
printf(" Value int32 : %d \n", val->integer.val.int32);
|
||||
break;
|
||||
case EXI_INTEGER_64:
|
||||
printf(" Value int64 : %ld \n", (long int) val->integer.val.int64);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case EXI_DATATYPE_BINARY_BASE64:
|
||||
case EXI_DATATYPE_BINARY_HEX:
|
||||
printf(" Value Binary (len == %d) : ", val->binary.len);
|
||||
for (i = 0; i < val->binary.len; i++) {
|
||||
printf(" [%d]", val->binary.data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
break;
|
||||
case EXI_DATATYPE_BOOLEAN:
|
||||
printf(" Value Boolean : %d \n", val->boolean);
|
||||
break;
|
||||
case EXI_DATATYPE_STRING:
|
||||
printf(" Value String (len==%d) : '", val->string.len);
|
||||
for (i = 0; i < val->string.len; i++) {
|
||||
printf("%c", (char) val->string.codepoints[i]);
|
||||
}
|
||||
printf("'\n");
|
||||
break;
|
||||
case EXI_DATATYPE_LIST:
|
||||
printf(" Value List (len==%d) \n", val->list.len);
|
||||
break;
|
||||
default:
|
||||
printf(" Value ?? \n");
|
||||
}
|
||||
}
|
||||
#endif /*EXI_DEBUG*/
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007-2012 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Sebastian.Kaebisch.EXT@siemens.com
|
||||
* @@version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
#include "v2g_serviceClientDataTransmitter.h"
|
||||
#include "evse_server.h"
|
||||
#include "v2gtp.h"
|
||||
|
||||
/*
|
||||
* Send EXI stream (outStream) to EVSE and receive a response stream (inStream)*/
|
||||
int serviceDataTransmitter(uint8_t* outStream, uint16_t outStreamLength, uint8_t* inStream)
|
||||
{
|
||||
/* send output stream to the underlying network to the EVSE and wait for response
|
||||
* --> here provide data to the V2G server directly*/
|
||||
|
||||
uint16_t inStreamLength = 0;
|
||||
uint16_t payloadLength = 0;
|
||||
|
||||
/* setup v2gtp header information; outStreamLength==payloadLength*/
|
||||
write_v2gtpHeader(outStream,&outStreamLength,V2GTP_EXI_TYPE);
|
||||
|
||||
/* send data to EVSE server (add v2g offset)*/
|
||||
testV2GService(outStream, outStreamLength, inStream, &inStreamLength);
|
||||
|
||||
|
||||
|
||||
return read_v2gtpHeader(inStream,inStreamLength, &payloadLength);;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
/*
|
||||
* Copyright (C) 2007-2010 Siemens AG
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*******************************************************************
|
||||
*
|
||||
* @author Sebastian.Kaebisch.EXT@siemens.com
|
||||
* @version 0.6
|
||||
* @contact Joerg.Heuer@siemens.com
|
||||
*
|
||||
********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef V2G_SERVICECLIENTDATATRANSMITTER_H_
|
||||
#define V2G_SERVICECLIENTDATATRANSMITTER_H_
|
||||
|
||||
#include "EXITypes.h"
|
||||
|
||||
/* This method has to be implemented!
|
||||
* This method sends EXI stream (outStream) to the EVSE and receives response stream (inStream)*/
|
||||
int serviceDataTransmitter(uint8_t* outStream, uint16_t outStreamLength, uint8_t* inStream);
|
||||
|
||||
#endif /* V2G_SERVICECLIENTDATATRANSMITTER_H_ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue