delete 0.6rc1

git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@64 d9f2db14-54d0-4bde-b00c-16405c910529
This commit is contained in:
sebastiankb 2012-03-30 14:04:18 +00:00
parent 37d784f56c
commit d3fe513ffc
65 changed files with 0 additions and 46162 deletions

View file

@ -1,332 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#include "appHand_service.h"
#include "appHand_dataTypes.h"
#include "EXITypes.h"
#include "appHand_EXIDecoder.h"
#include "StringTable.h"
#include <string.h>
static int _setUnsignedInt32Value(integer_t* iv, uint32_t* int32) {
int errn = 0;
switch(iv->type) {
/* Unsigned Integer */
case UNSIGNED_INTEGER_8:
*int32 = iv->val.uint8;
break;
case UNSIGNED_INTEGER_16:
*int32 = iv->val.uint16;
break;
case UNSIGNED_INTEGER_32:
if (iv->val.uint32 <= 2147483647) {
*int32 = iv->val.uint32;
} else {
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
}
break;
case UNSIGNED_INTEGER_64:
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
break;
/* (Signed) Integer */
case INTEGER_8:
*int32 = iv->val.int8;
break;
case INTEGER_16:
*int32 = iv->val.int16;
break;
case INTEGER_32:
*int32 = iv->val.int32;
break;
case INTEGER_64:
errn = EXI_UNSUPPORTED_INTEGER_VALUE;
}
return errn;
}
/**
* Deserialize an element or attribute value of the EXI stream and assign it to the
* service data structure
*/
static int deserializeElementAttributeCharacter(struct EXIDatabinder* service)
{
switch(service->eqn.namespaceURI) {
case 0:
switch(service->eqn.localPart) {
case 2: /*ProtocolNamespace*/
if(service->val.type == STRING)
{
memcpy(service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].ProtocolNamespace.data, service->val.string.codepoints,service->val.string.len*sizeof(uint32_t));
service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].ProtocolNamespace.arraylen.data = service->val.string.len;
}
else
{
return -1; /* wrong data type */
}
break;
case 5: /*VersionNumberMajor*/
if(service->val.type == UNSIGNED_INTEGER)
{
_setUnsignedInt32Value( &(service->val.integer),&(service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].VersionNumberMajor));
}
else
{
return -1; /* wrong data type */
}
break;
case 6: /*VersionNumberMinor*/
if(service->val.type == UNSIGNED_INTEGER)
{
_setUnsignedInt32Value( &(service->val.integer),&(service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].VersionNumberMinor));
}
else
{
return -1; /* wrong data type */
}
break;
case 4: /*SchemaID*/
if(service->val.type == NBIT_UNSIGNED_INTEGER)
{
if( service->idPath.id[0] == 7)
{
service->exiMsg.supportedAppProtocolRes->SchemaID = service->val.integer.val.uint8;
service->exiMsg.supportedAppProtocolRes->isused.SchemaID=1;
} else if(service->idPath.id[0] == 6)
{
service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].SchemaID = service->val.integer.val.uint8;
}
}
else
{
return -1; /* wrong data type */
}
break;
case 1: /*Priority*/
if(service->val.type == NBIT_UNSIGNED_INTEGER)
{
service->exiMsg.supportedAppProtocolReq->AppProtocol[service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol].Priority = service->val.integer.val.uint8;
}
else
{
return -1; /* wrong data type */
}
break;
case 3: /*ResponseCode*/
if(service->val.type == ENUMERATION)
{
service->exiMsg.supportedAppProtocolRes->ResponseCode = service->val.enumeration;
}
else
{
return -1; /* wrong data type */
}
break;
} /* close switch(service->eqn.localPart) */
break;
} /* close switch(service->eqn.namespaceURI) */
return 0;
}
/**
* Deserialize an element of the EXI stream
* @return 0 = 0K; -1 = ERROR
*/
static int deserializeElement(struct EXIDatabinder* service)
{
switch(service->eqn.namespaceURI) {
case 0:
switch(service->eqn.localPart) {
case 0:/* AppProtocol */
service->exiMsg.supportedAppProtocolReq->arraylen.AppProtocol++;
break;
}
break;
case 4:
switch(service->eqn.localPart) {
case 6:/* supportedAppProtocolReq */
service->exiMsg.isused.supportedAppProtocolReq=1;
break;
case 7:/* supportedAppProtocolRes */
service->exiMsg.isused.supportedAppProtocolRes=1;
break;
}
break;
}
return 0;
}
/**
* Deserialize the EXI stream
* @return 0 = 0K; -1 = ERROR
*/
int deserialize_appHand(struct EXIDatabinder* service, uint8_t* inStream, uint16_t sizeInStream, struct EXIDocumentType_appHand* exiDoc)
{
exi_name_table_runtime_t runtimeTableDecode;
uint32_t inPos;
int noEndOfDocument = 1; /* true */
int returnCode=0;
/* assign inStream data to service EXI structure */
inPos = service->transportHeaderOffset;
service->inStream.data = inStream;
service->inStream.size = sizeInStream+inPos;
service->inStream.pos = &inPos;
service->inStream.buffer=0;
service->inStream.capacity=0;
service->exiMsg=*exiDoc;
exiInitNameTableRuntime(&runtimeTableDecode);
exiappHandInitDecoder(&(service->inStream), &(service->stateDecode), runtimeTableDecode);
do {
exiappHandDecodeNextEvent(&(service->inStream), &(service->stateDecode), &(service->event));
if (returnCode < 0) {
printf("[ERROR] %d \n", returnCode);
return returnCode;
}
switch (service->event) {
case START_DOCUMENT:
returnCode = exiappHandDecodeStartDocument(&(service->inStream), &(service->stateDecode));
break;
case END_DOCUMENT:
returnCode = exiappHandDecodeEndDocument(&(service->inStream), &(service->stateDecode));
noEndOfDocument = 0; /* false */
break;
case START_ELEMENT:
returnCode = exiappHandDecodeStartElement(&(service->inStream), &(service->stateDecode), &(service->eqn));
service->idPath.id[service->idPath.pos++]=service->eqn.localPart;
break;
case END_ELEMENT:
returnCode = exiappHandDecodeEndElement(&(service->inStream), &(service->stateDecode), &(service->eqn));
service->idPath.pos--;
returnCode = deserializeElement(service);
break;
case CHARACTERS:
/* decode */
returnCode = exiappHandDecodeCharacters(&(service->inStream), &(service->stateDecode), &(service->val));
/* assign character data to the v2g message structure */
returnCode = deserializeElementAttributeCharacter(service);
break;
case ATTRIBUTE:
/* decode */
returnCode = exiappHandDecodeAttribute(&(service->inStream), &(service->stateDecode), &(service->eqn), &(service->val));
returnCode = deserializeElementAttributeCharacter(service);
break;
default:
/* ERROR */
return -1;
}
} while (noEndOfDocument);
return 0;
}
/* Initialize the deserializer */
int init_appHandDeserializer(struct EXIDatabinder* service, bytes_t bytes, string_ucs_t string, uint16_t transportHeaderOffset)
{
/* init byte array */
service->val.binary = bytes;
/* init string array */
service->val.string = string;
service->idPath.pos=0;
/* init offset for transport protocol */
service->transportHeaderOffset=transportHeaderOffset;
return 0;
}

View file

@ -1,435 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#include "appHand_service.h"
#include "appHand_dataTypes.h"
#include "appHand_dataTypes.h"
#include "StringTable.h"
#include "EXITypes.h"
#include "appHand_EXIEncoder.h"
#include <string.h>
static int serialize_AppProtocolType(struct AppProtocolType* type, struct EXIDatabinder* service)
{
/* element ID assignment of ProtocolNamespace*/
service->eqn.namespaceURI=0;
service->eqn.localPart=2;
/* encode start element ProtocolNamespace */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = STRING;
service->val.string.len = type->ProtocolNamespace.arraylen.data;
memcpy(service->val.string.codepoints, type->ProtocolNamespace.data,type->ProtocolNamespace.arraylen.data*sizeof(uint32_t));
/* encode character ProtocolNamespace */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of ProtocolNamespace */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
/* element ID assignment of VersionNumberMajor*/
service->eqn.namespaceURI=0;
service->eqn.localPart=5;
/* encode start element VersionNumberMajor */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = UNSIGNED_INTEGER;
service->val.integer.val.uint32=type->VersionNumberMajor;
service->val.integer.type = UNSIGNED_INTEGER_32;
/* encode character VersionNumberMajor */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of VersionNumberMajor */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
/* element ID assignment of VersionNumberMinor*/
service->eqn.namespaceURI=0;
service->eqn.localPart=6;
/* encode start element VersionNumberMinor */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = UNSIGNED_INTEGER;
service->val.integer.val.uint32=type->VersionNumberMinor;
service->val.integer.type = UNSIGNED_INTEGER_32;
/* encode character VersionNumberMinor */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of VersionNumberMinor */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
/* element ID assignment of SchemaID*/
service->eqn.namespaceURI=0;
service->eqn.localPart=4;
/* encode start element SchemaID */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = NBIT_UNSIGNED_INTEGER;
service->val.integer.val.uint8=type->SchemaID;
service->val.integer.type = UNSIGNED_INTEGER_8;
/* encode character SchemaID */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of SchemaID */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
/* element ID assignment of Priority*/
service->eqn.namespaceURI=0;
service->eqn.localPart=1;
/* encode start element Priority */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = NBIT_UNSIGNED_INTEGER;
service->val.integer.val.uint8=type->Priority;
service->val.integer.type = UNSIGNED_INTEGER_8;
/* encode character Priority */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of Priority */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
return 0;
}
static int serialize_AnonType_supportedAppProtocolReq(struct AnonType_supportedAppProtocolReq* type, struct EXIDatabinder* service)
{
size_t i_loop;
for(i_loop=0;i_loop < type->arraylen.AppProtocol;i_loop++)
{
/* element ID assignment of AppProtocol*/
service->eqn.namespaceURI=0;
service->eqn.localPart=0;
/* encode start element AppProtocol */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
/* encode children of AppProtocol */
if(serialize_AppProtocolType(&(type->AppProtocol[i_loop]),service))
{
return -1;
}
/* encode end element of AppProtocol */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
}
return 0;
}
static int serialize_AnonType_supportedAppProtocolRes(struct AnonType_supportedAppProtocolRes* type, struct EXIDatabinder* service)
{
/* element ID assignment of ResponseCode*/
service->eqn.namespaceURI=0;
service->eqn.localPart=3;
/* encode start element ResponseCode */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = ENUMERATION;
service->val.enumeration=type->ResponseCode;
/* encode character ResponseCode */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of ResponseCode */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
if(type->isused.SchemaID)
{
/* element ID assignment of SchemaID*/
service->eqn.namespaceURI=0;
service->eqn.localPart=4;
/* encode start element SchemaID */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
service->val.type = NBIT_UNSIGNED_INTEGER;
service->val.integer.val.uint8=type->SchemaID;
service->val.integer.type = UNSIGNED_INTEGER_8;
/* encode character SchemaID */
if (exiappHandEncodeCharacters(&(service->outStream), &(service->stateEncode), &(service->val)))
{
return -1;
}
/* encode end element of SchemaID */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
}
return 0;
}
static int serialize_EXIDocumentType(struct EXIDocumentType_appHand* type, struct EXIDatabinder* service)
{
if(type->isused.supportedAppProtocolReq)
{
/* element ID assignment of supportedAppProtocolReq*/
service->eqn.namespaceURI=4;
service->eqn.localPart=6;
/* encode start element supportedAppProtocolReq */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
/* encode children of supportedAppProtocolReq */
if(serialize_AnonType_supportedAppProtocolReq( (type->supportedAppProtocolReq),service))
{
return -1;
}
/* encode end element of supportedAppProtocolReq */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
return 0;
}
if(type->isused.supportedAppProtocolRes)
{
/* element ID assignment of supportedAppProtocolRes*/
service->eqn.namespaceURI=4;
service->eqn.localPart=7;
/* encode start element supportedAppProtocolRes */
if (exiappHandEncodeStartElement(&(service->outStream), &(service->stateEncode), &(service->eqn)))
{
return -1;
}
/* encode children of supportedAppProtocolRes */
if(serialize_AnonType_supportedAppProtocolRes( (type->supportedAppProtocolRes),service))
{
return -1;
}
/* encode end element of supportedAppProtocolRes */
exiappHandEncodeEndElement(&(service->outStream), &(service->stateEncode));
}
return 0;
}
/* marshal data to EXI stream */
static int serialize_message(struct EXIDatabinder* service)
{
/* encode start document */
if (exiappHandEncodeStartDocument(&(service->outStream), &(service->stateEncode)) )
{
return -1;
}
/* encode root element of null */
if (serialize_EXIDocumentType(&(service->exiMsg), service))
{
return -1;
}
/* encode end document */
if (exiappHandEncodeEndDocument(&(service->outStream), &(service->stateEncode))) {
return -1;
}
return 0;
}
int serialize_appHand(struct EXIDatabinder* service, uint8_t* outStream, uint16_t* payloadLength, struct EXIDocumentType_appHand* exiDoc)
{
exi_name_table_runtime_t runtimeTableEncode;
uint32_t outPos;
outPos=service->transportHeaderOffset;
/* assign outStream data to service EXI structure */
service->outStream.data = outStream;
service->outStream.pos = &outPos;
service->outStream.buffer=0;
service->outStream.capacity=8;
service->exiMsg = *exiDoc;
/* init encoder (write header, set initial state) */
exiInitNameTableRuntime(&runtimeTableEncode);
exiappHandInitEncoder(&(service->outStream), &(service->stateEncode), runtimeTableEncode);
if(serialize_message(service))
return -1;
outPos -= service->transportHeaderOffset;
*payloadLength = outPos;
return 0;
}
/* Initialize serializer */
int init_appHandSerializer(struct EXIDatabinder* service, bytes_t bytes, string_ucs_t string, size_t max_outStream_size, uint16_t transportHeaderOffset)
{
/* init byte array */
service->val.binary = bytes;
/* init string array */
service->val.string = string;
/* init output stream */
service->outStream.size=max_outStream_size;
service->transportHeaderOffset=transportHeaderOffset;
return 0;
}

View file

@ -1,70 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#include "EXITypes.h"
#include "appHand_dataTypes.h"
static void init_protocolNamespaceType(struct protocolNamespaceType* type)
{
type->arraylen.data=0;
}
static void init_AppProtocolType(struct AppProtocolType* type)
{
init_protocolNamespaceType(&(type->ProtocolNamespace));
}
void init_AnonType_supportedAppProtocolReq(struct AnonType_supportedAppProtocolReq* type)
{
int i_loop;
for(i_loop=0; i_loop<5;i_loop++)
{
init_AppProtocolType(&(type->AppProtocol[i_loop]));
}
type->arraylen.AppProtocol=0;
}
void init_AnonType_supportedAppProtocolRes(struct AnonType_supportedAppProtocolRes* type)
{
type->isused.SchemaID=0;
}
void init_EXIDocumentType_appHand(struct EXIDocumentType_appHand* type)
{
type->isused.supportedAppProtocolReq=0;
type->isused.supportedAppProtocolRes=0;
}

View file

@ -1,131 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef APPHANDDATATYPES_H
#define APPHANDDATATYPES_H
#include "EXITypes.h"
enum responseCodeType_appHand
{
OK_SuccessfulNegotiation_responseCodeType,
OK_SuccessfulNegotiationWithMinorDeviation_responseCodeType,
Failed_NoNegotiation_responseCodeType
};
struct arraylen_protocolNamespaceType
{
size_t data;
};
struct protocolNamespaceType
{
uint32_t data[100];
struct arraylen_protocolNamespaceType arraylen;
};
struct AppProtocolType
{
struct protocolNamespaceType ProtocolNamespace;
uint32_t VersionNumberMajor;
uint32_t VersionNumberMinor;
uint8_t SchemaID;
uint8_t Priority;
};
struct arraylen_AnonType_supportedAppProtocolReq
{
size_t AppProtocol;
};
struct AnonType_supportedAppProtocolReq
{
struct AppProtocolType AppProtocol[5];
struct arraylen_AnonType_supportedAppProtocolReq arraylen;
};
struct selection_EXIDocumentType
{
unsigned int supportedAppProtocolReq:1;
unsigned int supportedAppProtocolRes:1;
};
struct selection_AnonType_supportedAppProtocolRes
{
unsigned int SchemaID:1;
};
struct AnonType_supportedAppProtocolRes
{
enum responseCodeType_appHand ResponseCode;
uint8_t SchemaID;
struct selection_AnonType_supportedAppProtocolRes isused;
};
struct EXIDocumentType_appHand
{
struct AnonType_supportedAppProtocolReq* supportedAppProtocolReq;
struct AnonType_supportedAppProtocolRes* supportedAppProtocolRes;
struct selection_EXIDocumentType isused;
};
void init_EXIDocumentType_appHand(struct EXIDocumentType_appHand* type);
void init_AnonType_supportedAppProtocolReq(struct AnonType_supportedAppProtocolReq* type);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,84 +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
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_DATABINDER_H_
#define EXI_DATABINDER_H_
#include "appHand_dataTypes.h"
struct uniqueIDPath2
{
int id[10];
size_t pos;
};
struct EXIDatabinder
{
/* in-/ out-stream */
bitstream_t inStream;
bitstream_t outStream;
/* EXI */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
/* main message data structure */
struct EXIDocumentType_appHand exiMsg;
/* unique id for ambiguous elements */
struct uniqueIDPath2 idPath;
uint16_t transportHeaderOffset;
/* error code */
uint8_t errorCode;
};
int serialize_appHand(struct EXIDatabinder* service, uint8_t* outStream, uint16_t* outPos, struct EXIDocumentType_appHand* exiDoc);
int deserialize_appHand(struct EXIDatabinder* service, uint8_t* inStream, uint16_t sizeInStream, struct EXIDocumentType_appHand* exiDoc);
int init_appHandSerializer(struct EXIDatabinder* service, bytes_t bytes, string_ucs_t string, size_t max_outStream_size, uint16_t transportHeaderOffset);
int init_appHandDeserializer(struct EXIDatabinder* service, bytes_t bytes, string_ucs_t string, uint16_t transportHeaderOffset);
/* define error codes (TODO: define precise error codes) */
#define EXI_NON_VALID_MESSAGE 0x01
#define EXI_SERIALIZATION_FAILED 0x02
#define EXI_UNKNOWN_ERROR 0xFF
#endif /* EXI_DATABINDER_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -1,579 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "DecoderChannel.h"
#include "CoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef ABSTRACT_DECODER_CHANNEL_C
#define ABSTRACT_DECODER_CHANNEL_C
/* unsigned long == 64 bits, 10 * 7bits = 70 bits */
#define MAX_OCTETS_FOR_UNSIGNED_INTEGER_64 10
/* unsigned int == 32 bits, 5 * 7bits = 35 bits */
#define MAX_OCTETS_FOR_UNSIGNED_INTEGER_32 5
/* buffer for reading (arbitrary) large integer values */
static unsigned int maskedOctets[MAX_OCTETS_FOR_UNSIGNED_INTEGER_64];
static int _decodeUnsignedInteger(bitstream_t* stream, integer_t* iv, int negative) {
int errn = 0;
int i, k;
uint8_t b;
for (i = 0; i < MAX_OCTETS_FOR_UNSIGNED_INTEGER_64; i++) {
/* Read the next octet */
errn = decode(stream, &b);
/* If the most significant bit of the octet was 1,
another octet is going to come */
if (b < 128) {
/* no more octets */
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
switch(i) {
case 0: /* 7 bits */
if (negative) {
iv->val.int8 = - ( b + 1);
iv->type = INTEGER_8;
} else {
iv->val.uint8 = b;
iv->type = UNSIGNED_INTEGER_8;
}
return 0;
case 1: /* 14 bits */
maskedOctets[i] = b;
iv->val.uint16 = 0;
for (k = i; k >= 0 ; k--) {
iv->val.uint16 = (iv->val.uint16 << 7) | maskedOctets[k];
}
if (negative) {
iv->val.int16 = - ( iv->val.uint16 + 1 );
iv->type = INTEGER_16;
} else {
iv->type = UNSIGNED_INTEGER_16;
}
return 0;
case 2: /* 21 bits */
case 3: /* 28 bits */
maskedOctets[i] = b;
iv->val.uint32 = 0;
for (k = i; k >= 0 ; k--) {
iv->val.uint32 = (iv->val.uint32 << 7) | maskedOctets[k];
}
if (negative) {
iv->val.int32 = - ( iv->val.uint32 + 1 );
if (iv->val.int32 <= INT16_MAX && iv->val.int32 >= INT16_MIN ) {
iv->type = INTEGER_16;
} else {
iv->type = INTEGER_32;
}
} else {
if (iv->val.uint32 <= UINT16_MAX) {
iv->type = UNSIGNED_INTEGER_16;
} else {
iv->type = UNSIGNED_INTEGER_32;
}
}
return 0;
case 4: /* 35 bits */
case 5: /* 42 bits */
case 6: /* 49 bits */
case 7: /* 56 bits */
case 8: /* 63 bits */
case 9: /* 70 bits */
maskedOctets[i] = b;
iv->val.uint64 = 0;
for (k = i; k >= 0 ; k--) {
iv->val.uint64 = (iv->val.uint64 << 7) | maskedOctets[k];
}
if (negative) {
if (i > 8) {
/* too large */
return EXI_UNSUPPORTED_INTEGER_VALUE;
}
iv->val.int64 = - ( iv->val.uint64 + 1 );
if (iv->val.int64 <= INT32_MAX && iv->val.int64 >= INT32_MIN ) {
iv->type = INTEGER_32;
} else {
iv->type = INTEGER_64;
}
} else {
if (iv->val.uint64 <= UINT32_MAX) {
iv->type = UNSIGNED_INTEGER_32;
/* iv->val.uint32 = iv->val.uint64;*/
} else {
iv->type = UNSIGNED_INTEGER_64;
}
}
return 0;
default:
return EXI_UNSUPPORTED_INTEGER_VALUE;
}
} else {
/* the 7 least significant bits hold the actual value */
maskedOctets[i] = (b & 127);
}
}
return EXI_UNSUPPORTED_INTEGER_VALUE;
}
int decodeUnsignedInteger(bitstream_t* stream, integer_t* iv) {
return _decodeUnsignedInteger(stream, iv, 0);
}
int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16) {
unsigned int mShift = 0;
int errn = 0;
uint8_t b;
*uint16 = 0;
do {
/* 1. Read the next octet */
errn = decode(stream, &b);
/* 2. Multiply the value of the unsigned number represented by the 7
* least significant
* bits of the octet by the current multiplier and add the result to
* the current value */
*uint16 += (b & 127) << mShift;
/* 3. Multiply the multiplier by 128 */
mShift += 7;
/* 4. If the most significant bit of the octet was 1, go back to step 1 */
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32) {
/* 0XXXXXXX ... 1XXXXXXX 1XXXXXXX */
unsigned int mShift = 0;
int errn = 0;
uint8_t b;
*uint32 = 0;
do {
/* 1. Read the next octet */
errn = decode(stream, &b);
/* 2. Multiply the value of the unsigned number represented by the 7
* least significant
* bits of the octet by the current multiplier and add the result to
* the current value */
*uint32 += (b & 127) << mShift;
/* 3. Multiply the multiplier by 128 */
mShift += 7;
/* 4. If the most significant bit of the octet was 1, go back to step 1 */
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64) {
unsigned int mShift = 0;
int errn = 0;
uint8_t b;
*uint64 = 0L;
do {
errn = decode(stream, &b);
*uint64 += ((uint64_t) (b & 127)) << mShift;
mShift += 7;
} while (errn >= 0 && (b >> 7) == 1);
return errn;
}
int decodeInteger(bitstream_t* stream, integer_t* iv) {
int b;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
return _decodeUnsignedInteger(stream, iv, b);
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32) {
int b;
uint32_t uint32;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = -(uint32 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger32(stream, &uint32);
*int32 = (int32_t)(uint32);
}
return errn;
}
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64) {
int b;
uint64_t uint64;
int errn = decodeBoolean(stream, &b);
if (errn < 0) {
return errn;
}
if (b) {
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = -(uint64 + 1);
} else {
/* positive */
errn = decodeUnsignedInteger64(stream, &uint64);
*int64 = (int64_t)(uint64);
}
return errn;
}
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = decodeInteger64(stream, &f->mantissa);
if (errn < 0) {
return errn;
}
return decodeInteger32(stream, &f->exponent);
}
/**
* Decode a decimal represented as a Boolean sign followed by two Unsigned
* Integers. A sign value of zero (0) is used to represent positive Decimal
* values and a sign value of one (1) is used to represent negative Decimal
* values The first Integer represents the integral portion of the Decimal
* value. The second positive integer represents the fractional portion of
* the decimal with the digits in reverse order to preserve leading zeros.
*/
int decodeDecimal(bitstream_t* stream, decimal_t* d) {
int errn = decodeBoolean(stream, &d->negative);
if (errn < 0) {
return errn;
}
errn = decodeUnsignedInteger(stream, &d->integral);
if (errn < 0) {
return errn;
}
errn = decodeUnsignedInteger(stream, &d->reverseFraction);
return errn;
}
/**
* Decode a sequence of characters for a given length.
*/
int decodeStringOnly(bitstream_t* stream, uint16_t len, string_ucs_t* s) {
if (len > s->size) {
/* not enough space */
return EXI_ERROR_OUT_OF_STRING_BUFFER;
}
decodeCharacters(stream, len, s->codepoints);
s->len = len;
return 0;
}
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger16(stream, &s->len);
if (errn < 0) {
return errn;
}
return decodeStringOnly(stream, s->len, s);
}
int decodeStringASCII(bitstream_t* stream, string_ascii_t* s) {
uint16_t slen;
int errn = decodeUnsignedInteger16(stream, &slen);
if (errn < 0) {
return errn;
}
if (s->size < slen) {
return EXI_ERROR_OUT_OF_ASCII_BUFFER;
}
return decodeCharactersASCII(stream, slen, s->chars);
}
int decodeStringValue(bitstream_t* stream, string_ucs_t* s) {
int errn = decodeUnsignedInteger16(stream, &s->len);
if (errn < 0) {
return errn;
}
switch (s->len) {
case 0:
/* local value partition */
return EXI_UNSUPPORTED_STRING_TABLE_LOCAL_HIT;
case 1:
/* found in global value partition */
return EXI_UNSUPPORTED_STRING_TABLE_GLOBAL_HIT;
default:
/* not found in global value (and local value) partition
* ==> string literal is encoded as a String with the length
* incremented by two */
return decodeStringOnly(stream, ((s->len) - 2), s);
/* After encoding the string value, it is added to both the
* associated "local" value string table partition and the global
* value string table partition */
/* addValue(context, value); */
}
}
int decodeRCSStringValue(bitstream_t* stream, rcs_t* rcs, string_ucs_t* s) {
unsigned int i;
uint32_t cp;
int errn = decodeUnsignedInteger16(stream, &s->len);
if (errn < 0) {
return errn;
}
switch (s->len) {
case 0:
/* local value partition */
return EXI_UNSUPPORTED_STRING_TABLE_LOCAL_HIT;
case 1:
/* found in global value partition */
return EXI_UNSUPPORTED_STRING_TABLE_GLOBAL_HIT;
default:
/* not found in global value (and local value) partition
* ==> string literal is encoded as a String with the length
* incremented by two */
s->len = s->len - 2;
if (s->len > s->size) {
/* not enough space */
return EXI_ERROR_OUT_OF_STRING_BUFFER;
}
for (i = 0; i < s->len && errn >= 0; i++) {
errn = decodeNBitUnsignedInteger(stream, rcs->codingLength, &cp);
if (errn < 0) {
return errn;
}
s->codepoints[i] = rcs->codepoints[cp];
}
/* After encoding the string value, it is added to both the
* associated "local" value string table partition and the global
* value string table partition */
/* addValue(context, value); */
return 0;
}
}
/**
* Decode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int decodeCharacters(bitstream_t* stream, uint16_t len, uint32_t* chars) {
unsigned int i;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = decodeUnsignedInteger32(stream, &chars[i]);
if (errn < 0) {
return errn;
}
}
return errn;
}
int decodeCharactersASCII(bitstream_t* stream, uint16_t len, char* chars) {
unsigned int i;
uint32_t c;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = decodeUnsignedInteger32(stream, &c);
if (errn < 0) {
return errn;
}
if (c > 127) {
return EXI_ERROR_CONVERSION_NO_ASCII_CHARACTERS;
}
chars[i] = c;
}
chars[i] = '\0';
return errn;
}
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
uint8_t b;
int errn = decodeUnsignedInteger16(stream, &bytes->len);
if (errn < 0) {
return errn;
}
if (bytes->len > bytes->size) {
/* not enough space */
return EXI_ERROR_OUT_OF_BYTE_BUFFER;
}
for (i = 0; i < bytes->len && errn >= 0; i++) {
errn = decode(stream, &b);
if (errn < 0) {
return errn;
}
bytes->data[i] = (uint8_t)b;
}
return errn;
}
/**
* Decode Date-Time as sequence of values representing the individual
* components of the Date-Time.
*/
int decodeDateTime(bitstream_t* stream, exi_datetime_type_t type, datetime_t* datetime){
int errn;
datetime->type = type;
datetime->year = 0;
datetime->monthDay = 0;
datetime->time = 0;
datetime->presenceFractionalSecs = 0;
datetime->fractionalSecs = 0;
datetime->presenceTimezone = 0;
datetime->timezone = 0;
switch (type) {
case exiGYear: /* Year, [Time-Zone] */
errn = decodeInteger32(stream, &datetime->year);
if (errn < 0) {
return errn;
}
datetime->year += DATETIME_YEAR_OFFSET;
break;
case exiGYearMonth: /* Year, MonthDay, [TimeZone] */
case exiDate:
errn = decodeInteger32(stream, &datetime->year);
if (errn < 0) {
return errn;
}
datetime->year += DATETIME_YEAR_OFFSET;
errn = decodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, &datetime->monthDay);
break;
case exiDateTime: /* Year, MonthDay, Time, [FractionalSecs], [TimeZone] */
/* e.g. "0001-01-01T00:00:00.111+00:33" */
errn = decodeInteger32(stream, &datetime->year);
if (errn < 0) {
return errn;
}
datetime->year += DATETIME_YEAR_OFFSET;
errn = decodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, &datetime->monthDay);
if (errn < 0) {
return errn;
}
/* Note: *no* break */
case exiTime: /* Time, [FractionalSecs], [TimeZone] */
/* e.g. "12:34:56.135" */
errn = decodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIME, &datetime->time);
if (errn < 0) {
return errn;
}
errn = decodeBoolean(stream, &datetime->presenceFractionalSecs);
if (errn < 0) {
return errn;
}
if (datetime->presenceFractionalSecs) {
errn = decodeUnsignedInteger32(stream, &datetime->fractionalSecs);
}
break;
case exiGMonth: /* MonthDay, [TimeZone] */
/* e.g. "--12" */
case exiGMonthDay: /* MonthDay, [TimeZone] */
/* e.g. "--01-28" */
case exiGDay: /* MonthDay, [TimeZone] */
/* "---16" */
errn = decodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, &datetime->monthDay );
break;
default:
return -1;
}
errn = decodeBoolean(stream, &datetime->presenceTimezone );
if (errn < 0) {
return errn;
}
if (datetime->presenceTimezone) {
errn = decodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIMEZONE, &datetime->timezone);
datetime->timezone -= DATETIME_TIMEZONE_OFFSET_IN_MINUTES;
}
return errn;
}
#endif

View file

@ -1,436 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EncoderChannel.h"
#include "CoderChannel.h"
#include "BitOutputStream.h"
#include "EXITypes.h"
#include "MethodsBag.h"
#ifndef ABSTRACT_ENCODER_CHANNEL_C
#define ABSTRACT_ENCODER_CHANNEL_C
int encodeUnsignedInteger(bitstream_t* stream, integer_t* iv) {
int errn = 0;
switch(iv->type) {
/* Unsigned Integer */
case UNSIGNED_INTEGER_8:
errn = encodeUnsignedInteger32(stream, iv->val.uint8);
break;
case UNSIGNED_INTEGER_16:
errn = encodeUnsignedInteger32(stream, iv->val.uint16);
break;
case UNSIGNED_INTEGER_32:
errn = encodeUnsignedInteger32(stream, iv->val.uint32);
break;
case UNSIGNED_INTEGER_64:
errn = encodeUnsignedInteger64(stream, iv->val.uint64);
break;
/* (Signed) Integer */
case INTEGER_8:
if (iv->val.int8 < 0) {
return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE;
}
errn = encodeUnsignedInteger32(stream, iv->val.int8);
break;
case INTEGER_16:
if (iv->val.int16 < 0) {
return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE;
}
errn = encodeUnsignedInteger32(stream, iv->val.int16);
break;
case INTEGER_32:
if (iv->val.int32 < 0) {
return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE;
}
errn = encodeUnsignedInteger32(stream, iv->val.int32);
break;
case INTEGER_64:
if (iv->val.int64 < 0) {
return EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE;
}
errn = encodeUnsignedInteger64(stream, iv->val.int64);
break;
default:
errn = EXI_UNSUPPORTED_INTEGER_VALUE_TYPE;
}
return errn;
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n) {
int errn = 0;
if (n < 128) {
/* write byte as is */
errn = encode(stream, (uint8_t) n);
} else {
uint8_t n7BitBlocks = numberOf7BitBlocksToRepresent(n);
switch (n7BitBlocks) {
case 5:
errn = encode(stream, (uint8_t) (128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 4:
errn = encode(stream, (uint8_t) (128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 3:
errn = encode(stream, (uint8_t) (128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 2:
errn = encode(stream, (uint8_t) (128 | n));
n = n >> 7;
if (errn < 0) {
break;
}
case 1:
/* 0 .. 7 (last byte) */
errn = encode(stream, (uint8_t) (0 | n));
}
}
return errn;
}
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n) {
int errn = 0;
uint8_t lastEncode = (uint8_t) n;
n >>= 7;
while (n != 0) {
errn = encode(stream, lastEncode | 128);
if (errn < 0) {
return errn;
}
lastEncode = (uint8_t) n;
n >>= 7;
}
return encode(stream, lastEncode);
}
int encodeInteger(bitstream_t* stream, integer_t* iv) {
int errn = 0;
switch(iv->type) {
/* Unsigned Integer */
case UNSIGNED_INTEGER_8:
errn = encodeInteger32(stream, iv->val.uint8);
break;
case UNSIGNED_INTEGER_16:
errn = encodeInteger32(stream, iv->val.uint16);
break;
case UNSIGNED_INTEGER_32:
errn = encodeInteger64(stream, iv->val.uint32);
break;
case UNSIGNED_INTEGER_64:
errn = encodeInteger64(stream, iv->val.uint64);
break;
/* (Signed) Integer */
case INTEGER_8:
errn = encodeInteger32(stream, iv->val.int8);
break;
case INTEGER_16:
errn = encodeInteger32(stream, iv->val.int16);
break;
case INTEGER_32:
errn = encodeInteger32(stream, iv->val.int32);
break;
case INTEGER_64:
errn = encodeInteger64(stream, iv->val.int64);
break;
default:
errn = EXI_UNSUPPORTED_INTEGER_VALUE_TYPE;
}
return errn;
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger32(stream, n);
}
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n) {
int errn;
/* signalize sign */
if (n < 0) {
errn = encodeBoolean(stream, 1);
/* For negative values, the Unsigned Integer holds the
* magnitude of the value minus 1 */
n = (-n) - 1;
} else {
errn = encodeBoolean(stream, 0);
}
if (errn < 0) {
return errn;
}
return encodeUnsignedInteger64(stream, n);
}
/**
* The Float datatype representation is two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f) {
int errn = encodeInteger64(stream, f->mantissa);
if (errn >= 0) {
errn = encodeInteger32(stream, f->exponent);
}
return errn;
}
/**
* Encode a decimal represented as a Boolean sign followed by two Unsigned
* Integers. A sign value of zero (0) is used to represent positive Decimal
* values and a sign value of one (1) is used to represent negative Decimal
* values The first Integer represents the integral portion of the Decimal
* value. The second positive integer represents the fractional portion of
* the decimal with the digits in reverse order to preserve leading zeros.
*/
int encodeDecimal(bitstream_t* stream, decimal_t* d) {
/* sign, integral, reverse fractional */
int errn = encodeBoolean(stream, d->negative);
if (errn < 0) {
return errn;
}
errn = encodeUnsignedInteger(stream, &d->integral);
if (errn < 0) {
return errn;
}
errn = encodeUnsignedInteger(stream, &d->reverseFraction);
return errn;
}
/**
* Encode a length prefixed sequence of characters.
*/
int encodeASCII(bitstream_t* stream, const char* ascii) {
int errn;
uint32_t slen = (uint32_t) strlen(ascii);
errn = encodeUnsignedInteger32(stream, slen);
if (errn >= 0) {
errn = encodeASCIICharacters(stream, ascii, slen);
}
return errn;
}
int encodeString(bitstream_t* stream, string_ucs_t* string) {
int errn = encodeUnsignedInteger32(stream, string->len);
if (errn >= 0) {
errn = encodeUCSCharacters(stream, string->codepoints, string->len);
}
return errn;
}
int encodeStringValue(bitstream_t* stream, string_ucs_t* string) {
/* encode string as string table miss */
int errn = encodeUnsignedInteger32(stream, string->len + 2);
if (errn >= 0) {
errn = encodeUCSCharacters(stream, string->codepoints, string->len);
}
return errn;
}
int encodeRCSStringValue(bitstream_t* stream, rcs_t* rcs, string_ucs_t* string) {
unsigned int i;
uint32_t k;
/* encode string as string table miss */
int errn = encodeUnsignedInteger32(stream, string->len + 2);
if (errn >= 0) {
for (i = 0; i < string->len && errn >= 0; i++) {
for (k = 0; k < rcs->size && errn >= 0; k++) {
if (rcs->codepoints[k] == string->codepoints[i]) {
errn = encodeNBitUnsignedInteger(stream, rcs->codingLength, k);
break; /* break inner for loop */
}
}
}
}
return errn;
}
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeUCSCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len) {
unsigned int i;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = encodeUnsignedInteger32(stream, chars[i]);
}
return errn;
}
int encodeASCIICharacters(bitstream_t* stream, const char* chars, uint16_t len) {
unsigned int i;
int errn = 0;
for (i = 0; i < len && errn >= 0; i++) {
errn = encode(stream, chars[i]);
}
return errn;
}
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes) {
unsigned int i;
int errn = encodeUnsignedInteger32(stream, bytes->len);
for (i = 0; i < bytes->len && errn >= 0; i++) {
errn = encode(stream, bytes->data[i]);
}
return errn;
}
/**
* Encode a datetime representation which is a sequence of values
* representing the individual components of the Date-Time
*/
int encodeDateTime(bitstream_t* stream, datetime_t* datetime) {
int errn = 0;
switch (datetime->type) {
case exiGYear: /* Year, [Time-Zone] */
errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET);
break;
case exiGYearMonth: /* Year, MonthDay, [TimeZone] */
case exiDate: /* Year, MonthDay, [TimeZone] */
errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET);
if (errn < 0) {
return errn;
}
errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, datetime->monthDay);
break;
case exiDateTime: /* Year, MonthDay, Time, [FractionalSecs], [TimeZone] */
errn = encodeInteger32(stream, datetime->year - DATETIME_YEAR_OFFSET);
if (errn < 0) {
return errn;
}
errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, datetime->monthDay);
if (errn < 0) {
return errn;
}
/* Note: *no* break */
case exiTime: /* Time, [FractionalSecs], [TimeZone] */
errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIME, datetime->time);
if (errn < 0) {
return errn;
}
if (datetime->presenceFractionalSecs) {
encodeBoolean(stream, 1);
if (errn < 0) {
return errn;
}
encodeUnsignedInteger32(stream, datetime->fractionalSecs);
} else {
encodeBoolean(stream, 0);
}
break;
case exiGMonth: /* MonthDay, [TimeZone] */
case exiGMonthDay: /* MonthDay, [TimeZone] */
case exiGDay: /* MonthDay, [TimeZone] */
errn = encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_MONTHDAY, datetime->monthDay);
break;
default:
return EXI_ERROR_UNEXPECTED_DATETIME_TYPE;
}
if (errn < 0) {
return errn;
}
/* [TimeZone] */
if (datetime->presenceTimezone) {
errn = encodeBoolean(stream, 1);
if (errn < 0) {
return errn;
}
encodeNBitUnsignedInteger(stream, DATETIME_NUMBER_BITS_TIMEZONE, datetime->timezone
+ DATETIME_TIMEZONE_OFFSET_IN_MINUTES);
} else {
encodeBoolean(stream, 0);
}
return errn;
}
#endif

View file

@ -1,73 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "DecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef BIT_DECODER_CHANNEL_C
#define BIT_DECODER_CHANNEL_C
#if EXI_ALIGNMENT == BIT_PACKED
int decode(bitstream_t* stream, uint8_t* b) {
uint32_t bb;
int errn = readBits(stream, 8, &bb);
if (errn < 0) {
return errn;
}
if (bb > 256) {
return EXI_ERROR_UNEXPECTED_BYTE_VALUE;
} else {
*b = (uint8_t)bb;
}
return errn;
}
int decodeBoolean(bitstream_t* stream, int* b) {
uint32_t ub;
int errn = readBits(stream, 1, &ub);
*b = (ub == 0) ? 0 : 1;
return errn;
}
int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32) {
if (nbits == 0) {
*uint32 = 0;
return 0;
} else {
return readBits(stream, nbits, uint32);
}
}
#endif
#endif

View file

@ -1,88 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EncoderChannel.h"
#include "CoderChannel.h"
#include "BitOutputStream.h"
#include "EXITypes.h"
#ifndef BIT_ENCODER_CHANNEL_C
#define BIT_ENCODER_CHANNEL_C
#if EXI_ALIGNMENT == BIT_PACKED
int encode(bitstream_t* stream, uint8_t b) {
return writeBits(stream, 8, b);
}
/**
* Encode a single boolean value. A false value is encoded as bit 0 and true
* value is encode as bit 1.
*/
int encodeBoolean(bitstream_t* stream, int b) {
uint8_t val = b ? 1 : 0;
return writeBits(stream, 1, val);
}
/**
* Encode n-bit unsigned integer. The n least significant bits of parameter
* b starting with the most significant, i.e. from left to right.
*/
int encodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t val) {
if (nbits > 0) {
return writeBits(stream, nbits, val);
}
return 0;
}
/**
* Flush underlying bit output stream.
*/
int encodeFinish(bitstream_t* stream) {
return flush(stream);
}
#endif /* alignment */
#endif

View file

@ -1,110 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EXITypes.h"
#include "BitInputStream.h"
#ifndef BIT_INPUT_STREAM_C
#define BIT_INPUT_STREAM_C
/* internal method to (re)fill buffer */
int readBuffer(bitstream_t* stream)
{
int errn = 0;
if(stream->capacity==0)
{
#if EXI_STREAM == BYTE_ARRAY
if ( (*stream->pos) < stream->size ) {
stream->buffer = stream->data[(*stream->pos)++];
stream->capacity = BITS_IN_BYTE;
} else {
errn = EXI_ERROR_INPUT_STREAM_EOF;
}
#endif
#if EXI_STREAM == FILE_STREAM
stream->buffer = getc(stream->file);
/* EOF cannot be used, 0xFF valid value */
if ( feof(stream->file) || ferror(stream->file) ) {
return EXI_ERROR_INPUT_STREAM_EOF;
}
stream->capacity = BITS_IN_BYTE;
#endif
}
return errn;
}
int readBits(bitstream_t* stream, uint16_t num_bits, uint32_t* b)
{
int errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
/* read the bits in one step */
if(num_bits <= stream->capacity)
{
stream->capacity -= num_bits;
*b = (stream->buffer >> stream->capacity) & (0xff >> (BITS_IN_BYTE - num_bits));
}
else
{
/* read bits as much as possible */
*b = stream->buffer & (0xff >> (BITS_IN_BYTE - stream->capacity));
num_bits -= stream->capacity;
stream->capacity = 0;
/* read whole bytes */
while(num_bits >= 8)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << BITS_IN_BYTE) | stream->buffer;
num_bits -= BITS_IN_BYTE;
stream->capacity = 0;
}
/* read the spare bits in the buffer */
if(num_bits>0)
{
errn = readBuffer(stream);
if (errn < 0) {
return errn;
}
*b = ((*b) << num_bits) | (stream->buffer >> (BITS_IN_BYTE - num_bits));
stream->capacity = BITS_IN_BYTE - num_bits;
}
}
return errn;
}
#endif

View file

@ -1,48 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BIT_INPUT_STREAM_H
#define BIT_INPUT_STREAM_H
int readBits(bitstream_t* stream, uint16_t num_bits, uint32_t* b);
int flush();
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,118 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EXITypes.h"
#include "BitOutputStream.h"
#ifndef BIT_OUTPUT_STREAM_C
#define BIT_OUTPUT_STREAM_C
/* NOTE: nbits <= 8 */
int writeBits(bitstream_t* stream, uint16_t nbits, uint32_t val) {
/* is there enough space in the buffer */
if (nbits <= stream->capacity) {
/* all bits fit into the current buffer */
stream->buffer = (stream->buffer << (nbits)) | (val & (0xff
>> (BITS_IN_BYTE - nbits)));
stream->capacity -= nbits;
/* if the buffer is full write byte */
if (stream->capacity == 0) {
#if EXI_STREAM == BYTE_ARRAY
if ((*stream->pos) >= stream->size) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
stream->data[(*stream->pos)++] = stream->buffer;
#endif
#if EXI_STREAM == FILE_STREAM
if ( putc(stream->buffer, stream->file) == EOF ) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
#endif
stream->capacity = BITS_IN_BYTE;
stream->buffer = 0;
}
} else {
/* the buffer is not enough
* fill the buffer */
stream->buffer = (stream->buffer << stream->capacity) | ((val >> (nbits
- stream->capacity)) & (0xff >> (BITS_IN_BYTE
- stream->capacity)));
nbits -= stream->capacity;
#if EXI_STREAM == BYTE_ARRAY
if ((*stream->pos) >= stream->size) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
stream->data[(*stream->pos)++] = stream->buffer;
#endif
#if EXI_STREAM == FILE_STREAM
if ( putc(stream->buffer, stream->file) == EOF ) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
#endif
stream->buffer = 0;
/* write whole bytes */
while (nbits >= BITS_IN_BYTE) {
nbits -= BITS_IN_BYTE;
#if EXI_STREAM == BYTE_ARRAY
if ((*stream->pos) >= stream->size) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
stream->data[(*stream->pos)++] = (val >> (nbits));
#endif
#if EXI_STREAM == FILE_STREAM
if ( putc((val >> (nbits)), stream->file) == EOF ) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
#endif
}
/* spared bits are kept in the buffer */
stream->buffer = val; /* Note: the high bits will be shifted out during further filling */
stream->capacity = BITS_IN_BYTE - (nbits);
}
return 0;
}
/**
* Flush output
*/
int flush(bitstream_t* stream) {
if (stream->capacity == BITS_IN_BYTE) {
/* nothing to do, no bits in buffer */
return 0;
} else {
return writeBits(stream, stream->capacity, 0);
}
}
#endif

View file

@ -1,52 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "EXITypes.h"
#ifndef BIT_OUTPUT_STREAM_H
#define BIT_OUTPUT_STREAM_H
int writeBits(bitstream_t* stream, uint16_t nbits, uint32_t bits);
/* flush output */
int flush(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,93 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "DecoderChannel.h"
#include "CoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef BYTE_DECODER_CHANNEL_C
#define BYTE_DECODER_CHANNEL_C
#if EXI_ALIGNMENT == BYTE_ALIGNMENT
int decode(bitstream_t* stream, uint8_t* b) {
int errn = 0;
#if EXI_STREAM == BYTE_ARRAY
if ( (*stream->pos) < stream->size ) {
*b = stream->data[(*stream->pos)++];
} else {
errn = EXI_ERROR_INPUT_STREAM_EOF;
}
#endif /* EXI_STREAM == BYTE_ARRAY */
#if EXI_STREAM == FILE_STREAM
*b = getc(stream->file);
/* EOF cannot be used, 0xFF valid value */
if ( feof(stream->file) || ferror(stream->file) ) {
return EXI_ERROR_INPUT_STREAM_EOF;
}
#endif /* EXI_STREAM == FILE_STREAM */
return errn;
}
int decodeBoolean(bitstream_t* stream, int* b) {
uint8_t bb;
int errn = decode(stream, &bb);
*b = (bb == 0) ? 0 : 1;
return errn;
}
/**
* Decodes and returns an n-bit unsigned integer using the minimum number of
* bytes required for n bits.
*/
int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32) {
uint16_t bitsRead = 0;
uint8_t b;
int errn = 0;
*uint32 = 0;
while (bitsRead < nbits) {
errn = decode(stream, &b);
if (errn != 0) {
return errn;
}
*uint32 += (b << bitsRead);
bitsRead += 8;
}
return errn;
}
#endif
#endif

View file

@ -1,125 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EncoderChannel.h"
#include "CoderChannel.h"
#include "BitOutputStream.h"
#include "EXITypes.h"
#include "MethodsBag.h"
#ifndef BYTE_ENCODER_CHANNEL_C
#define BYTE_ENCODER_CHANNEL_C
#if EXI_ALIGNMENT == BYTE_ALIGNMENT
int encode(bitstream_t* stream, uint8_t b) {
#if EXI_STREAM == BYTE_ARRAY
if ( (*stream->pos) < stream->size ) {
stream->data[(*stream->pos)++] = b;
return 0;
} else {
return EXI_ERROR_OUTPUT_STREAM_EOF;
}
#endif /* EXI_STREAM == BYTE_ARRAY */
#if EXI_STREAM == FILE_STREAM
if ( putc(b, stream->file) == EOF ) {
return EXI_ERROR_OUTPUT_STREAM_EOF;
} else {
return 0;
}
#endif /* EXI_STREAM == FILE_STREAM */
}
/**
* Encode a single boolean value. A false value is encoded as byte 0 and true
* value is encode as byte 1.
*/
int encodeBoolean(bitstream_t* stream, int b) {
uint8_t val = b ? 1 : 0;
return encode(stream, val);
}
/**
* Encode n-bit unsigned integer. The n least significant bits of parameter
* b starting with the most significant, i.e. from left to right.
*/
int encodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t val) {
if (nbits > 0) {
if (nbits < 9) {
/* 1 byte */
encode(stream, val & 0xff);
} else if (nbits < 17) {
/* 2 bytes */
encode(stream, val & 0x00ff);
encode(stream, (val & 0xff00) >> 8);
} else if (nbits < 25) {
/* 3 bytes */
encode(stream, val & 0x0000ff);
encode(stream, (val & 0x00ff00) >> 8);
encode(stream, (val & 0xff0000) >> 16);
} else if (nbits < 33) {
/* 4 bytes */
encode(stream, val & 0x000000ff);
encode(stream, (val & 0x0000ff00) >> 8);
encode(stream, (val & 0x00ff0000) >> 16);
encode(stream, (val & 0xff000000) >> 24);
} else {
/* TODO Currently not more than 4 Bytes allowed for NBitUnsignedInteger */
return EXI_UNSUPPORTED_NBIT_INTEGER_LENGTH;
}
}
return 0;
}
/**
* Flush underlying bit output stream.
*/
int encodeFinish(bitstream_t* stream) {
/* no pending bits in byte-aligned mode */
return 0;
}
#endif /* alignment */
#endif

View file

@ -1,79 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#define _CRT_SECURE_NO_DEPRECATE 1
#include "EXITypes.h"
#ifndef BYTE_STREAM_C
#define BYTE_STREAM_C
int readBytesFromFile(const char * filename, uint8_t* data, uint32_t size, uint32_t pos) {
FILE* f;
int character;
f = fopen(filename, "rb");
if (f == NULL) {
return EXI_ERROR_INPUT_FILE_HANDLE;
} else {
/* read bytes */
while ((character = getc(f)) != EOF) {
if (pos >= size) {
return EXI_ERROR_OUT_OF_BYTE_BUFFER;
}
data[pos++] = (uint8_t) character;
}
fclose(f);
}
return pos;
}
int writeBytesToFile(uint8_t* data, uint32_t len, const char * filename) {
uint16_t rlen;
FILE* f = fopen(filename, "wb+");
if (f == NULL) {
return -1;
} else {
rlen = fwrite(data, sizeof(uint8_t), len, f);
fflush(f);
fclose(f);
if(rlen == len) {
return 0;
} else {
return EXI_ERROR_OUTPUT_FILE;
}
}
}
#endif

View file

@ -1,48 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef BYTE_STREAM_H
#define BYTE_STREAM_H
int writeBytesToFile(uint8_t* data, uint32_t len, const char * filename);
int readBytesFromFile(const char * filename, uint8_t* data, uint32_t size, uint32_t pos);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,48 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef CODER_CHANNEL_H
#define CODER_CHANNEL_H
/* EXI alignment mode */
#define BIT_PACKED 1
#define BYTE_ALIGNMENT 2
#define EXI_ALIGNMENT BIT_PACKED
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,178 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#include "CoderChannel.h"
#ifndef DECODER_CHANNEL_H
#define DECODER_CHANNEL_H
/**
* Decode a byte value.
*/
int decode(bitstream_t* stream, uint8_t* b);
/**
* Decode a single boolean value. The value false is represented by the bit
* 0, and the value true is represented by the bit 1.
*/
int decodeBoolean(bitstream_t* stream, int* b);
/**
* Decodes and returns an n-bit unsigned integer.
*/
int decodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t* uint32);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger(bitstream_t* stream, integer_t* iv);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger32(bitstream_t* stream, uint32_t* uint32);
/**
* Decode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int decodeUnsignedInteger64(bitstream_t* stream, uint64_t* uint64);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger(bitstream_t* stream, integer_t* iv);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger32(bitstream_t* stream, int32_t* int32);
/**
* Decode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int decodeInteger64(bitstream_t* stream, int64_t* int64);
/**
* Decode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int decodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Decode a decimal represented as a Boolean sign followed by two Unsigned
* Integers. A sign value of zero (0) is used to represent positive Decimal
* values and a sign value of one (1) is used to represent negative Decimal
* values The first Integer represents the integral portion of the Decimal
* value. The second positive integer represents the fractional portion of
* the decimal with the digits in reverse order to preserve leading zeros.
*/
int decodeDecimal(bitstream_t* stream, decimal_t* d);
/**
* Decode a sequence of characters for a given length.
*/
int decodeStringOnly(bitstream_t* stream, uint16_t len, string_ucs_t* s);
/**
* Decode a length prefixed sequence of characters.
*/
int decodeString(bitstream_t* stream, string_ucs_t* s);
int decodeStringASCII(bitstream_t* stream, string_ascii_t* s);
/**
* Decode a length prefixed sequence of characters in the sense of string tables.
* length == 0, local value partition hit
* length == 1, global value partition hit
* --> string literal is encoded as a String with the length incremented by two
*/
int decodeStringValue(bitstream_t* stream, string_ucs_t* s);
/**
* Restricted character set
*/
int decodeRCSStringValue(bitstream_t* stream, rcs_t* rcs, string_ucs_t* s);
/**
* Decode a sequence of characters according to a given length.
*/
int decodeCharacters(bitstream_t* stream, uint16_t len, uint32_t* chars);
int decodeCharactersASCII(bitstream_t* stream, uint16_t len, char* chars);
/**
* Decode a binary value as a length-prefixed sequence of octets.
*/
int decodeBinary(bitstream_t* stream, bytes_t* bytes);
/**
* Decode Date-Time as sequence of values representing the individual
* components of the Date-Time.
*/
int decodeDateTime(bitstream_t* stream, exi_datetime_type_t type, datetime_t* datetime);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because one or more lines are too long

View file

@ -1,65 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_CODER_H
#define EXI_CODER_H
#include "EXITypes.h"
#define IS_STRICT 0
#define DOCUMENT 0
#define DOC_CONTENT 1
#define DOC_END 2
#define UR_TYPE_GRAMMAR_0 73
#define UR_TYPE_GRAMMAR_1 602
int exiPushStack(exi_state_t* state, uint16_t newState, eqname_t* eqn);
int exiPopStack(exi_state_t* state);
int exiHandleXsiNilTrue(exi_state_t* state);
int exiHandleXsiType(exi_state_t* state, eqname_t* xsiType);
int exiIsStartContent(int16_t ruleID);
int exiMoveToElementContentRule(exi_state_t* state);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because one or more lines are too long

View file

@ -1,90 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI__DECODER_H
#define EXI__DECODER_H
#include "EXITypes.h"
int exiInitDecoder(bitstream_t* stream, exi_state_t* state,
exi_name_table_runtime_t runtimeTable);
int exiDecodeNextEvent(bitstream_t* stream,
exi_state_t* state, exi_event_t* nextEvent);
int exiDecodeStartDocument(bitstream_t* stream,
exi_state_t* state);
int exiDecodeEndDocument(bitstream_t* stream,
exi_state_t* state);
int
exiDecodeStartElement(bitstream_t* stream,
exi_state_t* state, eqname_t* se);
int exiDecodeStartElementGeneric(bitstream_t* stream,
exi_state_t* state, qname_t* qname);
int exiDecodeEndElement(bitstream_t* stream,
exi_state_t* state, eqname_t* ee);
int exiDecodeEndElementUndeclared(bitstream_t* stream,
exi_state_t* state, eqname_t* ee);
int exiDecodeCharacters(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiDecodeCharactersGeneric(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiDecodeCharactersGenericUndeclared(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiDecodeAttribute(bitstream_t* stream,
exi_state_t* state, eqname_t* at, exi_value_t* val);
int exiDecodeAttributeXsiNil(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiDecodeAttributeXsiType(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiDecodeAttributeGenericUndeclared(bitstream_t* stream,
exi_state_t* state, qname_t* at, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because one or more lines are too long

View file

@ -1,76 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI__ENCODER_H
#define EXI__ENCODER_H
#include "EXITypes.h"
int exiInitEncoder(bitstream_t* stream, exi_state_t* state,
exi_name_table_runtime_t runtimeTable);
int exiEncodeStartDocument(bitstream_t* stream,
exi_state_t* state);
int exiEncodeEndDocument(bitstream_t* stream,
exi_state_t* state);
int
exiEncodeStartElement(bitstream_t* stream,
exi_state_t* state, eqname_t* se);
int exiEncodeStartElementGeneric(bitstream_t* stream,
exi_state_t* state, string_ascii_t* namespaceURI,
string_ascii_t* localName);
int exiEncodeEndElement(bitstream_t* stream,
exi_state_t* state);
int exiEncodeCharacters(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiEncodeAttribute(bitstream_t* stream,
exi_state_t* state, eqname_t* at, exi_value_t* val);
int exiEncodeAttributeXsiNil(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiEncodeAttributeXsiType(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,59 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EXIHeaderDecoder.h"
#include "BitInputStream.h"
#include "DecoderChannel.h"
#ifndef EXI_HEADER_DECODER_C
#define EXI_HEADER_DECODER_C
int readEXIHeader(bitstream_t* stream) {
uint32_t header = 0;
int errn = readBits(stream, 8, &header);
if (errn < 0) {
return errn;
}
if(header == '$') {
/* we do not support "EXI Cookie" */
errn = EXI_UNSUPPORTED_HEADER_COOKIE;
} else if ( header & 0x20 ) {
/* we do not support "Presence Bit for EXI Options" */
errn = EXI_UNSUPPORTED_HEADER_OPTIONS;
} else {
/* Yes, a *simple* header */
errn = 0;
}
return errn;
}
#endif

View file

@ -1,46 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef EXI_HEADER_DECODER_H
#define EXI_HEADER_DECODER_H
int readEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,44 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include "EXIHeaderEncoder.h"
#include "BitOutputStream.h"
#include "EncoderChannel.h"
#ifndef EXI_HEADER_ENCODER_C
#define EXI_HEADER_ENCODER_C
int writeEXIHeader(bitstream_t* stream) {
return writeBits(stream, 8, 128);
}
#endif

View file

@ -1,46 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef EXI_HEADER_ENCODER_H
#define EXI_HEADER_ENCODER_H
int writeEXIHeader(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,433 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdio.h>
#ifndef EXI_TYPES_H
#define EXI_TYPES_H
#define BITS_IN_BYTE 8
#define DATETIME_YEAR_OFFSET 2000
#define DATETIME_NUMBER_BITS_MONTHDAY 9
#define DATETIME_NUMBER_BITS_TIME 17
#define DATETIME_NUMBER_BITS_TIMEZONE 11
#define DATETIME_MONTH_MULTIPLICATOR 32
#define DATETIME_TIMEZONE_OFFSET_IN_MINUTES 896
#define UINT_MAX_VALUE 65535
/* EXI Debug mode */
/* Increases code footprint but offers addition functionalities, e.g. string retrieving */
#define EXI_DEBUG_ON 1
#define EXI_DEBUG_OFF 2
#define EXI_DEBUG EXI_DEBUG_OFF
/* EXI stream */
#define BYTE_ARRAY 1
#define FILE_STREAM 2
#define EXI_STREAM BYTE_ARRAY
/* #define EXI_STREAM FILE_STREAM */
#define EXI_ELEMENT_STACK_SIZE 16
#define FLOAT_EXPONENT_SPECIAL_VALUES -16384
#define FLOAT_MANTISSA_INFINITY 1
#define FLOAT_MANTISSA_MINUS_INFINITY -1
#define FLOAT_MANTISSA_NOT_A_NUMBER 0
typedef struct {
#if EXI_STREAM == BYTE_ARRAY
/* Byte Array */
uint32_t size; /* array size */
uint8_t* data; /* int data array */
uint32_t* pos; /* next position in array */
#endif
#if EXI_STREAM == FILE_STREAM
/* FILE */
FILE *file;
#endif
/* Current byte buffer & its remaining bit capacity */
uint8_t buffer;
uint8_t capacity;
} bitstream_t;
typedef enum {
/* Binary */
BINARY_BASE64,
BINARY_HEX,
/* Boolean */
BOOLEAN,
BOOLEAN_FACET,
/* Decimal */
DECIMAL,
/* Float & Double */
FLOAT,
/* N-Bit Unsigned Integer */
NBIT_UNSIGNED_INTEGER,
/* Unsigned Integer */
UNSIGNED_INTEGER,
/* (Signed) Integer */
INTEGER,
/* Datetime */
DATETIME,
/* String */
STRING,
/* Restricted Character Set String */
RCS_STRING,
/* Enumeration */
ENUMERATION,
/* List */
LIST
} exi_datatype_t;
typedef enum {
/* Unsigned Integer */
UNSIGNED_INTEGER_8,
UNSIGNED_INTEGER_16,
UNSIGNED_INTEGER_32,
UNSIGNED_INTEGER_64,
/* (Signed) Integer */
INTEGER_8,
INTEGER_16,
INTEGER_32,
INTEGER_64
} exi_integer_type_t;
typedef enum {
START_DOCUMENT,
END_DOCUMENT,
START_ELEMENT,
START_ELEMENT_GENERIC,
START_ELEMENT_GENERIC_UNDECLARED,
END_ELEMENT,
END_ELEMENT_UNDECLARED,
CHARACTERS,
CHARACTERS_GENERIC,
CHARACTERS_GENERIC_UNDECLARED,
ATTRIBUTE_XSI_TYPE,
ATTRIBUTE_XSI_NIL,
ATTRIBUTE,
ATTRIBUTE_GENERIC,
ATTRIBUTE_INVALID_VALUE,
ATTRIBUTE_ANY_INVALID_VALUE,
ATTRIBUTE_GENERIC_UNDECLARED,
/* error state */
ERROR
} exi_event_t;
/* differ datetime types */
typedef enum {
exiGYear, exiGYearMonth, exiDate, exiDateTime, exiGMonth, exiGMonthDay, exiGDay, exiTime
} exi_datetime_type_t;
typedef struct {
/* Bytes Size and array container */
uint16_t size;
uint8_t* data;
/* current length (len <= size) */
uint16_t len;
} bytes_t;
/* Universal Character Set (UCS) strings */
typedef struct {
/* UCS size and UCS character container*/
uint16_t size;
uint32_t* codepoints;
/* current length == number of code-points, (len <= size) */
uint16_t len;
} string_ucs_t;
/* Restricted Characeter Set */
typedef struct {
/* size and UCS character codep*/
uint16_t size;
/* rcs codepoints */
uint32_t* codepoints;
/* character coding length*/
uint8_t codingLength; /* less than 256 characters */
} rcs_t;
/* ASCII strings */
typedef struct {
/* size of String array */
uint16_t size;
char* chars;
/* current length can be retrieved by calling strlen(chars)*/
} string_ascii_t;
typedef struct {
exi_integer_type_t type;
union {
/* unsigned values */
int8_t int8;
int16_t int16;
int32_t int32;
int32_t int64;
/* (signed) values */
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;
} val;
} integer_t;
typedef struct {
/* range of the mantissa is -(2^63) to 2^63-1 */
int64_t mantissa;
/* range of the exponent is - (2^14-1) to 2^14-1 */
int32_t exponent; /* base-10 */
} float_me_t;
typedef struct {
/* a sign value */
int negative;
/* represents the integral portion of the Decimal */
integer_t integral;
/* represents the fractional portion of the Decimal with the digits in reverse order to preserve leading zeros */
integer_t reverseFraction;
} decimal_t;
typedef struct {
/* datetime type */
exi_datetime_type_t type;
/* values */
int32_t year;
uint32_t monthDay;
uint32_t time;
int presenceFractionalSecs;
uint32_t fractionalSecs;
int presenceTimezone;
uint32_t timezone;
} datetime_t;
/* TODO list support */
typedef struct {
/* list item type */
exi_datatype_t type;
/* number of items */
uint16_t len;
/* List container with memory size */
uint16_t size;
uint8_t* data;
} list_t;
/* efficient ID qname */
typedef struct {
uint16_t namespaceURI;
uint16_t localPart;
} eqname_t;
/* ascii qname */
typedef struct {
string_ascii_t namespaceURI;
string_ascii_t localName;
} qname_t;
/* ==================================== */
/* LocalName Entries */
struct exiNamePartition {
/* length of array */
uint16_t len;
#if EXI_DEBUG == EXI_DEBUG_ON
/* array of string entries */
char** names;
#endif /*EXI_DEBUG*/
};
typedef struct exiNameTablePrepopulated {
/* length of both arrays (uris & localNames) */
uint16_t len;
#if EXI_DEBUG == EXI_DEBUG_ON
/* URI entries*/
char** uris;
#endif /*EXI_DEBUG*/
/* localName entries divided by URI */
struct exiNamePartition * localNames;
} exi_name_table_prepopulated_t;
#define EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_CHARACTERS 500
#define EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES 25
#define EXI_RESERVED_NUMBER_URI_PARTITION_ENTRIES 5
#define EXI_RESERVED_NUMBER_LOCALNAME_PARTITION_ENTRIES 10
typedef enum {
URI_PARTITION,
LOCALNAME_PARTITION
} exi_name_partition_type_t;
typedef struct {
char* uri;
uint16_t uriID;
} exi_uri_partition_t;
typedef struct {
char* localName;
uint16_t localNameID;
uint16_t uriID;
} exi_localname_partition_t;
typedef struct {
exi_name_partition_type_t namePartitionType;
struct
{
exi_uri_partition_t uriPartition;
exi_localname_partition_t localNamePartition;
} entry;
} exi_name_partition_t;
typedef struct exiNameTableRuntime {
/* maximum number of characters in the name partitions entries PLUS null terminators */
char characters[EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_CHARACTERS + EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES];
uint16_t numberOfUsedCharacters; /* initially zero <= EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_CHARACTERS */
/* maximum number of name partitions entries. Name partitions entries consist in all uri, and local-name partition entries */
exi_name_partition_t namePartitionsEntries[EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES];
/* uint16_t numberOfUsedNamePartitions; */ /* initially zero */
/* added entries */
uint16_t addedUriEntries; /* initially zero */
uint16_t addedLocalNameEntries; /* initially zero */
} exi_name_table_runtime_t;
typedef struct {
/* stack of grammar states */
int16_t grammarStack[EXI_ELEMENT_STACK_SIZE];
/* stack of grammar elements */
eqname_t elementStack[EXI_ELEMENT_STACK_SIZE];
uint16_t stackIndex;
/* event-code */
uint32_t eventCode;
/* string table entries */
exi_name_table_prepopulated_t nameTablePrepopulated;
exi_name_table_runtime_t nameTableRuntime;
} exi_state_t;
typedef struct {
/* type of value */
exi_datatype_t type;
/* base types */
int boolean;
integer_t integer;
/*uint16_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;
int8_t int8;
int16_t int16;
int32_t int32;
int64_t int64;*/
uint32_t enumeration;
/* Bytes, Strings and Lists are not native types anymore */
bytes_t binary;
string_ucs_t string;
float_me_t float_me;
decimal_t decimal;
datetime_t datetime;
list_t list;
eqname_t eqname;
} exi_value_t;
/*
* ERROR-Codes
*/
#define EXI_ERROR_INPUT_STREAM_EOF -10
#define EXI_ERROR_OUTPUT_STREAM_EOF -11
#define EXI_ERROR_INPUT_FILE_HANDLE -12
#define EXI_ERROR_OUTPUT_FILE -13
#define EXI_ERROR_OUT_OF_BOUNDS -100
#define EXI_ERROR_OUT_OF_STRING_BUFFER -101
#define EXI_ERROR_OUT_OF_ASCII_BUFFER -102
#define EXI_ERROR_OUT_OF_BYTE_BUFFER -103
#define EXI_ERROR_OUT_OF_GRAMMAR_STACK -104
#define EXI_ERROR_UNKOWN_EVENT -109
#define EXI_ERROR_UNKOWN_EVENT_CODE -110
#define EXI_ERROR_UNEXPECTED_EVENT_LEVEL1 -111
#define EXI_ERROR_UNEXPECTED_EVENT_LEVEL2 -112
#define EXI_ERROR_UNEXPECTED_START_DOCUMENT -113
#define EXI_ERROR_UNEXPECTED_END_DOCUMENT -114
#define EXI_ERROR_UNEXPECTED_START_ELEMENT -115
#define EXI_ERROR_UNEXPECTED_START_ELEMENT_GENERIC -116
#define EXI_ERROR_UNEXPECTED_END_ELEMENT -117
#define EXI_ERROR_UNEXPECTED_CHARACTERS -118
#define EXI_ERROR_UNEXPECTED_ATTRIBUTE -119
#define EXI_ERROR_UNEXPECTED_ATTRIBUTE_XSI_TYPE -120
#define EXI_ERROR_UNEXPECTED_ATTRIBUTE_XSI_NIL -121
#define EXI_ERROR_UNEXPECTED_GRAMMAR_ID -122
#define EXI_ERROR_UNEXPECTED_ATTRIBUTE_MOVE_TO_CONTENT_RULE -123
#define EXI_UNSUPPORTED_STRING_TABLE_LOCAL_HIT -130
#define EXI_UNSUPPORTED_STRING_TABLE_GLOBAL_HIT -131
#define EXI_UNSUPPORTED_NBIT_INTEGER_LENGTH -132
#define EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS -133
#define EXI_UNSUPPORTED_INTEGER_VALUE_TYPE -134
#define EXI_UNSUPPORTED_INTEGER_VALUE -135
#define EXI_NEGATIVE_UNSIGNED_INTEGER_VALUE -136
#define EXI_UNSUPPORTED_LIST_VALUE_TYPE -137
#define EXI_UNSUPPORTED_HEADER_COOKIE -138
#define EXI_UNSUPPORTED_HEADER_OPTIONS -139
#define EXI_ERROR_UNEXPECTED_BYTE_VALUE -200
#define EXI_ERROR_UNEXPECTED_DATETIME_TYPE -201
#define EXI_ERROR_CONVERSION_NO_ASCII_CHARACTERS -300
#define EXI_ERROR_CONVERSION_TYPE_TO_STRING -301
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,180 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
#ifndef ENCODER_CHANNEL_H
#define ENCODER_CHANNEL_H
/**
* Encode a byte value.
*/
int encode(bitstream_t* stream, uint8_t b);
/**
* Encode a single boolean value. A false value is encoded as 0 and true
* value is encode as 1.
*/
int encodeBoolean(bitstream_t* stream, int b);
/**
* Encode n-bit unsigned integer. The n least significant bits of parameter
* b starting with the most significant, i.e. from left to right.
*/
int encodeNBitUnsignedInteger(bitstream_t* stream, uint16_t nbits, uint32_t val);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger(bitstream_t* stream, integer_t* iv);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger32(bitstream_t* stream, uint32_t n);
/**
* Encode an arbitrary precision non negative integer using a sequence of
* octets. The most significant bit of the last octet is set to zero to
* indicate sequence termination. Only seven bits per octet are used to
* store the integer's value.
*/
int encodeUnsignedInteger64(bitstream_t* stream, uint64_t n);
/**
* Encode an arbitrary precision integer using a sign boolean followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger(bitstream_t* stream, integer_t* iv);
/**
* Encode an arbitrary precision integer using a sign boolean followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger32(bitstream_t* stream, int32_t n);
/**
* Encode an arbitrary precision integer using a sign bit followed by a
* sequence of octets. The most significant bit of the last octet is set to
* zero to indicate sequence termination. Only seven bits per octet are used
* to store the integer's value.
*/
int encodeInteger64(bitstream_t* stream, int64_t n);
/**
* Encode a Float datatype as two consecutive Integers.
* The first Integer represents the mantissa of the floating point
* number and the second Integer represents the base-10 exponent
* of the floating point number.
*/
int encodeFloat(bitstream_t* stream, float_me_t* f);
/**
* Encode a decimal represented as a Boolean sign followed by two Unsigned
* Integers. A sign value of zero (0) is used to represent positive Decimal
* values and a sign value of one (1) is used to represent negative Decimal
* values The first Integer represents the integral portion of the Decimal
* value. The second positive integer represents the fractional portion of
* the decimal with the digits in reverse order to preserve leading zeros.
*/
int encodeDecimal(bitstream_t* stream, decimal_t* d);
/**
* Encode a length prefixed sequence of characters.
*/
int encodeString(bitstream_t* stream, string_ucs_t* string);
int encodeASCII(bitstream_t* stream, const char* ascii);
/**
* Encode a length prefixed sequence of characters in the sense of string tables
*/
int encodeStringValue(bitstream_t* stream, string_ucs_t* string);
/**
* Restricted character set
*/
int encodeRCSStringValue(bitstream_t* stream, rcs_t* rcs, string_ucs_t* string);
/**
* Encode a sequence of characters according to a given length.
* Each character is represented by its UCS [ISO/IEC 10646]
* code point encoded as an Unsigned Integer
*/
int encodeUCSCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len);
int encodeASCIICharacters(bitstream_t* stream, const char* chars, uint16_t len);
/**
* Encode a binary value as a length-prefixed sequence of octets.
*/
int encodeBinary(bitstream_t* stream, bytes_t* bytes);
/**
* Encode a datetime representation which is a sequence of values
* representing the individual components of the Date-Time
*/
int encodeDateTime(bitstream_t* stream, datetime_t* datetime);
/**
* Flush underlying bit output stream
*/
int encodeFinish(bitstream_t* stream);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,106 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef METHODS_BAG_C
#define METHODS_BAG_C
#include "MethodsBag.h"
#include "EXITypes.h"
static const int smallLengths[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4,
4, 4, 4 };
int exiGetCodingLength(uint32_t characteristics, uint16_t* codingLength) {
if (characteristics < 17) {
*codingLength = smallLengths[characteristics];
return 0;
} else if (characteristics < 33) {
/* 17 .. 32 */
*codingLength = 5;
return 0;
} else if (characteristics < 65) {
/* 33 .. 64 */
*codingLength = 6;
return 0;
} else if (characteristics < 129) {
/* 65 .. 128 */
*codingLength = 7;
return 0;
} else if (characteristics < 257) {
/* 129 .. 256 */
*codingLength = 8;
return 0;
} else if (characteristics < 513) {
/* 257 .. 512 */
*codingLength = 9;
return 0;
} else if (characteristics < 1025) {
/* 513 .. 1024 */
*codingLength = 10;
return 0;
} else {
/*
return (int) Math.ceil(Math.log((double) (characteristics))
/ Math.log(2.0)); */
return EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
}
}
uint8_t numberOf7BitBlocksToRepresent(uint32_t n) {
/* assert (n >= 0); */
/* 7 bits */
if (n < 128) {
return 1;
}
/* 14 bits */
else if (n < 16384) {
return 2;
}
/* 21 bits */
else if (n < 2097152) {
return 3;
}
/* 28 bits */
else if (n < 268435456) {
return 4;
}
/* 35 bits */
else {
/* int, 32 bits */
return 5;
}
}
#endif

View file

@ -1,59 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef METHODS_BAG_H
#define METHODS_BAG_H
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
/**
* Returns the number of bits to identify the characteristics.
*
* @param characteristics
* @param codingLength (return value)
*
*/
int exiGetCodingLength(uint32_t characteristics, uint16_t* codingLength);
/**
* Returns the least number of 7 bit-blocks that is needed to represent the
* int <param>n</param>. Returns 1 if <param>n</param> is 0.
*
* @param n
* integer value
*
*/
uint8_t numberOf7BitBlocksToRepresent(uint32_t n);
#endif

View file

@ -1,63 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef EXI__NAME_TABLE_ENTRIES_C
#define EXI__NAME_TABLE_ENTRIES_C
#include "NameTableEntries.h"
/* ==================================== */
/* String Table Population */
#if EXI_DEBUG == EXI_DEBUG_OFF
static struct exiNamePartition localNamePartitions[9] = {
{ 9 },
{ 4 },
{ 2 },
{ 46 },
{ 70 },
{ 118 },
{ 186 },
{ 6 },
{ 3 }
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF
exi_name_table_prepopulated_t exiNameTablePrepopulated = { 9, localNamePartitions };
#endif /*EXI_DEBUG*/
#endif

View file

@ -1,41 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef EXI__NAME_TABLE_ENTRIES_H
#define EXI__NAME_TABLE_ENTRIES_H
#include "EXITypes.h"
/* ==================================== */
/* String Table Population */
extern exi_name_table_prepopulated_t exiNameTablePrepopulated;
#endif

View file

@ -1,131 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef STRING_TABLE_C
#define STRING_TABLE_C
#include <string.h>
#include "StringTable.h"
#include "NameTableEntries.h"
int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength) {
*uriLength = prepopulatedTable->len;
return 0;
}
int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable,
uint16_t uriID, uint16_t* localNameLength) {
*localNameLength = 0;
/* 1. pre-populated entries*/
if (uriID < prepopulatedTable->len) {
(*localNameLength) += prepopulatedTable->localNames[uriID].len;
} else {
/* range check */
if (uriID >= ( prepopulatedTable->len + runtimeTable->addedUriEntries )) {
return EXI_ERROR_OUT_OF_BOUNDS;
}
}
/* 2. runtime entries */
if (runtimeTable->addedLocalNameEntries > 0 ) {
int i;
for(i=0; i<(runtimeTable->addedUriEntries+runtimeTable->addedLocalNameEntries); i++) {
if ( runtimeTable->namePartitionsEntries[i].namePartitionType == LOCALNAME_PARTITION &&
runtimeTable->namePartitionsEntries[i].entry.localNamePartition.uriID == uriID ) {
(*localNameLength)++;
}
}
}
return 0;
}
/* inline */
static int _max(int a, int b) {
return (a > b) ? a : b;
}
int exiInitNameTableRuntime(exi_name_table_runtime_t* runtimeTable) {
runtimeTable->numberOfUsedCharacters = 0;
runtimeTable->addedLocalNameEntries = 0;
runtimeTable->addedUriEntries = 0;
return 0;
}
int exiAddUri(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, char* uri) {
if (runtimeTable->addedUriEntries < EXI_RESERVED_NUMBER_URI_PARTITION_ENTRIES
|| runtimeTable->addedUriEntries
< (EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES - _max(
runtimeTable->addedLocalNameEntries,
EXI_RESERVED_NUMBER_LOCALNAME_PARTITION_ENTRIES))) {
uint16_t index = runtimeTable->addedUriEntries + runtimeTable->addedLocalNameEntries;
int charsIndex = runtimeTable->numberOfUsedCharacters+runtimeTable->addedUriEntries+runtimeTable->addedLocalNameEntries;
runtimeTable->namePartitionsEntries[index].namePartitionType = URI_PARTITION;
strcpy(runtimeTable->characters+charsIndex, uri);
runtimeTable->namePartitionsEntries[index].entry.uriPartition.uri = runtimeTable->characters+charsIndex;
runtimeTable->namePartitionsEntries[index].entry.uriPartition.uriID = prepopulatedTable->len + runtimeTable->addedUriEntries;
runtimeTable->addedUriEntries++;
runtimeTable->numberOfUsedCharacters += strlen(uri);
return 0;
} else {
return -1;
}
}
int exiAddLocalName(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID,
char* localName) {
if (runtimeTable->addedUriEntries < EXI_RESERVED_NUMBER_LOCALNAME_PARTITION_ENTRIES
|| runtimeTable->addedLocalNameEntries
< (EXI_MAXIMUM_NUMBER_OF_NAME_PARTITION_ENTRIES - _max(
runtimeTable->addedUriEntries,
EXI_RESERVED_NUMBER_URI_PARTITION_ENTRIES))) {
uint16_t index = runtimeTable->addedUriEntries + runtimeTable->addedLocalNameEntries;
int charsIndex = runtimeTable->numberOfUsedCharacters+runtimeTable->addedUriEntries+runtimeTable->addedLocalNameEntries;
uint16_t localNameID;
int errn = exiGetLocalNameSize(prepopulatedTable, runtimeTable, uriID, &localNameID);
if (errn < 0) {
return errn;
}
runtimeTable->namePartitionsEntries[index].namePartitionType = LOCALNAME_PARTITION;
strcpy(runtimeTable->characters+charsIndex, localName);
runtimeTable->namePartitionsEntries[index].entry.localNamePartition.localName = runtimeTable->characters+charsIndex;
runtimeTable->namePartitionsEntries[index].entry.localNamePartition.localNameID = localNameID;
runtimeTable->namePartitionsEntries[index].entry.localNamePartition.uriID = uriID;
runtimeTable->addedLocalNameEntries++;
runtimeTable->numberOfUsedCharacters += strlen(localName);
return 0;
} else {
return -1;
}
}
#endif

View file

@ -1,58 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef STRING_TABLE_H
#define STRING_TABLE_H
#include "EXITypes.h"
int exiGetUriSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t* uriLength);
int exiGetLocalNameSize(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, uint16_t* localNameLength);
/* inits counter et cetera */
int exiInitNameTableRuntime(exi_name_table_runtime_t* runtimeTable);
/* add runtime URI entry */
int exiAddUri(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, char* uri);
/* add runtime local-name entry */
int exiAddLocalName(exi_name_table_prepopulated_t* prepopulatedTable, exi_name_table_runtime_t* runtimeTable, uint16_t uriID, char* localName);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,66 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#include <string.h>
#include "DecoderChannel.h"
#include "BitInputStream.h"
#include "EXITypes.h"
#ifndef UCS_STRING_C
#define UCS_STRING_C
int toUCSString(char* chars, string_ucs_t* s) {
unsigned int i;
s->len = strlen(chars);
if (s->len <= s->size) {
for(i=0; i<s->len; i++) {
s->codepoints[i] = chars[i];
}
return 0;
} else {
return EXI_ERROR_OUT_OF_STRING_BUFFER;
}
}
/* Note A: fails if string contains non ASCII characters */
/* Note B: causes harm if char array is not sufficiently long */
int toASCIIString(string_ucs_t* string, char* outASCII) {
unsigned int i;
for(i=0; i<string->len; i++) {
outASCII[i] = (char)string->codepoints[i];
}
outASCII[string->len] = '\0';
return 0;
}
#endif

View file

@ -1,52 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include "EXITypes.h"
/* TODO utf8/cstring//wchar_t/char16_t/char32_t methods */
#ifndef UCS_STRING_H
#define UCS_STRING_H
int toUCSString(char* chars, string_ucs_t* s);
/* Note: fails if string contains non ASCII characters */
int toASCIIString(string_ucs_t* string, char* outASCII);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,90 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_appHand_DECODER_H
#define EXI_appHand_DECODER_H
#include "EXITypes.h"
int exiappHandInitDecoder(bitstream_t* stream, exi_state_t* state,
exi_name_table_runtime_t runtimeTable);
int exiappHandDecodeNextEvent(bitstream_t* stream,
exi_state_t* state, exi_event_t* nextEvent);
int exiappHandDecodeStartDocument(bitstream_t* stream,
exi_state_t* state);
int exiappHandDecodeEndDocument(bitstream_t* stream,
exi_state_t* state);
int
exiappHandDecodeStartElement(bitstream_t* stream,
exi_state_t* state, eqname_t* se);
int exiappHandDecodeStartElementGeneric(bitstream_t* stream,
exi_state_t* state, qname_t* qname);
int exiappHandDecodeEndElement(bitstream_t* stream,
exi_state_t* state, eqname_t* ee);
int exiappHandDecodeEndElementUndeclared(bitstream_t* stream,
exi_state_t* state, eqname_t* ee);
int exiappHandDecodeCharacters(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandDecodeCharactersGeneric(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandDecodeCharactersGenericUndeclared(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandDecodeAttribute(bitstream_t* stream,
exi_state_t* state, eqname_t* at, exi_value_t* val);
int exiappHandDecodeAttributeXsiNil(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandDecodeAttributeXsiType(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandDecodeAttributeGenericUndeclared(bitstream_t* stream,
exi_state_t* state, qname_t* at, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,76 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_appHand_ENCODER_H
#define EXI_appHand_ENCODER_H
#include "EXITypes.h"
int exiappHandInitEncoder(bitstream_t* stream, exi_state_t* state,
exi_name_table_runtime_t runtimeTable);
int exiappHandEncodeStartDocument(bitstream_t* stream,
exi_state_t* state);
int exiappHandEncodeEndDocument(bitstream_t* stream,
exi_state_t* state);
int
exiappHandEncodeStartElement(bitstream_t* stream,
exi_state_t* state, eqname_t* se);
int exiappHandEncodeStartElementGeneric(bitstream_t* stream,
exi_state_t* state, string_ascii_t* namespaceURI,
string_ascii_t* localName);
int exiappHandEncodeEndElement(bitstream_t* stream,
exi_state_t* state);
int exiappHandEncodeCharacters(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandEncodeAttribute(bitstream_t* stream,
exi_state_t* state, eqname_t* at, exi_value_t* val);
int exiappHandEncodeAttributeXsiNil(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
int exiappHandEncodeAttributeXsiType(bitstream_t* stream,
exi_state_t* state, exi_value_t* val);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,58 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef EXI_appHand_NAME_TABLE_ENTRIES_C
#define EXI_appHand_NAME_TABLE_ENTRIES_C
#include "appHand_NameTableEntries.h"
/* ==================================== */
/* String Table Population */
#if EXI_DEBUG == EXI_DEBUG_OFF
struct exiNamePartition localNamePartitions[5] = {
{ 7 },
{ 4 },
{ 2 },
{ 46 },
{ 8 }
};
#endif /*EXI_DEBUG*/
#if EXI_DEBUG == EXI_DEBUG_OFF
exi_name_table_prepopulated_t exiappHandNameTablePrepopulated = { 5, localNamePartitions };
#endif /*EXI_DEBUG*/
#endif

View file

@ -1,41 +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 2012-01-31
* @contact Joerg.Heuer@siemens.com
*
* <p>Code generated by EXIdizer</p>
********************************************************************/
#ifndef EXI_appHand_NAME_TABLE_ENTRIES_H
#define EXI_appHand_NAME_TABLE_ENTRIES_H
#include "EXITypes.h"
/* ==================================== */
/* String Table Population */
extern exi_name_table_prepopulated_t exiappHandNameTablePrepopulated;
#endif

View file

@ -1,81 +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
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EXI_SERVICE_H_
#define EXI_SERVICE_H_
#include "v2g_serviceDataTypes.h"
#include "EXITypes.h"
struct uniqueIDPath
{
int id[10];
size_t pos;
};
struct EXIService
{
/* in-/ out-stream */
bitstream_t inStream;
bitstream_t outStream;
/* EXI */
exi_state_t stateDecode;
exi_state_t stateEncode;
exi_event_t event;
eqname_t eqn;
exi_value_t val;
/* v2g message data structure */
struct EXIDocumentType exiMsg;
/* unique id for ambiguous elements */
struct uniqueIDPath idPath;
/* error code */
uint8_t errorCode;
/* offset for transported header data */
uint16_t transportHeaderOffset;
};
/* define error codes (TODO: define precise error codes) */
#define EXI_NON_VALID_MESSAGE 0x01
#define EXI_SERIALIZATION_FAILED 0x02
#define EXI_DESERIALIZATION_FAILED 0x03
#define EXI_UNKNOWN_ERROR 0xFF
#endif /* EXI_SERVICE_H_ */
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,267 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICECLIENTSTUBS_H
#define SERVICECLIENTSTUBS_H
#include "v2g_service.h"
#include "v2g_serviceDataTypes.h"
#include "v2g_serviceClientStubs.h"
/**
* \brief Prepares the remote sessionSetup method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct SessionSetupReqType* Request data for the server (has to be set up before)
* \param result struct SessionSetupResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_sessionSetup(struct EXIService* service, struct MessageHeaderType* header, struct SessionSetupReqType* params, struct SessionSetupResType* result);
/**
* \brief Prepares the remote serviceDiscovery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct ServiceDiscoveryReqType* Request data for the server (has to be set up before)
* \param result struct ServiceDiscoveryResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_serviceDiscovery(struct EXIService* service, struct MessageHeaderType* header, struct ServiceDiscoveryReqType* params, struct ServiceDiscoveryResType* result);
/**
* \brief Prepares the remote serviceDetail method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct ServiceDetailReqType* Request data for the server (has to be set up before)
* \param result struct ServiceDetailResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_serviceDetail(struct EXIService* service, struct MessageHeaderType* header, struct ServiceDetailReqType* params, struct ServiceDetailResType* result);
/**
* \brief Prepares the remote servicePaymentSelection method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct ServicePaymentSelectionReqType* Request data for the server (has to be set up before)
* \param result struct ServicePaymentSelectionResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_servicePaymentSelection(struct EXIService* service, struct MessageHeaderType* header, struct ServicePaymentSelectionReqType* params, struct ServicePaymentSelectionResType* result);
/**
* \brief Prepares the remote paymentDetails method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct PaymentDetailsReqType* Request data for the server (has to be set up before)
* \param result struct PaymentDetailsResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_paymentDetails(struct EXIService* service, struct MessageHeaderType* header, struct PaymentDetailsReqType* params, struct PaymentDetailsResType* result);
/**
* \brief Prepares the remote contractAuthentication method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct ContractAuthenticationReqType* Request data for the server (has to be set up before)
* \param result struct ContractAuthenticationResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_contractAuthentication(struct EXIService* service, struct MessageHeaderType* header, struct ContractAuthenticationReqType* params, struct ContractAuthenticationResType* result);
/**
* \brief Prepares the remote chargeParameterDiscovery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct ChargeParameterDiscoveryReqType* Request data for the server (has to be set up before)
* \param result struct ChargeParameterDiscoveryResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_chargeParameterDiscovery(struct EXIService* service, struct MessageHeaderType* header, struct ChargeParameterDiscoveryReqType* params, struct ChargeParameterDiscoveryResType* result);
/**
* \brief Prepares the remote powerDelivery method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct PowerDeliveryReqType* Request data for the server (has to be set up before)
* \param result struct PowerDeliveryResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_powerDelivery(struct EXIService* service, struct MessageHeaderType* header, struct PowerDeliveryReqType* params, struct PowerDeliveryResType* result);
/**
* \brief Prepares the remote chargingStatus method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param result struct ChargingStatusResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_chargingStatus(struct EXIService* service, struct MessageHeaderType* header, struct ChargingStatusResType* result);
/**
* \brief Prepares the remote meteringReceipt method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct MeteringReceiptReqType* Request data for the server (has to be set up before)
* \param result struct MeteringReceiptResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_meteringReceipt(struct EXIService* service, struct MessageHeaderType* header, struct MeteringReceiptReqType* params, struct MeteringReceiptResType* result);
/**
* \brief Prepares the remote certificateUpdate method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct CertificateUpdateReqType* Request data for the server (has to be set up before)
* \param result struct CertificateUpdateResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_certificateUpdate(struct EXIService* service, struct MessageHeaderType* header, struct CertificateUpdateReqType* params, struct CertificateUpdateResType* result);
/**
* \brief Prepares the remote certificateInstallation method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct CertificateInstallationReqType* Request data for the server (has to be set up before)
* \param result struct CertificateInstallationResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_certificateInstallation(struct EXIService* service, struct MessageHeaderType* header, struct CertificateInstallationReqType* params, struct CertificateInstallationResType* result);
/**
* \brief Prepares the remote cableCheck method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct CableCheckReqType* Request data for the server (has to be set up before)
* \param result struct CableCheckResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_cableCheck(struct EXIService* service, struct MessageHeaderType* header, struct CableCheckReqType* params, struct CableCheckResType* result);
/**
* \brief Prepares the remote preCharge method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct PreChargeReqType* Request data for the server (has to be set up before)
* \param result struct PreChargeResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_preCharge(struct EXIService* service, struct MessageHeaderType* header, struct PreChargeReqType* params, struct PreChargeResType* result);
/**
* \brief Prepares the remote currentDemand method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct CurrentDemandReqType* Request data for the server (has to be set up before)
* \param result struct CurrentDemandResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_currentDemand(struct EXIService* service, struct MessageHeaderType* header, struct CurrentDemandReqType* params, struct CurrentDemandResType* result);
/**
* \brief Prepares the remote weldingDetection method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param params struct WeldingDetectionReqType* Request data for the server (has to be set up before)
* \param result struct WeldingDetectionResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_weldingDetection(struct EXIService* service, struct MessageHeaderType* header, struct WeldingDetectionReqType* params, struct WeldingDetectionResType* result);
/**
* \brief Prepares the remote sessionStop method
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param header struct MessageHeaderType* Header data structure
* \param result struct SessionStopResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int prepare_sessionStop(struct EXIService* service, struct MessageHeaderType* header, struct SessionStopResType* result);
/**
* \brief Determines which response message was received
* \param service struct EXIService* Service data structure (has to be initialized before)
* \param respMsg enum responseMessages* contains the name of the response message
* \param result struct SessionStopResType* Contains the response data from the server
* \return 0 = 0K; 0 != ERROR */
int determineResponseMesssage(struct EXIService* service, enum responseMessages* respMsg);
/* Initialize the v2g client */
int init_v2gServiceClient(struct EXIService* service, bytes_t bytes, string_ucs_t string, uint8_t* inStream, size_t max_inStream_size, uint8_t* outStream, size_t max_outStream_size, uint32_t* outPayloadLength, uint16_t transportHeaderOffset);
#endif
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,848 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#include "EXITypes.h"
#include "v2g_serviceDataTypes.h"
static void init_sessionIDType(struct sessionIDType* type)
{
type->arraylen.data=0;
}
static void init_faultMsgType(struct faultMsgType* type)
{
type->arraylen.data=0;
}
static void init_NotificationType(struct NotificationType* type)
{
init_faultMsgType(&(type->FaultMsg));
type->isused.FaultMsg=0;
}
static void init_service_string(struct service_string* type)
{
type->arraylen.data=0;
}
static void init_CanonicalizationMethodType(struct CanonicalizationMethodType* type)
{
init_service_string(&(type->attr_Algorithm));
}
static void init_SignatureMethodType(struct SignatureMethodType* type)
{
init_service_string(&(type->attr_Algorithm));
}
static void init_DigestMethodType(struct DigestMethodType* type)
{
init_service_string(&(type->attr_Algorithm));
}
static void init_DigestValueType(struct DigestValueType* type)
{
type->arraylen.data=0;
}
static void init_ReferenceType(struct ReferenceType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_service_string(&(type->attr_URI));
type->isused.attr_URI=0;
init_service_string(&(type->attr_Type));
type->isused.attr_Type=0;
init_DigestMethodType(&(type->DigestMethod));
init_DigestValueType(&(type->DigestValue));
}
static void init_SignedInfoType(struct SignedInfoType* type)
{
int i_loop;
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_CanonicalizationMethodType(&(type->CanonicalizationMethod));
init_SignatureMethodType(&(type->SignatureMethod));
for(i_loop=0; i_loop<1;i_loop++)
{
init_ReferenceType(&(type->Reference[i_loop]));
}
type->arraylen.Reference=0;
}
static void init_SignatureValueType(struct SignatureValueType* type)
{
}
static void init_X509IssuerSerialType(struct X509IssuerSerialType* type)
{
init_service_string(&(type->X509IssuerName));
}
static void init_service_byte(struct service_byte* type)
{
type->arraylen.data=0;
}
static void init_X509DataType(struct X509DataType* type)
{
init_X509IssuerSerialType(&(type->X509IssuerSerial));
init_service_byte(&(type->X509SKI));
init_service_string(&(type->X509SubjectName));
init_service_byte(&(type->X509Certificate));
init_service_byte(&(type->X509CRL));
}
static void init_KeyInfoType(struct KeyInfoType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_X509DataType(&(type->X509Data));
}
static void init_SignatureType(struct SignatureType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_SignedInfoType(&(type->SignedInfo));
init_SignatureValueType(&(type->SignatureValue));
init_KeyInfoType(&(type->KeyInfo));
type->isused.KeyInfo=0;
}
static void init_MessageHeaderType(struct MessageHeaderType* type)
{
init_sessionIDType(&(type->SessionID));
init_NotificationType(&(type->Notification));
type->isused.Notification=0;
type->isused.Signature=0;
}
static void init_evccIDType(struct evccIDType* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupReqType(struct SessionSetupReqType* type)
{
init_evccIDType(&(type->EVCCID));
}
static void init_evseIDType(struct evseIDType* type)
{
type->arraylen.data=0;
}
static void init_SessionSetupResType(struct SessionSetupResType* type)
{
init_evseIDType(&(type->EVSEID));
type->isused.DateTimeNow=0;
}
static void init_serviceScopeType(struct serviceScopeType* type)
{
type->arraylen.data=0;
}
static void init_ServiceDiscoveryReqType(struct ServiceDiscoveryReqType* type)
{
init_serviceScopeType(&(type->ServiceScope));
type->isused.ServiceScope=0;
type->isused.ServiceCategory=0;
}
static void init_PaymentOptionsType(struct PaymentOptionsType* type)
{
type->arraylen.PaymentOption=0;
}
static void init_serviceNameType(struct serviceNameType* type)
{
type->arraylen.data=0;
}
static void init_ServiceTagType(struct ServiceTagType* type)
{
init_serviceNameType(&(type->ServiceName));
type->isused.ServiceName=0;
type->isused.ServiceCategory=0;
init_serviceScopeType(&(type->ServiceScope));
type->isused.ServiceScope=0;
}
static void init_ServiceChargeType(struct ServiceChargeType* type)
{
init_ServiceTagType(&(type->ServiceTag));
}
static void init_ServiceType(struct ServiceType* type)
{
init_ServiceTagType(&(type->ServiceTag));
}
static void init_ServiceTagListType(struct ServiceTagListType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_ServiceType(&(type->Service[i_loop]));
}
type->arraylen.Service=0;
}
static void init_ServiceDiscoveryResType(struct ServiceDiscoveryResType* type)
{
init_PaymentOptionsType(&(type->PaymentOptions));
init_ServiceChargeType(&(type->ChargeService));
init_ServiceTagListType(&(type->ServiceList));
type->isused.ServiceList=0;
}
static void init_PhysicalValueType(struct PhysicalValueType* type)
{
type->isused.Unit=0;
}
static void init_ParameterType(struct ParameterType* type)
{
init_service_string(&(type->attr_Name));
init_service_string(&(type->attr_ValueType));
init_PhysicalValueType(&(type->physicalValue));
init_service_string(&(type->stringValue));
}
static void init_ParameterSetType(struct ParameterSetType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_ParameterType(&(type->Parameter[i_loop]));
}
type->arraylen.Parameter=0;
}
static void init_ServiceParameterListType(struct ServiceParameterListType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_ParameterSetType(&(type->ParameterSet[i_loop]));
}
type->arraylen.ParameterSet=0;
}
static void init_ServiceDetailResType(struct ServiceDetailResType* type)
{
init_ServiceParameterListType(&(type->ServiceParameterList));
type->isused.ServiceParameterList=0;
}
static void init_SelectedServiceType(struct SelectedServiceType* type)
{
type->isused.ParameterSetID=0;
}
static void init_SelectedServiceListType(struct SelectedServiceListType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_SelectedServiceType(&(type->SelectedService[i_loop]));
}
type->arraylen.SelectedService=0;
}
static void init_ServicePaymentSelectionReqType(struct ServicePaymentSelectionReqType* type)
{
init_SelectedServiceListType(&(type->SelectedServiceList));
}
static void init_contractIDType(struct contractIDType* type)
{
type->arraylen.data=0;
}
static void init_certificateType(struct certificateType* type)
{
type->arraylen.data=0;
}
static void init_SubCertificatesType(struct SubCertificatesType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_certificateType(&(type->Certificate[i_loop]));
}
type->arraylen.Certificate=0;
}
static void init_CertificateChainType(struct CertificateChainType* type)
{
init_certificateType(&(type->Certificate));
init_SubCertificatesType(&(type->SubCertificates));
type->isused.SubCertificates=0;
}
static void init_PaymentDetailsReqType(struct PaymentDetailsReqType* type)
{
init_contractIDType(&(type->ContractID));
init_CertificateChainType(&(type->ContractSignatureCertChain));
}
static void init_genChallengeType(struct genChallengeType* type)
{
type->arraylen.data=0;
}
static void init_PaymentDetailsResType(struct PaymentDetailsResType* type)
{
init_genChallengeType(&(type->GenChallenge));
}
static void init_ContractAuthenticationReqType(struct ContractAuthenticationReqType* type)
{
init_service_string(&(type->attr_Id));
init_genChallengeType(&(type->GenChallenge));
}
static void init_AC_EVChargeParameterType(struct AC_EVChargeParameterType* type)
{
init_PhysicalValueType(&(type->EAmount));
init_PhysicalValueType(&(type->EVMaxVoltage));
init_PhysicalValueType(&(type->EVMaxCurrent));
init_PhysicalValueType(&(type->EVMinCurrent));
}
static void init_DC_EVStatusType(struct DC_EVStatusType* type)
{
type->isused.EVCabinConditioning=0;
type->isused.EVRESSConditioning=0;
}
static void init_DC_EVChargeParameterType(struct DC_EVChargeParameterType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
init_PhysicalValueType(&(type->EVMaximumCurrentLimit));
init_PhysicalValueType(&(type->EVMaximumPowerLimit));
type->isused.EVMaximumPowerLimit=0;
init_PhysicalValueType(&(type->EVMaximumVoltageLimit));
init_PhysicalValueType(&(type->EVEnergyCapacity));
type->isused.EVEnergyCapacity=0;
init_PhysicalValueType(&(type->EVEnergyRequest));
type->isused.EVEnergyRequest=0;
type->isused.FullSOC=0;
type->isused.BulkSOC=0;
}
static void init_ChargeParameterDiscoveryReqType(struct ChargeParameterDiscoveryReqType* type)
{
type->isused.AC_EVChargeParameter=0;
type->isused.DC_EVChargeParameter=0;
}
static void init_RelativeTimeIntervalType(struct RelativeTimeIntervalType* type)
{
type->isused.duration=0;
}
static void init_PMaxScheduleEntryType(struct PMaxScheduleEntryType* type)
{
init_RelativeTimeIntervalType(&(type->RelativeTimeInterval));
}
static void init_PMaxScheduleType(struct PMaxScheduleType* type)
{
int i_loop;
for(i_loop=0; i_loop<12;i_loop++)
{
init_PMaxScheduleEntryType(&(type->PMaxScheduleEntry[i_loop]));
}
type->arraylen.PMaxScheduleEntry=0;
}
static void init_tariffDescriptionType(struct tariffDescriptionType* type)
{
type->arraylen.data=0;
}
static void init_CostType(struct CostType* type)
{
type->isused.amountMultiplier=0;
}
static void init_ConsumptionCostType(struct ConsumptionCostType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_CostType(&(type->Cost[i_loop]));
}
type->arraylen.Cost=0;
type->isused.Cost=0;
}
static void init_SalesTariffEntryType(struct SalesTariffEntryType* type)
{
int i_loop;
init_RelativeTimeIntervalType(&(type->RelativeTimeInterval));
for(i_loop=0; i_loop<2;i_loop++)
{
init_ConsumptionCostType(&(type->ConsumptionCost[i_loop]));
}
type->arraylen.ConsumptionCost=0;
type->isused.ConsumptionCost=0;
}
static void init_SalesTariffType(struct SalesTariffType* type)
{
int i_loop;
init_service_string(&(type->attr_Id));
init_tariffDescriptionType(&(type->SalesTariffDescription));
type->isused.SalesTariffDescription=0;
for(i_loop=0; i_loop<2;i_loop++)
{
init_SalesTariffEntryType(&(type->SalesTariffEntry[i_loop]));
}
type->arraylen.SalesTariffEntry=0;
}
static void init_SAScheduleTupleType(struct SAScheduleTupleType* type)
{
init_PMaxScheduleType(&(type->PMaxSchedule));
type->isused.SalesTariff=0;
}
static void init_SAScheduleListType(struct SAScheduleListType* type)
{
int i_loop;
for(i_loop=0; i_loop<3;i_loop++)
{
init_SAScheduleTupleType(&(type->SAScheduleTuple[i_loop]));
}
type->arraylen.SAScheduleTuple=0;
}
static void init_AC_EVSEChargeParameterType(struct AC_EVSEChargeParameterType* type)
{
init_PhysicalValueType(&(type->EVSEMaxVoltage));
init_PhysicalValueType(&(type->EVSEMaxCurrent));
init_PhysicalValueType(&(type->EVSEMinCurrent));
}
static void init_DC_EVSEStatusType(struct DC_EVSEStatusType* type)
{
type->isused.EVSEIsolationStatus=0;
}
static void init_DC_EVSEChargeParameterType(struct DC_EVSEChargeParameterType* type)
{
init_DC_EVSEStatusType(&(type->DC_EVSEStatus));
init_PhysicalValueType(&(type->EVSEMaximumCurrentLimit));
init_PhysicalValueType(&(type->EVSEMaximumPowerLimit));
type->isused.EVSEMaximumPowerLimit=0;
init_PhysicalValueType(&(type->EVSEMaximumVoltageLimit));
init_PhysicalValueType(&(type->EVSEMinimumCurrentLimit));
init_PhysicalValueType(&(type->EVSEMinimumVoltageLimit));
init_PhysicalValueType(&(type->EVSECurrentRegulationTolerance));
type->isused.EVSECurrentRegulationTolerance=0;
init_PhysicalValueType(&(type->EVSEPeakCurrentRipple));
init_PhysicalValueType(&(type->EVSEEnergyToBeDelivered));
type->isused.EVSEEnergyToBeDelivered=0;
}
static void init_ChargeParameterDiscoveryResType(struct ChargeParameterDiscoveryResType* type)
{
type->isused.SAScheduleList=0;
type->isused.AC_EVSEChargeParameter=0;
type->isused.DC_EVSEChargeParameter=0;
}
static void init_ChargingProfileType(struct ChargingProfileType* type)
{
type->arraylen.ProfileEntry=0;
}
static void init_DC_EVPowerDeliveryParameterType(struct DC_EVPowerDeliveryParameterType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
type->isused.BulkChargingComplete=0;
}
static void init_PowerDeliveryReqType(struct PowerDeliveryReqType* type)
{
init_ChargingProfileType(&(type->ChargingProfile));
type->isused.ChargingProfile=0;
type->isused.DC_EVPowerDeliveryParameter=0;
}
static void init_PowerDeliveryResType(struct PowerDeliveryResType* type)
{
type->isused.AC_EVSEStatus=0;
type->isused.DC_EVSEStatus=0;
}
static void init_meterIDType(struct meterIDType* type)
{
type->arraylen.data=0;
}
static void init_sigMeterReadingType(struct sigMeterReadingType* type)
{
type->arraylen.data=0;
}
static void init_MeterInfoType(struct MeterInfoType* type)
{
init_meterIDType(&(type->MeterID));
init_PhysicalValueType(&(type->MeterReading));
type->isused.MeterReading=0;
init_sigMeterReadingType(&(type->SigMeterReading));
type->isused.SigMeterReading=0;
type->isused.MeterStatus=0;
type->isused.TMeter=0;
}
static void init_ChargingStatusResType(struct ChargingStatusResType* type)
{
init_evseIDType(&(type->EVSEID));
init_PhysicalValueType(&(type->EVSEMaxCurrent));
type->isused.EVSEMaxCurrent=0;
init_MeterInfoType(&(type->MeterInfo));
type->isused.MeterInfo=0;
}
static void init_MeteringReceiptReqType(struct MeteringReceiptReqType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_sessionIDType(&(type->SessionID));
init_MeterInfoType(&(type->MeterInfo));
}
static void init_MeteringReceiptResType(struct MeteringReceiptResType* type)
{
}
static void init_rootCertificateIDType(struct rootCertificateIDType* type)
{
type->arraylen.data=0;
}
static void init_ListOfRootCertificateIDsType(struct ListOfRootCertificateIDsType* type)
{
int i_loop;
for(i_loop=0; i_loop<2;i_loop++)
{
init_rootCertificateIDType(&(type->RootCertificateID[i_loop]));
}
type->arraylen.RootCertificateID=0;
}
static void init_CertificateUpdateReqType(struct CertificateUpdateReqType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_CertificateChainType(&(type->ContractSignatureCertChain));
init_contractIDType(&(type->ContractID));
init_ListOfRootCertificateIDsType(&(type->ListOfRootCertificateIDs));
}
static void init_privateKeyType(struct privateKeyType* type)
{
type->arraylen.data=0;
}
static void init_dHParamsType(struct dHParamsType* type)
{
type->arraylen.data=0;
}
static void init_CertificateUpdateResType(struct CertificateUpdateResType* type)
{
init_service_string(&(type->attr_Id));
init_CertificateChainType(&(type->ContractSignatureCertChain));
init_privateKeyType(&(type->ContractSignatureEncryptedPrivateKey));
init_privateKeyType(&(type->ContractEncryptionEncryptedPrivateKey));
init_dHParamsType(&(type->DHParams));
init_contractIDType(&(type->ContractID));
}
static void init_CertificateInstallationReqType(struct CertificateInstallationReqType* type)
{
init_service_string(&(type->attr_Id));
type->isused.attr_Id=0;
init_certificateType(&(type->OEMProvisioningCert));
init_ListOfRootCertificateIDsType(&(type->ListOfRootCertificateIDs));
}
static void init_CertificateInstallationResType(struct CertificateInstallationResType* type)
{
init_service_string(&(type->attr_Id));
init_CertificateChainType(&(type->ContractSignatureCertChain));
init_privateKeyType(&(type->ContractSignatureEncryptedPrivateKey));
init_privateKeyType(&(type->ContractEncryptionEncryptedPrivateKey));
init_dHParamsType(&(type->DHParams));
init_contractIDType(&(type->ContractID));
}
static void init_CableCheckReqType(struct CableCheckReqType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
}
static void init_CableCheckResType(struct CableCheckResType* type)
{
init_DC_EVSEStatusType(&(type->DC_EVSEStatus));
}
static void init_PreChargeReqType(struct PreChargeReqType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
init_PhysicalValueType(&(type->EVTargetVoltage));
init_PhysicalValueType(&(type->EVTargetCurrent));
}
static void init_PreChargeResType(struct PreChargeResType* type)
{
init_DC_EVSEStatusType(&(type->DC_EVSEStatus));
init_PhysicalValueType(&(type->EVSEPresentVoltage));
}
static void init_CurrentDemandReqType(struct CurrentDemandReqType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
init_PhysicalValueType(&(type->EVTargetCurrent));
init_PhysicalValueType(&(type->EVMaximumVoltageLimit));
type->isused.EVMaximumVoltageLimit=0;
init_PhysicalValueType(&(type->EVMaximumCurrentLimit));
type->isused.EVMaximumCurrentLimit=0;
init_PhysicalValueType(&(type->EVMaximumPowerLimit));
type->isused.EVMaximumPowerLimit=0;
type->isused.BulkChargingComplete=0;
init_PhysicalValueType(&(type->RemainingTimeToFullSoC));
type->isused.RemainingTimeToFullSoC=0;
init_PhysicalValueType(&(type->RemainingTimeToBulkSoC));
type->isused.RemainingTimeToBulkSoC=0;
init_PhysicalValueType(&(type->EVTargetVoltage));
}
static void init_CurrentDemandResType(struct CurrentDemandResType* type)
{
init_DC_EVSEStatusType(&(type->DC_EVSEStatus));
init_PhysicalValueType(&(type->EVSEPresentVoltage));
init_PhysicalValueType(&(type->EVSEPresentCurrent));
init_PhysicalValueType(&(type->EVSEMaximumVoltageLimit));
type->isused.EVSEMaximumVoltageLimit=0;
init_PhysicalValueType(&(type->EVSEMaximumCurrentLimit));
type->isused.EVSEMaximumCurrentLimit=0;
init_PhysicalValueType(&(type->EVSEMaximumPowerLimit));
type->isused.EVSEMaximumPowerLimit=0;
}
static void init_WeldingDetectionReqType(struct WeldingDetectionReqType* type)
{
init_DC_EVStatusType(&(type->DC_EVStatus));
}
static void init_WeldingDetectionResType(struct WeldingDetectionResType* type)
{
init_DC_EVSEStatusType(&(type->DC_EVSEStatus));
init_PhysicalValueType(&(type->EVSEPresentVoltage));
}
static void init_BodyType(struct BodyType* type)
{
type->isused.SessionSetupReq=0;
type->isused.SessionSetupRes=0;
type->isused.ServiceDiscoveryReq=0;
type->isused.ServiceDiscoveryRes=0;
type->isused.ServiceDetailReq=0;
type->isused.ServiceDetailRes=0;
type->isused.ServicePaymentSelectionReq=0;
type->isused.ServicePaymentSelectionRes=0;
type->isused.PaymentDetailsReq=0;
type->isused.PaymentDetailsRes=0;
type->isused.ContractAuthenticationReq=0;
type->isused.ContractAuthenticationRes=0;
type->isused.ChargeParameterDiscoveryReq=0;
type->isused.ChargeParameterDiscoveryRes=0;
type->isused.PowerDeliveryReq=0;
type->isused.PowerDeliveryRes=0;
type->isused.ChargingStatusReq=0;
type->isused.ChargingStatusRes=0;
type->isused.MeteringReceiptReq=0;
type->isused.MeteringReceiptRes=0;
type->isused.SessionStopReq=0;
type->isused.SessionStopRes=0;
type->isused.CertificateUpdateReq=0;
type->isused.CertificateUpdateRes=0;
type->isused.CertificateInstallationReq=0;
type->isused.CertificateInstallationRes=0;
type->isused.CableCheckReq=0;
type->isused.CableCheckRes=0;
type->isused.PreChargeReq=0;
type->isused.PreChargeRes=0;
type->isused.CurrentDemandReq=0;
type->isused.CurrentDemandRes=0;
type->isused.WeldingDetectionReq=0;
type->isused.WeldingDetectionRes=0;
}
static void init_AnonType_V2G_Message(struct AnonType_V2G_Message* type)
{
init_BodyType(&(type->Body));
}
static void init_EXIDocumentType(struct EXIDocumentType* type)
{
init_AnonType_V2G_Message(&(type->V2G_Message));
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,43 +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
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2GSERVER_H_
#define V2GSERVER_H_
#include "v2g_serviceDataTypes.h"
int init_v2gservice(struct EXIService* service,bytes_t bytes, string_ucs_t string, uint16_t transportHeaderOffset);
int messageDispatcher(struct EXIService* service, uint8_t* inStream, uint16_t sizeInStream, uint8_t* outStream, uint16_t sizeOutStream, uint16_t* outPos);
#endif /* V2GSERVER_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -1,87 +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
*
* <p>Code generated by EXISeGen</p>
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICEMETHODS_H
#define SERVICEMETHODS_H
#include "v2g_serviceDataTypes.h"
#include "EXITypes.h"
/* This service methods has to be implemented by the EVSE server */
int sessionSetup(struct MessageHeaderType* header, struct SessionSetupReqType* param, struct SessionSetupResType* result);
int serviceDiscovery(struct MessageHeaderType* header, struct ServiceDiscoveryReqType* param, struct ServiceDiscoveryResType* result);
int serviceDetail(struct MessageHeaderType* header, struct ServiceDetailReqType* param, struct ServiceDetailResType* result);
int servicePaymentSelection(struct MessageHeaderType* header, struct ServicePaymentSelectionReqType* param, struct ServicePaymentSelectionResType* result);
int paymentDetails(struct MessageHeaderType* header, struct PaymentDetailsReqType* param, struct PaymentDetailsResType* result);
int contractAuthentication(struct MessageHeaderType* header, struct ContractAuthenticationReqType* param, struct ContractAuthenticationResType* result);
int chargeParameterDiscovery(struct MessageHeaderType* header, struct ChargeParameterDiscoveryReqType* param, struct ChargeParameterDiscoveryResType* result);
int powerDelivery(struct MessageHeaderType* header, struct PowerDeliveryReqType* param, struct PowerDeliveryResType* result);
int chargingStatus(struct MessageHeaderType* header, struct ChargingStatusReqType* param, struct ChargingStatusResType* result);
int meteringReceipt(struct MessageHeaderType* header, struct MeteringReceiptReqType* param, struct MeteringReceiptResType* result);
int sessionStop(struct MessageHeaderType* header, struct SessionStopType* param, struct SessionStopResType* result);
int certificateUpdate(struct MessageHeaderType* header, struct CertificateUpdateReqType* param, struct CertificateUpdateResType* result);
int certificateInstallation(struct MessageHeaderType* header, struct CertificateInstallationReqType* param, struct CertificateInstallationResType* result);
int cableCheck(struct MessageHeaderType* header, struct CableCheckReqType* param, struct CableCheckResType* result);
int preCharge(struct MessageHeaderType* header, struct PreChargeReqType* param, struct PreChargeResType* result);
int currentDemand(struct MessageHeaderType* header, struct CurrentDemandReqType* param, struct CurrentDemandResType* result);
int weldingDetection(struct MessageHeaderType* header, struct WeldingDetectionReqType* param, struct WeldingDetectionResType* result);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -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");
}

View file

@ -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_ */

View file

@ -1,576 +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;
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;
}
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.Value = 400;
result->isused.EVSEMaxCurrent=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;
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);
if(param->isused.RemainingTimeToFullSoC)
printf("\t\t RemainingTimeToFullSoC=%d\n", param->RemainingTimeToFullSoC.Value);
if(param->isused.RemainingTimeToBulkSoC)
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 = 300;
result->EVSEPresentVoltage=f;
f.Unit = A_unitSymbolType;
f.Value = 45;
result->EVSEPresentCurrent=f;
result->EVSECurrentLimitAchieved=0;
result->EVSEVoltageLimitAchieved=0;
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)
{
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");
}

View file

@ -1,44 +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 Daniel.Peintner.EXT@siemens.com
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.6
* @contact Joerg.Heuer@siemens.com
*
* <p>Switch for sample programs: EXI codec only or for entire V2G service</p>
*
********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
int main(int argc, char *argv[]) {
#if CODE_VERSION == CODE_VERSION_EXI
/* EXI codec only */
return main_codec(argc, argv);
#elif CODE_VERSION == CODE_VERSION_SERVICE
/* V2G client / service example scenario */
return main_service(argc, argv);
#endif
}

View file

@ -1,42 +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 Daniel.Peintner.EXT@siemens.com
* @author Sebastian.Kaebisch.EXT@siemens.com
* @version 0.6
* @contact Joerg.Heuer@siemens.com
*
*
********************************************************************/
#define CODE_VERSION_EXI 1
#define CODE_VERSION_SERVICE 2
#define CODE_VERSION CODE_VERSION_SERVICE
#ifndef MAIN_H_
#define MAIN_H_
#if CODE_VERSION == CODE_VERSION_EXI
int main_codec(int argc, char *argv[]);
#elif CODE_VERSION == CODE_VERSION_SERVICE
int main_service(int argc, char *argv[]);
#endif
#endif

View file

@ -1,330 +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 2012-01-31
* @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 200
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];
int main_codec(int argc, char *argv[]) {
int errn = 0;
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 };
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);
do {
if (errn < 0) {
return errn;
}
errn = exiDecodeNextEvent(&iStream, &stateDecode,
&event);
if (errn < 0) {
return errn;
}
switch (event) {
case START_DOCUMENT:
/* decode */
errn = exiDecodeStartDocument(&iStream,
&stateDecode);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeStartDocument(&oStream,
&stateEncode);
break;
case END_DOCUMENT:
/* decode */
errn = exiDecodeEndDocument(&iStream,
&stateDecode);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeEndDocument(&oStream,
&stateEncode);
/* signalize end of document */
noEndOfDocument = 0; /* false */
break;
case START_ELEMENT:
/* decode */
errn = exiDecodeStartElement(&iStream,
&stateDecode, &eqn);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeStartElement(&oStream,
&stateEncode, &eqn);
break;
case START_ELEMENT_GENERIC:
/* decode */
errn = exiDecodeStartElementGeneric(&iStream,
&stateDecode, &qn);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeStartElementGeneric(&oStream,
&stateEncode, &stringNamespaceURI, &stringLocalName);
break;
case END_ELEMENT:
/* decode */
errn = exiDecodeEndElement(&iStream,
&stateDecode, &eqn);
if (errn < 0) {
return errn;
}
/* encode */
errn
= exiEncodeEndElement(&oStream,
&stateEncode);
break;
case END_ELEMENT_UNDECLARED:
/* decode */
errn = exiDecodeEndElementUndeclared(&iStream,
&stateDecode, &eqn);
if (errn < 0) {
return errn;
}
/* encode */
errn
= exiEncodeEndElement(&oStream,
&stateEncode);
break;
case CHARACTERS:
/* decode */
errn = exiDecodeCharacters(&iStream,
&stateDecode, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeCharacters(&oStream,
&stateEncode, &val);
break;
case CHARACTERS_GENERIC:
/* decode */
errn = exiDecodeCharactersGeneric(&iStream,
&stateDecode, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeCharacters(&oStream,
&stateEncode, &val);
break;
case CHARACTERS_GENERIC_UNDECLARED:
/* decode */
errn = exiDecodeCharactersGenericUndeclared(
&iStream, &stateDecode, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeCharacters(&oStream,
&stateEncode, &val);
break;
case ATTRIBUTE:
/* decode */
errn = exiDecodeAttribute(&iStream, &stateDecode,
&eqn, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode,
&eqn, &val);
break;
case ATTRIBUTE_XSI_NIL:
/* decode */
errn = exiDecodeAttributeXsiNil(&iStream,
&stateDecode, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeAttributeXsiNil(&oStream,
&stateEncode, &val);
break;
case ATTRIBUTE_XSI_TYPE:
/* decode */
errn = exiDecodeAttributeXsiType(&iStream,
&stateDecode, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeAttributeXsiType(&oStream,
&stateEncode, &val);
break;
case ATTRIBUTE_GENERIC_UNDECLARED:
/* decode */
errn = exiDecodeAttributeGenericUndeclared(
&iStream, &stateDecode, &qn, &val);
if (errn < 0) {
return errn;
}
/* encode */
errn = exiEncodeAttribute(&oStream, &stateEncode,
&eqn, &val);
break;
default:
/* ERROR */
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;
}

File diff suppressed because it is too large Load diff

View file

@ -1,47 +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 "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);
}

View file

@ -1,43 +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
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SERVICECLIENTDATATRANSMITTER_H_
#define SERVICECLIENTDATATRANSMITTER_H_
#include <stdint.h>
/*
* This method sends EXI stream (outStream) to the EVSE and receives a response stream (inStream)*/
int serviceDataTransmitter(uint8_t* outStream, uint16_t outStreamLength, uint8_t* inStream);
#endif /* V2G_SERVICECLIENTDATATRANSMITTER_H_ */
#ifdef __cplusplus
}
#endif

View file

@ -1,98 +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
*
********************************************************************/
/*
* This file implements the v2gtp header writer and reader.
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "v2gtp.h"
int write_v2gtpHeader(uint8_t* outStream, uint16_t* outStreamLength, uint16_t payloadType)
{
/* write v2gtp version number 1=byte */
outStream[0]=V2GTP_VERSION;
/* write inverse v2gtp version */
outStream[1]=V2GTP_VERSION_INV;
/* write payload type */
outStream[2] = (uint8_t)(payloadType & 0xFF);
outStream[3] = (uint8_t)(payloadType >> 8 & 0xFF);
/* write payload length */
outStream[4] = (uint8_t)(*outStreamLength & 0xFF);
outStream[5] = (uint8_t)(*outStreamLength>>8 & 0xFF);
outStream[6] = (uint8_t)(*outStreamLength>>16 & 0xFF);
outStream[7] = (uint8_t)(*outStreamLength>>24 & 0xFF);
/* here, the outStream length have to be resized by the v2gtp offset*/
*outStreamLength += V2GTP_HEADER_LENGTH;
return 0;
}
int read_v2gtpHeader(uint8_t* inStream, uint16_t inStreamLength, uint16_t* payloadLength)
{
uint16_t payloadType=0;
/* check, if we support this v2gtp version */
if(inStream[0]!=V2GTP_VERSION && inStream[1]!=V2GTP_VERSION_INV)
return -1;
/* check, if we support this payload type*/
payloadType = inStream[3];
payloadType = (payloadType << 8 | inStream[2]);
if(payloadType != V2GTP_EXI_TYPE)
return -1;
/* determine payload length*/
*payloadLength = inStream[7];
*payloadLength = (*payloadLength << 8 | inStream[6]);
*payloadLength = (*payloadLength << 16 | inStream[5]);
*payloadLength = (*payloadLength << 24 | inStream[4]);
if((*payloadLength+V2GTP_HEADER_LENGTH)!=inStreamLength)
return -1;
return 0;
}

View file

@ -1,54 +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
*
********************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V2GTP_H_
#define V2GTP_H_
/* generic V2GTP header length */
#define V2GTP_HEADER_LENGTH 8
/* define V2GTP Version */
#define V2GTP_VERSION 0x01
#define V2GTP_VERSION_INV 0xFE
/* define V2GTP payload types*/
#define V2GTP_EXI_TYPE 0x8001
int write_v2gtpHeader(uint8_t* outStream, uint16_t* outStreamLength, uint16_t payloadType);
int read_v2gtpHeader(uint8_t* inStream, uint16_t inStreamLength, uint16_t* payloadLength);
#endif /* V2GTP_H_ */
#ifdef __cplusplus
}
#endif