From 05301bf248bea4d2ca16dddaf3d05baf73e4ab77 Mon Sep 17 00:00:00 2001 From: sebastiankb Date: Wed, 22 Dec 2010 14:36:13 +0000 Subject: [PATCH] 0.3.1 release (EXI codec) git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@28 d9f2db14-54d0-4bde-b00c-16405c910529 --- src/codec/BitDecoderChannel.c | 288 ++++++ src/codec/BitDecoderChannel.h | 131 +++ src/codec/BitEncoderChannel.c | 298 ++++++ src/codec/BitEncoderChannel.h | 133 +++ src/codec/BitInputStream.c | 100 ++ src/codec/BitInputStream.h | 44 + src/codec/BitOutputStream.c | 95 ++ src/codec/BitOutputStream.h | 48 + src/codec/ByteStream.c | 83 ++ src/codec/ByteStream.h | 46 + src/codec/EXICoder.c | 70 ++ src/codec/EXICoder.h | 51 + src/codec/EXIDecoder.c | 1616 ++++++++++++++++++++++++++++++++ src/codec/EXIDecoder.h | 64 ++ src/codec/EXIEncoder.c | 1442 ++++++++++++++++++++++++++++ src/codec/EXIEncoder.h | 61 ++ src/codec/EXIHeaderDecoder.c | 58 ++ src/codec/EXIHeaderDecoder.h | 44 + src/codec/EXIHeaderEncoder.c | 43 + src/codec/EXIHeaderEncoder.h | 44 + src/codec/EXITypes.h | 187 ++++ src/codec/StringTable.c | 109 +++ src/codec/StringTable.h | 53 ++ src/codec/StringTableEntries.c | 126 +++ src/codec/StringTableEntries.h | 60 ++ src/codec/UCSString.c | 64 ++ src/codec/UCSString.h | 48 + 27 files changed, 5406 insertions(+) create mode 100644 src/codec/BitDecoderChannel.c create mode 100644 src/codec/BitDecoderChannel.h create mode 100644 src/codec/BitEncoderChannel.c create mode 100644 src/codec/BitEncoderChannel.h create mode 100644 src/codec/BitInputStream.c create mode 100644 src/codec/BitInputStream.h create mode 100644 src/codec/BitOutputStream.c create mode 100644 src/codec/BitOutputStream.h create mode 100644 src/codec/ByteStream.c create mode 100644 src/codec/ByteStream.h create mode 100644 src/codec/EXICoder.c create mode 100644 src/codec/EXICoder.h create mode 100644 src/codec/EXIDecoder.c create mode 100644 src/codec/EXIDecoder.h create mode 100644 src/codec/EXIEncoder.c create mode 100644 src/codec/EXIEncoder.h create mode 100644 src/codec/EXIHeaderDecoder.c create mode 100644 src/codec/EXIHeaderDecoder.h create mode 100644 src/codec/EXIHeaderEncoder.c create mode 100644 src/codec/EXIHeaderEncoder.h create mode 100644 src/codec/EXITypes.h create mode 100644 src/codec/StringTable.c create mode 100644 src/codec/StringTable.h create mode 100644 src/codec/StringTableEntries.c create mode 100644 src/codec/StringTableEntries.h create mode 100644 src/codec/UCSString.c create mode 100644 src/codec/UCSString.h diff --git a/src/codec/BitDecoderChannel.c b/src/codec/BitDecoderChannel.c new file mode 100644 index 0000000..4515189 --- /dev/null +++ b/src/codec/BitDecoderChannel.c @@ -0,0 +1,288 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + * Bit decoding functionalities + * + ********************************************************************/ + +#include +#include +#include +#include +#include + +#include "BitDecoderChannel.h" +#include "BitInputStream.h" +#include "EXITypes.h" + +#ifndef BIT_DECODER_CHANNEL_C +#define BIT_DECODER_CHANNEL_C + +/* only the least significant 8 bits are filled properly */ +int _decode(bitstream_t* stream, uint32_t* b) { + return readBits(stream, 8, b); +} + +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); + } +} + +int decodeUnsignedInteger16(bitstream_t* stream, uint16_t* uint16) { + unsigned int mShift = 0; + int errn = 0; + uint32_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; + uint32_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; + uint32_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; +} + +/** + * 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 sequence of characters for a given length. + */ +int decodeStringOnly(bitstream_t* stream, uint16_t len, string_ucs_t* s) { + 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 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 */ + printf("[ERROR] String local value partition hit not supported \n"); + return -2; + case 1: + /* found in global value partition */ + printf("[ERROR] String global value partition hit not supported \n"); + return -3; + 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); */ + } +} + +/** + * 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; +} + +/** + * Decode a binary value as a length-prefixed sequence of octets. + */ +int decodeBinary(bitstream_t* stream, bytes_t* bytes) { + unsigned int i; + uint32_t b; + int errn = decodeUnsignedInteger16(stream, &bytes->len); + if (errn < 0) { + return errn; + } + + 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; +} + +#endif + diff --git a/src/codec/BitDecoderChannel.h b/src/codec/BitDecoderChannel.h new file mode 100644 index 0000000..077f3e8 --- /dev/null +++ b/src/codec/BitDecoderChannel.h @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "EXITypes.h" + +#ifndef BIT_DECODER_CHANNEL_H +#define BIT_DECODER_CHANNEL_H + +/** + * 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 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 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 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); + +/** + * 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); + + +/** + * Decode a sequence of characters according to a given length. + */ +int decodeCharacters(bitstream_t* stream, uint16_t len, uint32_t* chars); + +/** + * Decode a binary value as a length-prefixed sequence of octets. + */ +int decodeBinary(bitstream_t* stream, bytes_t* bytes); + + +#endif + + +#ifdef __cplusplus +} +#endif + diff --git a/src/codec/BitEncoderChannel.c b/src/codec/BitEncoderChannel.c new file mode 100644 index 0000000..bd1162c --- /dev/null +++ b/src/codec/BitEncoderChannel.c @@ -0,0 +1,298 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ +#include +#include +#include + +#include "BitEncoderChannel.h" +#include "BitOutputStream.h" +#include "EXITypes.h" + +#ifndef BIT_ENCODER_CHANNEL_C +#define BIT_ENCODER_CHANNEL_C + +/** + * Returns the least number of 7 bit-blocks that is needed to represent the + * int n. Returns 1 if n is 0. + * + * @param n + * integer value + * + */ +uint8_t numberOf7BitBlocksToRepresent(int 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; + } +} + + +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) { + return writeBits(stream, nbits, 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 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); +} + + +/** + * 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 length prefixed sequence of characters. + */ +int encodeString(bitstream_t* stream, string_ucs_t* string) { + int errn = encodeUnsignedInteger32(stream, string->len); + if (errn >= 0) { + errn = encodeCharacters(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 = encodeCharacters(stream, string->codepoints, string->len); + } + 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 encodeCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len) { + unsigned int i; + int errn = 0; + for(i=0; i=0; i++) { + errn = encodeUnsignedInteger32(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; ilen && errn>=0; i++) { + errn = encode(stream, bytes->data[i]); + } + return errn; +} + +/** + * Flush underlying bit output stream. + */ +int encodeFinish(bitstream_t* stream) { + return flush(stream); +} + + +#endif + + + + + + + + + + + + diff --git a/src/codec/BitEncoderChannel.h b/src/codec/BitEncoderChannel.h new file mode 100644 index 0000000..ab5c366 --- /dev/null +++ b/src/codec/BitEncoderChannel.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "EXITypes.h" + +#ifndef BIT_ENCODER_CHANNEL_H +#define BIT_ENCODER_CHANNEL_H + +/** + * 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); + + +/** + * 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 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 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); + +/** + * 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 length prefixed sequence of characters. + */ +int encodeString(bitstream_t* stream, string_ucs_t* string); + +/** + * Encode a length prefixed sequence of characters in the sense of string tables + */ +int encodeStringValue(bitstream_t* stream, 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 encodeCharacters(bitstream_t* stream, uint32_t* chars, uint16_t len); + +/** + * Encode a binary value as a length-prefixed sequence of octets. + */ +int encodeBinary(bitstream_t* stream, bytes_t* bytes); + +/** + * Flush underlying bit output stream + */ +int encodeFinish(bitstream_t* stream); + + +#endif + + +#ifdef __cplusplus +} +#endif + + + + + + + + diff --git a/src/codec/BitInputStream.c b/src/codec/BitInputStream.c new file mode 100644 index 0000000..5297f45 --- /dev/null +++ b/src/codec/BitInputStream.c @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include +#include +#include + +#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 ( (*stream->pos) < stream->size ) { + stream->buffer = stream->data[(*stream->pos)++]; + stream->capacity = BITS_IN_BYTE; + } else { + errn = -1; + } + } + 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 diff --git a/src/codec/BitInputStream.h b/src/codec/BitInputStream.h new file mode 100644 index 0000000..5610c91 --- /dev/null +++ b/src/codec/BitInputStream.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#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 diff --git a/src/codec/BitOutputStream.c b/src/codec/BitOutputStream.c new file mode 100644 index 0000000..78f55c8 --- /dev/null +++ b/src/codec/BitOutputStream.c @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include + +#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 it into the data */ + if (stream->capacity == 0) { + if ((*stream->pos) >= stream->size) { + return -1; + } + stream->data[(*stream->pos)++] = 0xFF & stream->buffer; + 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 ((*stream->pos) >= stream->size) { + return -1; + } + stream->data[(*stream->pos)++] = 0xFF & stream->buffer; + stream->buffer = 0; + + /* write whole bytes */ + while (nbits >= BITS_IN_BYTE) { + nbits -= BITS_IN_BYTE; + if ((*stream->pos) >= stream->size) { + return -1; + } + stream->data[(*stream->pos)++] = 0xFF & (val >> (nbits)); + } + + /* 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 + diff --git a/src/codec/BitOutputStream.h b/src/codec/BitOutputStream.h new file mode 100644 index 0000000..0524663 --- /dev/null +++ b/src/codec/BitOutputStream.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#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 + diff --git a/src/codec/ByteStream.c b/src/codec/ByteStream.c new file mode 100644 index 0000000..dad7cb5 --- /dev/null +++ b/src/codec/ByteStream.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#define _CRT_SECURE_NO_DEPRECATE 1 + +#include +#include +#include +#include +#include + +#include "EXITypes.h" + +#ifndef BYTE_STREAM_C +#define BYTE_STREAM_C + +int readBytesFromFile(const char * filename, uint8_t* data, uint16_t size, uint16_t pos) { + FILE* f; + int character; + + f = fopen(filename, "rb"); + + if (f == NULL) { + printf("\n[Error] no valid file handle !\n"); + return -1; + } else { + /* read bytes */ + while ((character = getc(f)) != EOF) { + if (pos >= size) { + return -1; + } + data[pos++] = (uint8_t) character; + /* printf("%u \n", character); */ + } + fclose(f); + } + + return pos; +} + +int writeBytesToFile(uint8_t* data, uint16_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 -1; + } + } +} + + +#endif + diff --git a/src/codec/ByteStream.h b/src/codec/ByteStream.h new file mode 100644 index 0000000..ae06f64 --- /dev/null +++ b/src/codec/ByteStream.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "EXITypes.h" + +#ifndef BYTE_STREAM_H +#define BYTE_STREAM_H + +int writeBytesToFile(uint8_t* data, uint16_t len, const char * filename); + +int readBytesFromFile(const char * filename, uint8_t* data, uint16_t size, uint16_t pos); + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/codec/EXICoder.c b/src/codec/EXICoder.c new file mode 100644 index 0000000..83d2f86 --- /dev/null +++ b/src/codec/EXICoder.c @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifndef EXI_CODER_C +#define EXI_CODER_C + +#include +#include +#include +#include + +#include "EXITypes.h" +#include "BitInputStream.h" +#include "BitDecoderChannel.h" + +#include "assert.h" +#include "EXICoder.h" + +/* + uint16_t exiGetCurrentState(struct exiState* state) { + return state->grammarStates[state->currentStack]; + // return 0; + } + */ + +int exiPushStack(exi_state_t* state, uint16_t newState, eqname_t* eqn) { + if ((state->stackIndex + 1) < EXI_ELEMENT_STACK_SIZE) { + state->grammarStack[++state->stackIndex] = newState; + /* copy qname */ + state->elementStack[state->stackIndex].localPart = eqn->localPart; + state->elementStack[state->stackIndex].namespaceURI = eqn->namespaceURI; + return 0; + } else { + return EXI_ERROR_OUT_OF_BOUNDS; + } +} + +int exiPopStack(exi_state_t* state) { + if (state->stackIndex >= 1) { + state->stackIndex--; + return 0; + } else { + return EXI_ERROR_OUT_OF_BOUNDS; + } +} + +#endif + diff --git a/src/codec/EXICoder.h b/src/codec/EXICoder.h new file mode 100644 index 0000000..4852c66 --- /dev/null +++ b/src/codec/EXICoder.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef EXI_CODER_H +#define EXI_CODER_H + +#include +#include +#include + +#include "EXITypes.h" + + +/* uint16_t exiGetCurrentState(struct exiState* state); */ + +int exiPushStack(exi_state_t* state, uint16_t newState, eqname_t* eqn); + +int exiPopStack(exi_state_t* state); + +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/codec/EXIDecoder.c b/src/codec/EXIDecoder.c new file mode 100644 index 0000000..4fcb8b5 --- /dev/null +++ b/src/codec/EXIDecoder.c @@ -0,0 +1,1616 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + *

NOTE: Code generated by EXIdizer v0.1

+ ********************************************************************/ + +#ifndef EXI_DECODER_C +#define EXI_DECODER_C + +#include +#include +#include +#include + +#include "EXITypes.h" +#include "BitInputStream.h" +#include "BitDecoderChannel.h" + +#include "EXICoder.h" +#include "EXIHeaderDecoder.h" + + +int exiInitDecoder(bitstream_t* stream, exi_state_t* state) { + /* init grammar state */ + state->stackIndex = 0; + state->grammarStack[0] = 0; + /* decode header */ + return readEXIHeader(stream); +} + +int exiDecodeNextEvent(bitstream_t* stream, exi_state_t* state, + exi_event_t* nextEvent) { + + switch (state->grammarStack[state->stackIndex]) { + case 2: + /* DocEnd[END_DOCUMENT] */ + *nextEvent = END_DOCUMENT; + return 0; + case 56: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 75: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + case 100: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EnergyProvider), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + case 17: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + case 151: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 173: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceSessionID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + case 178: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + decodeNBitUnsignedInteger(stream, 2, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 2) { + *nextEvent = END_ELEMENT; + return 0; + } + case 168: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), END_ELEMENT] */ + decodeNBitUnsignedInteger(stream, 5, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 2) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 3) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 4) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 5) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 6) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 7) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 8) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 9) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 10) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 11) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 12) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 13) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 14) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 15) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 16) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 17) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 18) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 19) { + *nextEvent = END_ELEMENT; + return 0; + } + case 54: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 149: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 172: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + decodeNBitUnsignedInteger(stream, 2, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 2) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 3) { + *nextEvent = END_ELEMENT; + return 0; + } + case 7: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 48: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + case 114: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffDescription), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + case 21: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + decodeNBitUnsignedInteger(stream, 1, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + case 5: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 24: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqLockStatus)] */ + case 25: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + case 28: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ChargerStandby)] */ + case 6: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 32: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + case 35: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FatalError)] */ + case 36: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EVSEStandby)] */ + case 38: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + case 39: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}PowerSwitchClosed)] */ + case 40: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}RCD)] */ + case 42: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ShutDownTime)] */ + case 46: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 49: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + case 50: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo)] */ + case 57: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Multiplier)] */ + case 61: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Unit)] */ + case 63: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Value)] */ + case 8: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 10: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 69: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + case 71: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + case 73: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + case 74: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPower)] */ + case 11: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ContractID)] */ + case 12: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 13: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 82: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqSwitchStatus)] */ + case 14: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 15: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 87: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EoC)] */ + case 88: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EAmount)] */ + case 89: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPower)] */ + case 90: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPhases)] */ + case 91: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxVoltage)] */ + case 93: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMinVoltage)] */ + case 16: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 95: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + case 97: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEVoltage)] */ + case 98: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEIMax)] */ + case 99: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPhases)] */ + case 104: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Currency)] */ + case 105: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff)] */ + case 108: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffID)] */ + case 115: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + case 118: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry)] */ + case 120: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffStart)] */ + case 128: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffPMax)] */ + case 18: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 139: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service)] */ + case 141: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceID)] */ + case 19: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList)] */ + case 20: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 158: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + case 22: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + case 160: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + case 162: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + case 163: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + case 23: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Header)] */ + case 165: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Body)] */ + case 166: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}SessionInformation)] */ + case 170: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}SessionID)] */ + case 183: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Event)] */ + *nextEvent = START_ELEMENT; + return 0; + case 3: + /* First(xsi:type)StartTag[END_ELEMENT] */ + case 26: + /* Element[END_ELEMENT] */ + case 29: + /* Element[END_ELEMENT] */ + case 31: + /* Element[END_ELEMENT] */ + case 34: + /* Element[END_ELEMENT] */ + case 44: + /* Element[END_ELEMENT] */ + case 52: + /* Element[END_ELEMENT] */ + case 60: + /* Element[END_ELEMENT] */ + case 65: + /* Element[END_ELEMENT] */ + case 67: + /* Element[END_ELEMENT] */ + case 9: + /* FirstStartTag[END_ELEMENT] */ + case 77: + /* Element[END_ELEMENT] */ + case 78: + /* Element[END_ELEMENT] */ + case 80: + /* Element[END_ELEMENT] */ + case 84: + /* Element[END_ELEMENT] */ + case 85: + /* Element[END_ELEMENT] */ + case 94: + /* Element[END_ELEMENT] */ + case 103: + /* Element[END_ELEMENT] */ + case 113: + /* Element[END_ELEMENT] */ + case 117: + /* Element[END_ELEMENT] */ + case 127: + /* Element[END_ELEMENT] */ + case 131: + /* Element[END_ELEMENT] */ + case 134: + /* Element[END_ELEMENT] */ + case 138: + /* Element[END_ELEMENT] */ + case 148: + /* Element[END_ELEMENT] */ + case 154: + /* Element[END_ELEMENT] */ + case 155: + /* Element[END_ELEMENT] */ + case 156: + /* Element[END_ELEMENT] */ + case 159: + /* Element[END_ELEMENT] */ + case 164: + /* Element[END_ELEMENT] */ + case 167: + /* Element[END_ELEMENT] */ + case 171: + /* Element[END_ELEMENT] */ + case 176: + /* Element[END_ELEMENT] */ + case 182: + /* Element[END_ELEMENT] */ + case 184: + /* Element[END_ELEMENT] */ + case 186: + /* Element[END_ELEMENT] */ + *nextEvent = END_ELEMENT; + return 0; + case 27: + /* FirstStartTag[CHARACTERS[BOOLEAN]] */ + case 30: + /* FirstStartTag[CHARACTERS[BOOLEAN]] */ + case 33: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 37: + /* FirstStartTag[CHARACTERS[BOOLEAN]] */ + case 41: + /* FirstStartTag[CHARACTERS[BOOLEAN]] */ + case 43: + /* FirstStartTag[CHARACTERS[BOOLEAN]] */ + case 45: + /* FirstStartTag[CHARACTERS[INTEGER_32]] */ + case 47: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 51: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 55: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 62: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 64: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 66: + /* First(xsi:type)StartTag[CHARACTERS[INTEGER_32]] */ + case 59: + /* FirstStartTag[CHARACTERS[INTEGER_16]] */ + case 68: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 70: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 72: + /* FirstStartTag[CHARACTERS[BINARY_HEX]] */ + case 79: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 81: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 86: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 92: + /* FirstStartTag[CHARACTERS[INTEGER_16]] */ + case 96: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 102: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 106: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 116: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 129: + /* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER_32]] */ + case 133: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 135: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 137: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 150: + /* FirstStartTag[CHARACTERS[BINARY_HEX]] */ + case 152: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 157: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 161: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 174: + /* FirstStartTag[CHARACTERS[BINARY_HEX]] */ + case 177: + /* FirstStartTag[CHARACTERS[STRING]] */ + case 179: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + case 181: + /* First(xsi:type)StartTag[CHARACTERS[STRING]] */ + case 185: + /* FirstStartTag[CHARACTERS[ENUMERATION]] */ + *nextEvent = CHARACTERS; + return 0; + case 53: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + decodeNBitUnsignedInteger(stream, 3, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 2) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 3) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 4) { + *nextEvent = END_ELEMENT; + return 0; + } + case 58: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 76: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + case 83: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff), END_ELEMENT] */ + case 101: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + case 107: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 109: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 110: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 111: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 112: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 119: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 121: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 122: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 123: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 124: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 125: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 126: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 130: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EPrice), END_ELEMENT] */ + case 132: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + case 136: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList), END_ELEMENT] */ + case 140: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 142: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 143: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 144: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 145: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 146: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 147: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 153: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 169: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}Notification), END_ELEMENT] */ + case 175: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + case 180: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + decodeNBitUnsignedInteger(stream, 1, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = END_ELEMENT; + return 0; + } + case 1: + /* DocContent[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}V2G_Message), START_ELEMENT_GENERIC] */ + decodeNBitUnsignedInteger(stream, 5, &state->eventCode); + if (state->eventCode == 0) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 1) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 2) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 3) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 4) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 5) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 6) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 7) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 8) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 9) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 10) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 11) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 12) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 13) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 14) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 15) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 16) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 17) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 18) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 19) { + *nextEvent = START_ELEMENT; + return 0; + } + else if (state->eventCode == 20) { + *nextEvent = START_ELEMENT_GENERIC; + return 0; + } + case 0: + /* Document[START_DOCUMENT] */ + *nextEvent = START_DOCUMENT; + return 0; + + default: + *nextEvent = ERROR; + return -1; + } + + return -1; +} + +int exiDecodeStartDocument(bitstream_t* stream, exi_state_t* state) { + if ( state->grammarStack[state->stackIndex] == 0 ) { + /* move on */ + state->grammarStack[state->stackIndex] = 1; + return 0; + } + + return -1; +} + +int exiDecodeEndDocument(bitstream_t* stream, exi_state_t* state) { + if ( state->grammarStack[state->stackIndex] == 2) { + return 0; + } + + return -1; +} + +static int _exiDecodeStartElement(exi_state_t* state, eqname_t* se, + uint16_t ns, uint16_t ln, uint16_t stackId, uint16_t newState) { + se->namespaceURI = ns; + se->localPart = ln; + /* move on */ + state->grammarStack[state->stackIndex] = stackId; + /* push element on stack */ + return exiPushStack(state, newState, se); +} + + +int exiDecodeStartElement(bitstream_t* stream, exi_state_t* state, + eqname_t* se) { + switch (state->grammarStack[state->stackIndex]) { + case 1: + /* DocContent[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}V2G_Message), START_ELEMENT_GENERIC] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 6, 2, 2, 3); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 10, 2, 5); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 4, 12, 2, 6); + } + else if (state->eventCode == 3) { + return _exiDecodeStartElement(state, se, 4, 15, 2, 7); + } + else if (state->eventCode == 4) { + return _exiDecodeStartElement(state, se, 4, 17, 2, 8); + } + else if (state->eventCode == 5) { + return _exiDecodeStartElement(state, se, 4, 19, 2, 9); + } + else if (state->eventCode == 6) { + return _exiDecodeStartElement(state, se, 4, 21, 2, 10); + } + else if (state->eventCode == 7) { + return _exiDecodeStartElement(state, se, 4, 30, 2, 11); + } + else if (state->eventCode == 8) { + return _exiDecodeStartElement(state, se, 4, 32, 2, 12); + } + else if (state->eventCode == 9) { + return _exiDecodeStartElement(state, se, 4, 34, 2, 13); + } + else if (state->eventCode == 10) { + return _exiDecodeStartElement(state, se, 4, 36, 2, 14); + } + else if (state->eventCode == 11) { + return _exiDecodeStartElement(state, se, 4, 38, 2, 15); + } + else if (state->eventCode == 12) { + return _exiDecodeStartElement(state, se, 4, 40, 2, 16); + } + else if (state->eventCode == 13) { + return _exiDecodeStartElement(state, se, 4, 45, 2, 17); + } + else if (state->eventCode == 14) { + return _exiDecodeStartElement(state, se, 4, 47, 2, 18); + } + else if (state->eventCode == 15) { + return _exiDecodeStartElement(state, se, 4, 50, 2, 19); + } + else if (state->eventCode == 16) { + return _exiDecodeStartElement(state, se, 4, 52, 2, 20); + } + else if (state->eventCode == 17) { + return _exiDecodeStartElement(state, se, 4, 56, 2, 21); + } + else if (state->eventCode == 18) { + return _exiDecodeStartElement(state, se, 4, 58, 2, 22); + } + else if (state->eventCode == 19) { + return _exiDecodeStartElement(state, se, 6, 5, 2, 23); + } + break; + case 5: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + return _exiDecodeStartElement(state, se, 4, 29, 24, 25); + break; + case 6: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 32, 33); + break; + case 7: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 24, 46, 47); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 29, 48, 25); + } + break; + case 8: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 67, 68); + break; + case 10: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 69, 70); + break; + case 11: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ContractID)] */ + return _exiDecodeStartElement(state, se, 4, 0, 78, 79); + break; + case 12: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 80, 81); + break; + case 13: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + return _exiDecodeStartElement(state, se, 4, 29, 82, 25); + break; + case 14: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 85, 86); + break; + case 15: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + return _exiDecodeStartElement(state, se, 4, 29, 87, 25); + break; + case 16: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 95, 96); + break; + case 17: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 55, 132, 133); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 54, 134, 135); + } + break; + case 18: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 136, 137); + break; + case 19: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList)] */ + return _exiDecodeStartElement(state, se, 4, 49, 155, 139); + break; + case 20: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 156, 157); + break; + case 21: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 24, 158, 47); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 29, 159, 25); + } + break; + case 22: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + return _exiDecodeStartElement(state, se, 4, 44, 160, 161); + break; + case 23: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Header)] */ + return _exiDecodeStartElement(state, se, 6, 4, 165, 166); + break; + case 24: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqLockStatus)] */ + return _exiDecodeStartElement(state, se, 4, 42, 26, 27); + break; + case 25: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + return _exiDecodeStartElement(state, se, 5, 4, 28, 27); + break; + case 28: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ChargerStandby)] */ + return _exiDecodeStartElement(state, se, 5, 0, 29, 30); + break; + case 32: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + return _exiDecodeStartElement(state, se, 4, 6, 34, 35); + break; + case 35: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FatalError)] */ + return _exiDecodeStartElement(state, se, 5, 12, 36, 37); + break; + case 36: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EVSEStandby)] */ + return _exiDecodeStartElement(state, se, 5, 7, 38, 30); + break; + case 38: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + return _exiDecodeStartElement(state, se, 5, 4, 39, 27); + break; + case 39: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}PowerSwitchClosed)] */ + return _exiDecodeStartElement(state, se, 5, 23, 40, 41); + break; + case 40: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}RCD)] */ + return _exiDecodeStartElement(state, se, 5, 25, 42, 43); + break; + case 42: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ShutDownTime)] */ + return _exiDecodeStartElement(state, se, 5, 36, 44, 45); + break; + case 46: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + return _exiDecodeStartElement(state, se, 4, 29, 48, 25); + break; + case 48: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 60, 49, 45); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 61, 50, 51); + } + break; + case 49: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + return _exiDecodeStartElement(state, se, 4, 61, 50, 51); + break; + case 50: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo)] */ + return _exiDecodeStartElement(state, se, 4, 14, 52, 53); + break; + case 53: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 16, 54, 55); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 18, 56, 57); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 5, 19, 58, 59); + } + else if (state->eventCode == 3) { + return _exiDecodeStartElement(state, se, 5, 37, 60, 45); + } + break; + case 54: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 18, 56, 57); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 19, 58, 59); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 5, 37, 60, 45); + } + break; + case 56: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 19, 58, 59); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 37, 60, 45); + } + break; + case 57: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Multiplier)] */ + return _exiDecodeStartElement(state, se, 5, 20, 61, 62); + break; + case 58: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 37, 60, 45); + } + break; + case 61: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Unit)] */ + return _exiDecodeStartElement(state, se, 5, 49, 63, 64); + break; + case 63: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Value)] */ + return _exiDecodeStartElement(state, se, 5, 50, 65, 66); + break; + case 69: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + return _exiDecodeStartElement(state, se, 4, 2, 71, 72); + break; + case 71: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + return _exiDecodeStartElement(state, se, 4, 6, 73, 35); + break; + case 73: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + return _exiDecodeStartElement(state, se, 4, 60, 74, 45); + break; + case 74: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPower)] */ + return _exiDecodeStartElement(state, se, 4, 5, 75, 57); + break; + case 75: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 23, 76, 57); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 14, 77, 53); + } + break; + case 76: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 14, 77, 53); + } + break; + case 82: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqSwitchStatus)] */ + return _exiDecodeStartElement(state, se, 4, 43, 83, 41); + break; + case 83: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 61, 84, 51); + } + break; + case 87: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EoC)] */ + return _exiDecodeStartElement(state, se, 4, 9, 88, 45); + break; + case 88: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EAmount)] */ + return _exiDecodeStartElement(state, se, 4, 1, 89, 57); + break; + case 89: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPower)] */ + return _exiDecodeStartElement(state, se, 4, 26, 90, 57); + break; + case 90: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPhases)] */ + return _exiDecodeStartElement(state, se, 4, 25, 91, 92); + break; + case 91: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxVoltage)] */ + return _exiDecodeStartElement(state, se, 4, 27, 93, 57); + break; + case 93: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMinVoltage)] */ + return _exiDecodeStartElement(state, se, 4, 28, 94, 57); + break; + case 95: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + return _exiDecodeStartElement(state, se, 4, 6, 97, 35); + break; + case 97: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEVoltage)] */ + return _exiDecodeStartElement(state, se, 4, 7, 98, 57); + break; + case 98: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEIMax)] */ + return _exiDecodeStartElement(state, se, 4, 3, 99, 57); + break; + case 99: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPhases)] */ + return _exiDecodeStartElement(state, se, 4, 4, 100, 92); + break; + case 100: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EnergyProvider), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 8, 101, 102); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 62, 103, 104); + } + break; + case 101: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 62, 103, 104); + } + break; + case 104: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Currency)] */ + return _exiDecodeStartElement(state, se, 5, 5, 105, 106); + break; + case 105: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff)] */ + return _exiDecodeStartElement(state, se, 5, 38, 107, 108); + break; + case 107: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 38, 109, 108); + } + break; + case 108: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffID)] */ + return _exiDecodeStartElement(state, se, 5, 45, 114, 51); + break; + case 109: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 38, 110, 108); + } + break; + case 110: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 38, 111, 108); + } + break; + case 111: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 38, 112, 108); + } + break; + case 112: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 38, 113, 108); + } + break; + case 114: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffDescription), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 40, 115, 116); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 41, 117, 118); + } + break; + case 115: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + return _exiDecodeStartElement(state, se, 5, 41, 117, 118); + break; + case 118: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry)] */ + return _exiDecodeStartElement(state, se, 5, 43, 119, 120); + break; + case 119: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 121, 120); + } + break; + case 120: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffStart)] */ + return _exiDecodeStartElement(state, se, 5, 47, 128, 129); + break; + case 121: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 122, 120); + } + break; + case 122: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 123, 120); + } + break; + case 123: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 124, 120); + } + break; + case 124: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 125, 120); + } + break; + case 125: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 126, 120); + } + break; + case 126: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 43, 127, 120); + } + break; + case 128: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffPMax)] */ + return _exiDecodeStartElement(state, se, 5, 46, 130, 57); + break; + case 130: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EPrice), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 6, 131, 57); + } + break; + case 132: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 54, 134, 135); + } + break; + case 136: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 4, 49, 138, 139); + } + break; + case 139: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service)] */ + return _exiDecodeStartElement(state, se, 5, 26, 140, 141); + break; + case 140: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 142, 141); + } + break; + case 141: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceID)] */ + return _exiDecodeStartElement(state, se, 5, 28, 149, 150); + break; + case 142: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 143, 141); + } + break; + case 143: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 144, 141); + } + break; + case 144: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 145, 141); + } + break; + case 145: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 146, 141); + } + break; + case 146: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 147, 141); + } + break; + case 147: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 26, 148, 141); + } + break; + case 149: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 30, 151, 152); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 33, 153, 133); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 5, 31, 154, 135); + } + break; + case 151: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 33, 153, 133); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 31, 154, 135); + } + break; + case 153: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 31, 154, 135); + } + break; + case 158: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + return _exiDecodeStartElement(state, se, 4, 29, 159, 25); + break; + case 160: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + return _exiDecodeStartElement(state, se, 4, 2, 162, 72); + break; + case 162: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + return _exiDecodeStartElement(state, se, 4, 6, 163, 35); + break; + case 163: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + return _exiDecodeStartElement(state, se, 4, 60, 164, 45); + break; + case 165: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Body)] */ + return _exiDecodeStartElement(state, se, 6, 0, 167, 168); + break; + case 166: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}SessionInformation)] */ + return _exiDecodeStartElement(state, se, 7, 2, 169, 170); + break; + case 168: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 6, 2, 186, 3); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 4, 10, 186, 5); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 4, 12, 186, 6); + } + else if (state->eventCode == 3) { + return _exiDecodeStartElement(state, se, 4, 15, 186, 7); + } + else if (state->eventCode == 4) { + return _exiDecodeStartElement(state, se, 4, 17, 186, 8); + } + else if (state->eventCode == 5) { + return _exiDecodeStartElement(state, se, 4, 19, 186, 9); + } + else if (state->eventCode == 6) { + return _exiDecodeStartElement(state, se, 4, 21, 186, 10); + } + else if (state->eventCode == 7) { + return _exiDecodeStartElement(state, se, 4, 30, 186, 11); + } + else if (state->eventCode == 8) { + return _exiDecodeStartElement(state, se, 4, 32, 186, 12); + } + else if (state->eventCode == 9) { + return _exiDecodeStartElement(state, se, 4, 34, 186, 13); + } + else if (state->eventCode == 10) { + return _exiDecodeStartElement(state, se, 4, 36, 186, 14); + } + else if (state->eventCode == 11) { + return _exiDecodeStartElement(state, se, 4, 38, 186, 15); + } + else if (state->eventCode == 12) { + return _exiDecodeStartElement(state, se, 4, 40, 186, 16); + } + else if (state->eventCode == 13) { + return _exiDecodeStartElement(state, se, 4, 45, 186, 17); + } + else if (state->eventCode == 14) { + return _exiDecodeStartElement(state, se, 4, 47, 186, 18); + } + else if (state->eventCode == 15) { + return _exiDecodeStartElement(state, se, 4, 50, 186, 19); + } + else if (state->eventCode == 16) { + return _exiDecodeStartElement(state, se, 4, 52, 186, 20); + } + else if (state->eventCode == 17) { + return _exiDecodeStartElement(state, se, 4, 56, 186, 21); + } + else if (state->eventCode == 18) { + return _exiDecodeStartElement(state, se, 4, 58, 186, 22); + } + break; + case 169: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}Notification), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 7, 1, 171, 172); + } + break; + case 170: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}SessionID)] */ + return _exiDecodeStartElement(state, se, 5, 34, 173, 174); + break; + case 172: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 13, 178, 179); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 14, 180, 181); + } + else if (state->eventCode == 2) { + return _exiDecodeStartElement(state, se, 5, 10, 182, 183); + } + break; + case 173: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceSessionID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 32, 175, 174); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 24, 176, 177); + } + break; + case 175: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 24, 176, 177); + } + break; + case 178: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 14, 180, 181); + } + else if (state->eventCode == 1) { + return _exiDecodeStartElement(state, se, 5, 10, 182, 183); + } + break; + case 180: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if (state->eventCode == 0) { + return _exiDecodeStartElement(state, se, 5, 10, 182, 183); + } + break; + case 183: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Event)] */ + return _exiDecodeStartElement(state, se, 5, 9, 184, 185); + break; + + default: + return -1; + } + + return -1; +} + +int exiDecodeStartElementGeneric(bitstream_t* stream, exi_state_t* state, + eqname_t* se) { + switch (state->grammarStack[state->stackIndex]) { +/* $EXI_DECODE_START_ELEMENT_GENERIC$ */ + default: + return -1; + } + + return -1; +} + +int exiDecodeEndElement(bitstream_t* stream, exi_state_t* state, + eqname_t* ee) { + /* pop item and update ahead of time element qname */ + ee->localPart = state->elementStack[state->stackIndex].localPart; + ee->namespaceURI = state->elementStack[state->stackIndex].namespaceURI; + return exiPopStack(state); +} + +int exiDecodeCharacters(bitstream_t* stream, exi_state_t* state, + exi_value_t* val) { + uint32_t xsi; + uint32_t bits; + switch (state->grammarStack[state->stackIndex]) { + case 62: + /* CHARACTERS[ENUMERATION] */ + val->type = ENUMERATION; + decodeNBitUnsignedInteger(stream, 4, &val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 27: + /* CHARACTERS[BOOLEAN] */ + case 30: + /* CHARACTERS[BOOLEAN] */ + case 37: + /* CHARACTERS[BOOLEAN] */ + case 41: + /* CHARACTERS[BOOLEAN] */ + case 43: + /* CHARACTERS[BOOLEAN] */ + val->type = BOOLEAN; + decodeBoolean(stream, &val->boolean); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 47: + /* CHARACTERS[STRING] */ + case 55: + /* CHARACTERS[STRING] */ + case 79: + /* CHARACTERS[STRING] */ + case 102: + /* CHARACTERS[STRING] */ + case 106: + /* CHARACTERS[STRING] */ + case 116: + /* CHARACTERS[STRING] */ + case 135: + /* CHARACTERS[STRING] */ + case 152: + /* CHARACTERS[STRING] */ + case 177: + /* CHARACTERS[STRING] */ + val->type = STRING; + decodeStringValue(stream, &val->string); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 68: + /* CHARACTERS[ENUMERATION] */ + case 70: + /* CHARACTERS[ENUMERATION] */ + case 96: + /* CHARACTERS[ENUMERATION] */ + val->type = ENUMERATION; + decodeNBitUnsignedInteger(stream, 1, &val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 33: + /* CHARACTERS[ENUMERATION] */ + case 81: + /* CHARACTERS[ENUMERATION] */ + case 133: + /* CHARACTERS[ENUMERATION] */ + case 157: + /* CHARACTERS[ENUMERATION] */ + case 179: + /* CHARACTERS[ENUMERATION] */ + val->type = ENUMERATION; + decodeNBitUnsignedInteger(stream, 2, &val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 72: + /* CHARACTERS[BINARY_HEX] */ + case 150: + /* CHARACTERS[BINARY_HEX] */ + case 174: + /* CHARACTERS[BINARY_HEX] */ + val->type = BINARY_HEX; + decodeBinary(stream, &val->binary); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 181: + /* CHARACTERS[STRING] */ + /* xsi:type OR xsi:nil */ + decodeNBitUnsignedInteger(stream, 1, &xsi); + val->type = STRING; + decodeStringValue(stream, &val->string); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 66: + /* CHARACTERS[INTEGER_32] */ + /* xsi:type OR xsi:nil */ + decodeNBitUnsignedInteger(stream, 1, &xsi); + val->type = INTEGER_32; + decodeInteger32(stream, &val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 51: + /* CHARACTERS[ENUMERATION] */ + case 86: + /* CHARACTERS[ENUMERATION] */ + case 137: + /* CHARACTERS[ENUMERATION] */ + case 161: + /* CHARACTERS[ENUMERATION] */ + case 185: + /* CHARACTERS[ENUMERATION] */ + val->type = ENUMERATION; + decodeNBitUnsignedInteger(stream, 3, &val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 59: + /* CHARACTERS[INTEGER_16] */ + case 92: + /* CHARACTERS[INTEGER_16] */ + val->type = INTEGER_16; + decodeInteger32(stream, &val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 45: + /* CHARACTERS[INTEGER_32] */ + val->type = INTEGER_32; + decodeInteger32(stream, &val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 64: + /* CHARACTERS[ENUMERATION] */ + val->type = ENUMERATION; + decodeNBitUnsignedInteger(stream, 5, &val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + case 129: + /* CHARACTERS[UNSIGNED_INTEGER_32] */ + val->type = UNSIGNED_INTEGER_32; + decodeUnsignedInteger32(stream, &val->uint32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + + default: + return -1; + } + + return 0; +} + +int exiDecodeAttribute(bitstream_t* stream, exi_state_t* state, + eqname_t* at, exi_value_t* val) { + switch (state->grammarStack[state->stackIndex]) { + + default: + return -1; + } + return -1; +} + + + +#endif + diff --git a/src/codec/EXIDecoder.h b/src/codec/EXIDecoder.h new file mode 100644 index 0000000..db000d4 --- /dev/null +++ b/src/codec/EXIDecoder.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#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); + +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, + eqname_t* se); + +int exiDecodeEndElement(bitstream_t* stream, exi_state_t* state, + eqname_t* ee); + +int exiDecodeCharacters(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); + +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/codec/EXIEncoder.c b/src/codec/EXIEncoder.c new file mode 100644 index 0000000..730a88e --- /dev/null +++ b/src/codec/EXIEncoder.c @@ -0,0 +1,1442 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + *

NOTE: Code generated by EXIdizer v0.1

+ ********************************************************************/ + +#ifndef EXI_ENCODER_C +#define EXI_ENCODER_C + +#include +#include +#include +#include + +#include "EXITypes.h" +#include "BitOutputStream.h" +#include "BitEncoderChannel.h" + +#include "EXICoder.h" +#include "EXIHeaderEncoder.h" + +/* ==================================== */ + +int exiInitEncoder(bitstream_t* stream, exi_state_t* state) { + /* init grammar state */ + state->stackIndex = 0; + state->grammarStack[0] = 0; + /* encode header */ + return writeEXIHeader(stream); +} + +int exiEncodeStartDocument(bitstream_t* stream, exi_state_t* state) { + if ( state->grammarStack[state->stackIndex] == 0 ) { + /* move on */ + state->grammarStack[state->stackIndex] = 1; + return 0; + } + + return -1; +} + +int exiEncodeEndDocument(bitstream_t* stream, exi_state_t* state) { + if ( state->grammarStack[state->stackIndex] == 2) { + encodeFinish(stream); + return 0; + } + + return -1; +} + +static int _exiEncodeStartElement(bitstream_t* stream, uint16_t nbits, uint32_t val, + exi_state_t* state, eqname_t* se, uint16_t stackId, uint16_t newState) { + int errn = encodeNBitUnsignedInteger(stream, nbits, val); + if (errn) { + return errn; + } + /* move on */ + state->grammarStack[state->stackIndex] = stackId; + /* push element on stack */ + return exiPushStack(state, newState, se); +} + +int exiEncodeStartElement(bitstream_t* stream, exi_state_t* state, + eqname_t* se) { + switch (state->grammarStack[state->stackIndex]) { + case 1: + /* DocContent[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}V2G_Message), START_ELEMENT_GENERIC] */ + if ( se->localPart == 2 && se->namespaceURI == 6 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement) */ + return _exiEncodeStartElement(stream, 5, 0, state, se, 2, 3); + } + else if ( se->localPart == 10 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq) */ + return _exiEncodeStartElement(stream, 5, 1, state, se, 2, 5); + } + else if ( se->localPart == 12 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes) */ + return _exiEncodeStartElement(stream, 5, 2, state, se, 2, 6); + } + else if ( se->localPart == 15 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq) */ + return _exiEncodeStartElement(stream, 5, 3, state, se, 2, 7); + } + else if ( se->localPart == 17 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes) */ + return _exiEncodeStartElement(stream, 5, 4, state, se, 2, 8); + } + else if ( se->localPart == 19 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq) */ + return _exiEncodeStartElement(stream, 5, 5, state, se, 2, 9); + } + else if ( se->localPart == 21 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes) */ + return _exiEncodeStartElement(stream, 5, 6, state, se, 2, 10); + } + else if ( se->localPart == 30 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq) */ + return _exiEncodeStartElement(stream, 5, 7, state, se, 2, 11); + } + else if ( se->localPart == 32 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes) */ + return _exiEncodeStartElement(stream, 5, 8, state, se, 2, 12); + } + else if ( se->localPart == 34 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq) */ + return _exiEncodeStartElement(stream, 5, 9, state, se, 2, 13); + } + else if ( se->localPart == 36 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes) */ + return _exiEncodeStartElement(stream, 5, 10, state, se, 2, 14); + } + else if ( se->localPart == 38 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq) */ + return _exiEncodeStartElement(stream, 5, 11, state, se, 2, 15); + } + else if ( se->localPart == 40 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes) */ + return _exiEncodeStartElement(stream, 5, 12, state, se, 2, 16); + } + else if ( se->localPart == 45 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq) */ + return _exiEncodeStartElement(stream, 5, 13, state, se, 2, 17); + } + else if ( se->localPart == 47 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes) */ + return _exiEncodeStartElement(stream, 5, 14, state, se, 2, 18); + } + else if ( se->localPart == 50 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq) */ + return _exiEncodeStartElement(stream, 5, 15, state, se, 2, 19); + } + else if ( se->localPart == 52 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes) */ + return _exiEncodeStartElement(stream, 5, 16, state, se, 2, 20); + } + else if ( se->localPart == 56 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq) */ + return _exiEncodeStartElement(stream, 5, 17, state, se, 2, 21); + } + else if ( se->localPart == 58 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes) */ + return _exiEncodeStartElement(stream, 5, 18, state, se, 2, 22); + } + else if ( se->localPart == 5 && se->namespaceURI == 6 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}V2G_Message) */ + return _exiEncodeStartElement(stream, 5, 19, state, se, 2, 23); + } + break; + case 5: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 24, 25); + } + break; + case 6: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 32, 33); + } + break; + case 7: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 24 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 46, 47); + } + else if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 1, 1, state, se, 48, 25); + } + break; + case 8: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 67, 68); + } + break; + case 10: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 69, 70); + } + break; + case 11: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ContractID)] */ + if ( se->localPart == 0 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ContractID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 78, 79); + } + break; + case 12: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 80, 81); + } + break; + case 13: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 82, 25); + } + break; + case 14: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 85, 86); + } + break; + case 15: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 87, 25); + } + break; + case 16: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 95, 96); + } + break; + case 17: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + if ( se->localPart == 55 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceType) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 132, 133); + } + else if ( se->localPart == 54 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 134, 135); + } + break; + case 18: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 136, 137); + } + break; + case 19: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList)] */ + if ( se->localPart == 49 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 155, 139); + } + break; + case 20: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 156, 157); + } + break; + case 21: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 24 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVID) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 158, 47); + } + else if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 1, 1, state, se, 159, 25); + } + break; + case 22: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode)] */ + if ( se->localPart == 44 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ResponseCode) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 160, 161); + } + break; + case 23: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Header)] */ + if ( se->localPart == 4 && se->namespaceURI == 6 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Header) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 165, 166); + } + break; + case 24: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqLockStatus)] */ + if ( se->localPart == 42 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqLockStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 26, 27); + } + break; + case 25: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + if ( se->localPart == 4 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 28, 27); + } + break; + case 28: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ChargerStandby)] */ + if ( se->localPart == 0 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ChargerStandby) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 29, 30); + } + break; + case 32: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + if ( se->localPart == 6 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 34, 35); + } + break; + case 35: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FatalError)] */ + if ( se->localPart == 12 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FatalError) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 36, 37); + } + break; + case 36: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EVSEStandby)] */ + if ( se->localPart == 7 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EVSEStandby) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 38, 30); + } + break; + case 38: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked)] */ + if ( se->localPart == 4 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ConnectorLocked) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 39, 27); + } + break; + case 39: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}PowerSwitchClosed)] */ + if ( se->localPart == 23 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}PowerSwitchClosed) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 40, 41); + } + break; + case 40: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}RCD)] */ + if ( se->localPart == 25 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}RCD) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 42, 43); + } + break; + case 42: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ShutDownTime)] */ + if ( se->localPart == 36 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ShutDownTime) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 44, 45); + } + break; + case 46: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 48, 25); + } + break; + case 48: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + if ( se->localPart == 60 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 49, 45); + } + else if ( se->localPart == 61 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff) */ + return _exiEncodeStartElement(stream, 1, 1, state, se, 50, 51); + } + break; + case 49: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff)] */ + if ( se->localPart == 61 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 50, 51); + } + break; + case 50: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo)] */ + if ( se->localPart == 14 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 52, 53); + } + break; + case 53: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if ( se->localPart == 16 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterID) */ + return _exiEncodeStartElement(stream, 3, 0, state, se, 54, 55); + } + else if ( se->localPart == 18 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading) */ + return _exiEncodeStartElement(stream, 3, 1, state, se, 56, 57); + } + else if ( se->localPart == 19 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus) */ + return _exiEncodeStartElement(stream, 3, 2, state, se, 58, 59); + } + else if ( se->localPart == 37 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter) */ + return _exiEncodeStartElement(stream, 3, 3, state, se, 60, 45); + } + break; + case 54: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if ( se->localPart == 18 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 56, 57); + } + else if ( se->localPart == 19 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 58, 59); + } + else if ( se->localPart == 37 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter) */ + return _exiEncodeStartElement(stream, 2, 2, state, se, 60, 45); + } + break; + case 56: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if ( se->localPart == 19 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 58, 59); + } + else if ( se->localPart == 37 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 60, 45); + } + break; + case 57: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Multiplier)] */ + if ( se->localPart == 20 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Multiplier) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 61, 62); + } + break; + case 58: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + if ( se->localPart == 37 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 60, 45); + } + break; + case 61: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Unit)] */ + if ( se->localPart == 49 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Unit) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 63, 64); + } + break; + case 63: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Value)] */ + if ( se->localPart == 50 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Value) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 65, 66); + } + break; + case 69: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + if ( se->localPart == 2 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 71, 72); + } + break; + case 71: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + if ( se->localPart == 6 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 73, 35); + } + break; + case 73: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + if ( se->localPart == 60 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 74, 45); + } + break; + case 74: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPower)] */ + if ( se->localPart == 5 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPower) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 75, 57); + } + break; + case 75: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + if ( se->localPart == 23 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PCurrent) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 76, 57); + } + else if ( se->localPart == 14 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 77, 53); + } + break; + case 76: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + if ( se->localPart == 14 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 77, 53); + } + break; + case 82: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqSwitchStatus)] */ + if ( se->localPart == 43 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ReqSwitchStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 83, 41); + } + break; + case 83: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff), END_ELEMENT] */ + if ( se->localPart == 61 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 84, 51); + } + break; + case 87: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EoC)] */ + if ( se->localPart == 9 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EoC) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 88, 45); + } + break; + case 88: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EAmount)] */ + if ( se->localPart == 1 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EAmount) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 89, 57); + } + break; + case 89: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPower)] */ + if ( se->localPart == 26 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPower) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 90, 57); + } + break; + case 90: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPhases)] */ + if ( se->localPart == 25 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxPhases) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 91, 92); + } + break; + case 91: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxVoltage)] */ + if ( se->localPart == 27 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMaxVoltage) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 93, 57); + } + break; + case 93: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMinVoltage)] */ + if ( se->localPart == 28 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVMinVoltage) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 94, 57); + } + break; + case 95: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + if ( se->localPart == 6 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 97, 35); + } + break; + case 97: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEVoltage)] */ + if ( se->localPart == 7 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEVoltage) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 98, 57); + } + break; + case 98: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEIMax)] */ + if ( se->localPart == 3 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEIMax) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 99, 57); + } + break; + case 99: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPhases)] */ + if ( se->localPart == 4 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEMaxPhases) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 100, 92); + } + break; + case 100: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EnergyProvider), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + if ( se->localPart == 8 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EnergyProvider) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 101, 102); + } + else if ( se->localPart == 62 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 103, 104); + } + break; + case 101: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + if ( se->localPart == 62 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 103, 104); + } + break; + case 104: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Currency)] */ + if ( se->localPart == 5 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Currency) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 105, 106); + } + break; + case 105: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff)] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 107, 108); + } + break; + case 107: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 109, 108); + } + break; + case 108: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffID)] */ + if ( se->localPart == 45 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 114, 51); + } + break; + case 109: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 110, 108); + } + break; + case 110: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 111, 108); + } + break; + case 111: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 112, 108); + } + break; + case 112: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + if ( se->localPart == 38 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 113, 108); + } + break; + case 114: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffDescription), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + if ( se->localPart == 40 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffDescription) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 115, 116); + } + else if ( se->localPart == 41 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries) */ + return _exiEncodeStartElement(stream, 1, 1, state, se, 117, 118); + } + break; + case 115: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries)] */ + if ( se->localPart == 41 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntries) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 117, 118); + } + break; + case 118: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry)] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 119, 120); + } + break; + case 119: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 121, 120); + } + break; + case 120: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffStart)] */ + if ( se->localPart == 47 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffStart) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 128, 129); + } + break; + case 121: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 122, 120); + } + break; + case 122: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 123, 120); + } + break; + case 123: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 124, 120); + } + break; + case 124: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 125, 120); + } + break; + case 125: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 126, 120); + } + break; + case 126: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + if ( se->localPart == 43 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 127, 120); + } + break; + case 128: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffPMax)] */ + if ( se->localPart == 46 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffPMax) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 130, 57); + } + break; + case 130: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EPrice), END_ELEMENT] */ + if ( se->localPart == 6 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EPrice) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 131, 57); + } + break; + case 132: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + if ( se->localPart == 54 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 134, 135); + } + break; + case 136: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList), END_ELEMENT] */ + if ( se->localPart == 49 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 138, 139); + } + break; + case 139: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service)] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 140, 141); + } + break; + case 140: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 142, 141); + } + break; + case 141: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceID)] */ + if ( se->localPart == 28 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 149, 150); + } + break; + case 142: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 143, 141); + } + break; + case 143: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 144, 141); + } + break; + case 144: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 145, 141); + } + break; + case 145: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 146, 141); + } + break; + case 146: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 147, 141); + } + break; + case 147: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + if ( se->localPart == 26 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 148, 141); + } + break; + case 149: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if ( se->localPart == 30 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceName) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 151, 152); + } + else if ( se->localPart == 33 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 153, 133); + } + else if ( se->localPart == 31 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope) */ + return _exiEncodeStartElement(stream, 2, 2, state, se, 154, 135); + } + break; + case 151: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if ( se->localPart == 33 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 153, 133); + } + else if ( se->localPart == 31 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 154, 135); + } + break; + case 153: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + if ( se->localPart == 31 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 154, 135); + } + break; + case 158: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus)] */ + if ( se->localPart == 29 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PEVStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 159, 25); + } + break; + case 160: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID)] */ + if ( se->localPart == 2 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 162, 72); + } + break; + case 162: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus)] */ + if ( se->localPart == 6 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EVSEStatus) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 163, 35); + } + break; + case 163: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent)] */ + if ( se->localPart == 60 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TCurrent) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 164, 45); + } + break; + case 165: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Body)] */ + if ( se->localPart == 0 && se->namespaceURI == 6 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}Body) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 167, 168); + } + break; + case 166: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}SessionInformation)] */ + if ( se->localPart == 2 && se->namespaceURI == 7 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}SessionInformation) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 169, 170); + } + break; + case 168: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), END_ELEMENT] */ + if ( se->localPart == 2 && se->namespaceURI == 6 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement) */ + return _exiEncodeStartElement(stream, 5, 0, state, se, 186, 3); + } + else if ( se->localPart == 10 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq) */ + return _exiEncodeStartElement(stream, 5, 1, state, se, 186, 5); + } + else if ( se->localPart == 12 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes) */ + return _exiEncodeStartElement(stream, 5, 2, state, se, 186, 6); + } + else if ( se->localPart == 15 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq) */ + return _exiEncodeStartElement(stream, 5, 3, state, se, 186, 7); + } + else if ( se->localPart == 17 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes) */ + return _exiEncodeStartElement(stream, 5, 4, state, se, 186, 8); + } + else if ( se->localPart == 19 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq) */ + return _exiEncodeStartElement(stream, 5, 5, state, se, 186, 9); + } + else if ( se->localPart == 21 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes) */ + return _exiEncodeStartElement(stream, 5, 6, state, se, 186, 10); + } + else if ( se->localPart == 30 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq) */ + return _exiEncodeStartElement(stream, 5, 7, state, se, 186, 11); + } + else if ( se->localPart == 32 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes) */ + return _exiEncodeStartElement(stream, 5, 8, state, se, 186, 12); + } + else if ( se->localPart == 34 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq) */ + return _exiEncodeStartElement(stream, 5, 9, state, se, 186, 13); + } + else if ( se->localPart == 36 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes) */ + return _exiEncodeStartElement(stream, 5, 10, state, se, 186, 14); + } + else if ( se->localPart == 38 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq) */ + return _exiEncodeStartElement(stream, 5, 11, state, se, 186, 15); + } + else if ( se->localPart == 40 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes) */ + return _exiEncodeStartElement(stream, 5, 12, state, se, 186, 16); + } + else if ( se->localPart == 45 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq) */ + return _exiEncodeStartElement(stream, 5, 13, state, se, 186, 17); + } + else if ( se->localPart == 47 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes) */ + return _exiEncodeStartElement(stream, 5, 14, state, se, 186, 18); + } + else if ( se->localPart == 50 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq) */ + return _exiEncodeStartElement(stream, 5, 15, state, se, 186, 19); + } + else if ( se->localPart == 52 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes) */ + return _exiEncodeStartElement(stream, 5, 16, state, se, 186, 20); + } + else if ( se->localPart == 56 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq) */ + return _exiEncodeStartElement(stream, 5, 17, state, se, 186, 21); + } + else if ( se->localPart == 58 && se->namespaceURI == 4 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes) */ + return _exiEncodeStartElement(stream, 5, 18, state, se, 186, 22); + } + break; + case 169: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}Notification), END_ELEMENT] */ + if ( se->localPart == 1 && se->namespaceURI == 7 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}Notification) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 171, 172); + } + break; + case 170: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}SessionID)] */ + if ( se->localPart == 34 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}SessionID) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 173, 174); + } + break; + case 172: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if ( se->localPart == 13 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultCode) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 178, 179); + } + else if ( se->localPart == 14 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 180, 181); + } + else if ( se->localPart == 10 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList) */ + return _exiEncodeStartElement(stream, 2, 2, state, se, 182, 183); + } + break; + case 173: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceSessionID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + if ( se->localPart == 32 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceSessionID) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 175, 174); + } + else if ( se->localPart == 24 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 176, 177); + } + break; + case 175: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + if ( se->localPart == 24 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 176, 177); + } + break; + case 178: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if ( se->localPart == 14 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg) */ + return _exiEncodeStartElement(stream, 2, 0, state, se, 180, 181); + } + else if ( se->localPart == 10 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList) */ + return _exiEncodeStartElement(stream, 2, 1, state, se, 182, 183); + } + break; + case 180: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + if ( se->localPart == 10 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList) */ + return _exiEncodeStartElement(stream, 1, 0, state, se, 182, 183); + } + break; + case 183: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Event)] */ + if ( se->localPart == 9 && se->namespaceURI == 5 ) { + /* START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Event) */ + return _exiEncodeStartElement(stream, 0, 0, state, se, 184, 185); + } + break; + + default: + return -1; + } + + return -1; +} + +int exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, + eqname_t* ee) { + switch (state->grammarStack[state->stackIndex]) { + case 53: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + encodeNBitUnsignedInteger(stream, 3, 4); + break; + case 3: + /* First(xsi:type)StartTag[END_ELEMENT] */ + case 26: + /* Element[END_ELEMENT] */ + case 29: + /* Element[END_ELEMENT] */ + case 31: + /* Element[END_ELEMENT] */ + case 34: + /* Element[END_ELEMENT] */ + case 44: + /* Element[END_ELEMENT] */ + case 52: + /* Element[END_ELEMENT] */ + case 60: + /* Element[END_ELEMENT] */ + case 65: + /* Element[END_ELEMENT] */ + case 67: + /* Element[END_ELEMENT] */ + case 9: + /* FirstStartTag[END_ELEMENT] */ + case 77: + /* Element[END_ELEMENT] */ + case 78: + /* Element[END_ELEMENT] */ + case 80: + /* Element[END_ELEMENT] */ + case 84: + /* Element[END_ELEMENT] */ + case 85: + /* Element[END_ELEMENT] */ + case 94: + /* Element[END_ELEMENT] */ + case 103: + /* Element[END_ELEMENT] */ + case 113: + /* Element[END_ELEMENT] */ + case 117: + /* Element[END_ELEMENT] */ + case 127: + /* Element[END_ELEMENT] */ + case 131: + /* Element[END_ELEMENT] */ + case 134: + /* Element[END_ELEMENT] */ + case 138: + /* Element[END_ELEMENT] */ + case 148: + /* Element[END_ELEMENT] */ + case 154: + /* Element[END_ELEMENT] */ + case 155: + /* Element[END_ELEMENT] */ + case 156: + /* Element[END_ELEMENT] */ + case 159: + /* Element[END_ELEMENT] */ + case 164: + /* Element[END_ELEMENT] */ + case 167: + /* Element[END_ELEMENT] */ + case 171: + /* Element[END_ELEMENT] */ + case 176: + /* Element[END_ELEMENT] */ + case 182: + /* Element[END_ELEMENT] */ + case 184: + /* Element[END_ELEMENT] */ + case 186: + /* Element[END_ELEMENT] */ + break; + case 54: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 149: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 172: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + encodeNBitUnsignedInteger(stream, 2, 3); + break; + case 168: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}LineLockRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeteringStatusRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PowerDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}SessionSetupRes), END_ELEMENT] */ + encodeNBitUnsignedInteger(stream, 5, 19); + break; + case 58: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 76: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + case 83: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}Tariff), END_ELEMENT] */ + case 101: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + case 112: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 111: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 110: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 109: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 107: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Tariff), END_ELEMENT] */ + case 126: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 125: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 124: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 123: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 122: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 121: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 119: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TariffEntry), END_ELEMENT] */ + case 130: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EPrice), END_ELEMENT] */ + case 132: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + case 136: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceList), END_ELEMENT] */ + case 147: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 146: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 145: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 144: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 143: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 142: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 140: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}Service), END_ELEMENT] */ + case 153: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 169: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgHeader}Notification), END_ELEMENT] */ + case 175: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + case 180: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + encodeNBitUnsignedInteger(stream, 1, 1); + break; + case 56: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}TMeter), END_ELEMENT] */ + case 75: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}PCurrent), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}MeterInfo), END_ELEMENT] */ + case 100: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}EnergyProvider), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}TariffTable), END_ELEMENT] */ + case 17: + /* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgBody}ServiceScope), END_ELEMENT] */ + case 151: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceType), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceScope), END_ELEMENT] */ + case 173: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ServiceSessionID), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}ProtocolVersion), END_ELEMENT] */ + case 178: + /* Element[START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:eval1.0:MsgDataTypes}EventList), END_ELEMENT] */ + encodeNBitUnsignedInteger(stream, 2, 2); + break; + + default: + return -1; + } + + /* pop item */ + return exiPopStack(state); +} + +int exiEncodeCharacters(bitstream_t* stream, exi_state_t* state, + exi_value_t* val) { + uint32_t bits; + switch (state->grammarStack[state->stackIndex]) { + case 33: + case 81: + case 133: + case 157: + case 179: + /* CHARACTERS[ENUMERATION] */ + if (val->type == ENUMERATION) { + encodeNBitUnsignedInteger(stream, 2, val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 72: + case 150: + case 174: + /* CHARACTERS[BINARY_HEX] */ + if (val->type == BINARY_HEX) { + encodeBinary(stream, &val->binary); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 66: + /* CHARACTERS[INTEGER_32] */ + /* xsi:type OR xsi:nil */ + encodeNBitUnsignedInteger(stream, 1, 0); + if (val->type == INTEGER_32) { + encodeInteger32(stream, val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 181: + /* CHARACTERS[STRING] */ + /* xsi:type OR xsi:nil */ + encodeNBitUnsignedInteger(stream, 1, 0); + if (val->type == STRING) { + encodeStringValue(stream, &val->string); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 27: + case 30: + case 37: + case 41: + case 43: + /* CHARACTERS[BOOLEAN] */ + if (val->type == BOOLEAN) { + encodeBoolean(stream, val->boolean); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 59: + case 92: + /* CHARACTERS[INTEGER_16] */ + if (val->type == INTEGER_16) { + encodeInteger32(stream, val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 129: + /* CHARACTERS[UNSIGNED_INTEGER_32] */ + if (val->type == UNSIGNED_INTEGER_32) { + encodeUnsignedInteger32(stream, val->uint32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 47: + case 55: + case 79: + case 102: + case 106: + case 116: + case 135: + case 152: + case 177: + /* CHARACTERS[STRING] */ + if (val->type == STRING) { + encodeStringValue(stream, &val->string); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 62: + /* CHARACTERS[ENUMERATION] */ + if (val->type == ENUMERATION) { + encodeNBitUnsignedInteger(stream, 4, val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 51: + case 86: + case 137: + case 161: + case 185: + /* CHARACTERS[ENUMERATION] */ + if (val->type == ENUMERATION) { + encodeNBitUnsignedInteger(stream, 3, val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 45: + /* CHARACTERS[INTEGER_32] */ + if (val->type == INTEGER_32) { + encodeInteger32(stream, val->int32); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 64: + /* CHARACTERS[ENUMERATION] */ + if (val->type == ENUMERATION) { + encodeNBitUnsignedInteger(stream, 5, val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + case 68: + case 70: + case 96: + /* CHARACTERS[ENUMERATION] */ + if (val->type == ENUMERATION) { + encodeNBitUnsignedInteger(stream, 1, val->enumeration); + /* move on */ + state->grammarStack[state->stackIndex] = 31; + return 0; + } + break; + + default: + return -1; + } + + return -1; +} + +int exiEncodeAttribute(bitstream_t* stream, exi_state_t* state, + eqname_t* at, exi_value_t* val) { + switch (state->grammarStack[state->stackIndex]) { + + default: + return -1; + } + + return -1; +} + + +#endif + diff --git a/src/codec/EXIEncoder.h b/src/codec/EXIEncoder.h new file mode 100644 index 0000000..84423f3 --- /dev/null +++ b/src/codec/EXIEncoder.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef EXI_ENCODER_H +#define EXI_ENCODER_H + +#include +#include +#include + +#include "EXITypes.h" + +int exiInitEncoder(bitstream_t* stream, exi_state_t* state); + +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 exiEncodeEndElement(bitstream_t* stream, exi_state_t* state, eqname_t* ee); + +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); + +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/codec/EXIHeaderDecoder.c b/src/codec/EXIHeaderDecoder.c new file mode 100644 index 0000000..fb17f8d --- /dev/null +++ b/src/codec/EXIHeaderDecoder.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include +#include + +#include "EXIHeaderDecoder.h" +#include "BitInputStream.h" +#include "BitDecoderChannel.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 = -1; + } else if ( header & 0x20 ) { + /* we do not support "Presence Bit for EXI Options" */ + errn = -2; + } else { + /* Yes, a *simple* header */ + errn = 0; + } + return errn; +} + + +#endif + + diff --git a/src/codec/EXIHeaderDecoder.h b/src/codec/EXIHeaderDecoder.h new file mode 100644 index 0000000..f5a2daa --- /dev/null +++ b/src/codec/EXIHeaderDecoder.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "EXITypes.h" + +#ifndef EXI_HEADER_DECODER_H +#define EXI_HEADER_DECODER_H + +int readEXIHeader(bitstream_t* stream); + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/codec/EXIHeaderEncoder.c b/src/codec/EXIHeaderEncoder.c new file mode 100644 index 0000000..92b30a1 --- /dev/null +++ b/src/codec/EXIHeaderEncoder.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include +#include + +#include "EXIHeaderEncoder.h" +#include "BitOutputStream.h" +#include "BitEncoderChannel.h" + +#ifndef EXI_HEADER_ENCODER_C +#define EXI_HEADER_ENCODER_C + +int writeEXIHeader(bitstream_t* stream) { + return writeBits(stream, 8, 144); +} + + +#endif + + diff --git a/src/codec/EXIHeaderEncoder.h b/src/codec/EXIHeaderEncoder.h new file mode 100644 index 0000000..8177ef9 --- /dev/null +++ b/src/codec/EXIHeaderEncoder.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include "EXITypes.h" + +#ifndef EXI_HEADER_ENCODER_H +#define EXI_HEADER_ENCODER_H + +int writeEXIHeader(bitstream_t* stream); + +#endif + + +#ifdef __cplusplus +} +#endif diff --git a/src/codec/EXITypes.h b/src/codec/EXITypes.h new file mode 100644 index 0000000..30ad418 --- /dev/null +++ b/src/codec/EXITypes.h @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifndef EXI_TYPES_H +#define EXI_TYPES_H + +#define BITS_IN_BYTE 8 + +#define UINT_MAX_VALUE 65535 + +#define EXI_ELEMENT_STACK_SIZE 16 + +/* EXI automaton methods prefixes such as "inline" etc. */ +#ifndef EXI_MPFX +#define EXI_MPFX +#endif + +#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 { + /* Integer Array */ + uint16_t size; /* array size */ + uint8_t* data; /* int data array */ + uint16_t* pos; /* next position in array */ + /* Current byte buffer & its remaining bit capacity */ + uint8_t buffer; + uint16_t capacity; +} bitstream_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; + +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 enum +{ + /* Binary */ + BINARY_BASE64, BINARY_HEX, + /* Boolean */ + BOOLEAN, + /* Decimal */ + DECIMAL, + /* Float */ + FLOAT, DOUBLE, + /* N-Bit Integer */ + NBIT_INTEGER_32, NBIT_INTEGER_64, NBIT_INTEGER_BIG, + /* Unsigned Integer */ + UNSIGNED_INTEGER_16, UNSIGNED_INTEGER_32, UNSIGNED_INTEGER_64, UNSIGNED_INTEGER_BIG, + /* (Signed) Integer */ + INTEGER_16, INTEGER_32, INTEGER_64, INTEGER_BIG, + /* Datetime */ + DATETIME, + /* String */ + STRING, + /* Enumeration */ + ENUMERATION, + /* List */ + LIST +} exi_datatype_t; + + +typedef enum +{ + START_DOCUMENT, + END_DOCUMENT, + START_ELEMENT, + START_ELEMENT_GENERIC, /* not supported yet */ + END_ELEMENT, + CHARACTERS, + CHARACTERS_GENERIC, /* not supported yet */ + ATTRIBUTE, + ATTRIBUTE_GENERIC, /* not supported yet */ + /* error state */ + ERROR +} exi_event_t; + +/* TODO list support */ +typedef struct { + /* List container with memory size */ + uint16_t size; + uint8_t* data; + /* list item type */ + exi_datatype_t type; + /* number of items */ + uint16_t len; +} list_t; + + +typedef struct { + uint16_t namespaceURI; + uint16_t localPart; +} eqname_t; + +typedef struct { + /* stack of grammar states and elements */ + uint16_t grammarStack [EXI_ELEMENT_STACK_SIZE]; + eqname_t elementStack [EXI_ELEMENT_STACK_SIZE]; + uint16_t stackIndex; + /* event-code */ + uint32_t eventCode; +} exi_state_t; + + +typedef struct { + /* type of value */ + exi_datatype_t type; + + /* base types */ + int boolean; + uint32_t uint32; + uint64_t uint64; + 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; + list_t list; +} exi_value_t; + + +/* + * ERROR-Codes + */ +# define EXI_ERROR_OUT_OF_BOUNDS -100 + +# define EXI_ERROR_UNKOWN_EVENT_CODE -110 + +#endif + +#ifdef __cplusplus +} +#endif diff --git a/src/codec/StringTable.c b/src/codec/StringTable.c new file mode 100644 index 0000000..aff058f --- /dev/null +++ b/src/codec/StringTable.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifndef STRING_TABLE_C +#define STRING_TABLE_C + +#include +#include +#include +#include + +#include "StringTable.h" + +#include "StringTableEntries.h" + +#include "assert.h" + +int exiGetUri(uint16_t uriID, const char** uri) { + if ( uriID < stringTable.len ) { + *uri = stringTable.uris[uriID]; + } else { + return EXI_ERROR_OUT_OF_BOUNDS; + } + + return 0; +} + +int exiGetUriLength(uint16_t* uriLength) { + *uriLength = stringTable.len; + return 0; +} + + +int exiGetUriID(const char* uri, uint16_t* uriID) { + unsigned int i; + for(i=0; i. + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STRING_TABLE_H +#define STRING_TABLE_H + +#include "EXITypes.h" + +int exiGetUri(uint16_t uriID, const char** uri); + +int exiGetUriLength(uint16_t* uriLength); + +int exiGetUriID(const char* uri, uint16_t* uriID); + +int exiGetLocalName(uint16_t uriID, uint16_t localNameID, const char** localName); + +int exiGetLocalNameLength(uint16_t uriID, uint16_t* localNameLength); + +int exiGetLocalNameID(uint16_t uriID, const char* localName, uint16_t* localNameID); + +#endif + + +#ifdef __cplusplus +} +#endif + diff --git a/src/codec/StringTableEntries.c b/src/codec/StringTableEntries.c new file mode 100644 index 0000000..fb740a6 --- /dev/null +++ b/src/codec/StringTableEntries.c @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifndef STRING_TABLE_ENTRIES_C +#define STRING_TABLE_ENTRIES_C + +#include "StringTableEntries.h" + + +/* ==================================== */ +/* String Table Population */ + +/* localName entries for URI id = 0 */ +const char * localNames0[] = { + NULL +}; +/* localName entries for URI id = 1 */ +const char * localNames1[] = { + "base", "id", "lang", "space" +}; +/* localName entries for URI id = 2 */ +const char * localNames2[] = { + "nil", "type" +}; +/* localName entries for URI id = 3 */ +const char * localNames3[] = { + "ENTITIES", "ENTITY", "ID", "IDREF", "IDREFS", + "NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "Name", + "QName", "anySimpleType", "anyType", "anyURI", "base64Binary", + "boolean", "byte", "date", "dateTime", "decimal", + "double", "duration", "float", "gDay", "gMonth", + "gMonthDay", "gYear", "gYearMonth", "hexBinary", "int", + "integer", "language", "long", "negativeInteger", "nonNegativeInteger", + "nonPositiveInteger", "normalizedString", "positiveInteger", "short", "string", + "time", "token", "unsignedByte", "unsignedInt", "unsignedLong", + "unsignedShort" +}; +/* localName entries for URI id = 4 */ +const char * localNames4[] = { + "ContractID", "EAmount", "EVSEID", "EVSEIMax", "EVSEMaxPhases", + "EVSEMaxPower", "EVSEStatus", "EVSEVoltage", "EnergyProvider", "EoC", + "LineLockReq", "LineLockReqType", "LineLockRes", "LineLockResType", "MeterInfo", + "MeteringReceiptReq", "MeteringReceiptReqType", "MeteringReceiptRes", "MeteringReceiptResType", "MeteringStatusReq", + "MeteringStatusReqType", "MeteringStatusRes", "MeteringStatusResType", "PCurrent", "PEVID", + "PEVMaxPhases", "PEVMaxPower", "PEVMaxVoltage", "PEVMinVoltage", "PEVStatus", + "PaymentDetailsReq", "PaymentDetailsReqType", "PaymentDetailsRes", "PaymentDetailsResType", "PowerDeliveryReq", + "PowerDeliveryReqType", "PowerDeliveryRes", "PowerDeliveryResType", "PowerDiscoveryReq", "PowerDiscoveryReqType", + "PowerDiscoveryRes", "PowerDiscoveryResType", "ReqLockStatus", "ReqSwitchStatus", "ResponseCode", + "ServiceDiscoveryReq", "ServiceDiscoveryReqType", "ServiceDiscoveryRes", "ServiceDiscoveryResType", "ServiceList", + "ServicePaymentSelectionReq", "ServicePaymentSelectionReqType", "ServicePaymentSelectionRes", "ServicePaymentSelectionResType", "ServiceScope", + "ServiceType", "SessionSetupReq", "SessionSetupReqType", "SessionSetupRes", "SessionSetupResType", + "TCurrent", "Tariff", "TariffTable" +}; +/* localName entries for URI id = 5 */ +const char * localNames5[] = { + "ChargerStandby", "ChargingProfileEntryMaxPower", "ChargingProfileEntryStart", "ChargingProfileType", "ConnectorLocked", + "Currency", "EPrice", "EVSEStandby", "EVSEStatusType", "Event", + "EventList", "EventListType", "FatalError", "FaultCode", "FaultMsg", + "FloatingValueType", "MeterID", "MeterInfoType", "MeterReading", "MeterStatus", + "Multiplier", "NotificationType", "PEVStatusType", "PowerSwitchClosed", "ProtocolVersion", + "RCD", "Service", "ServiceDescriptionType", "ServiceID", "ServiceListType", + "ServiceName", "ServiceScope", "ServiceSessionID", "ServiceType", "SessionID", + "SessionInformationType", "ShutDownTime", "TMeter", "Tariff", "TariffDescrType", + "TariffDescription", "TariffEntries", "TariffEntriesType", "TariffEntry", "TariffEntryType", + "TariffID", "TariffPMax", "TariffStart", "TariffTableType", "Unit", + "Value", "contractIDType", "currencyType", "energyProviderType", "eventEntryType", + "evseIDType", "fatalErrorType", "faultCodeType", "lockStatusType", "maxPhasesType", + "meterIDType", "meterStatusType", "paymentOptionListType", "paymentOptionType", "pevIDType", + "protocolVersionType", "pubKeyType", "rcdType", "responseCode_LineLockType", "responseCode_MeteringReceiptType", + "responseCode_MeteringStatusType", "responseCode_PaymentDetailsType", "responseCode_PowerDeliveryType", "responseCode_PowerDiscoveryType", "responseCode_ServiceDiscoveryType", + "responseCode_ServicePaymentSelectionType", "responseCode_SessionSetupType", "serviceDetailsType", "serviceIDType", "serviceNameType", + "serviceScopeType", "serviceTypeType", "sessionIDType", "standbyType", "switchStatusType", + "tariffDescriptionType", "tariffIDType", "tariffStartType", "timeType", "unitMultiplierType", + "unitSymbolType" +}; +/* localName entries for URI id = 6 */ +const char * localNames6[] = { + "Body", "BodyBaseType", "BodyElement", "BodyType", "Header", + "V2G_Message" +}; +/* localName entries for URI id = 7 */ +const char * localNames7[] = { + "HeaderType", "Notification", "SessionInformation" +}; +struct exiPartition localNamePartitions[8] = { + { 0, localNames0 }, + { 4, localNames1 }, + { 2, localNames2 }, + { 46, localNames3 }, + { 63, localNames4 }, + { 91, localNames5 }, + { 6, localNames6 }, + { 3, localNames7 } +}; +const char * uris[] = { + "", "http://www.w3.org/XML/1998/namespace", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/2001/XMLSchema", "urn:iso:15118:2:2010:eval1.0:MsgBody", "urn:iso:15118:2:2010:eval1.0:MsgDataTypes", "urn:iso:15118:2:2010:eval1.0:MsgDef", "urn:iso:15118:2:2010:eval1.0:MsgHeader" +}; +struct exiStringTable stringTable = { 8, uris, localNamePartitions }; + + + + +#endif + diff --git a/src/codec/StringTableEntries.h b/src/codec/StringTableEntries.h new file mode 100644 index 0000000..f32411c --- /dev/null +++ b/src/codec/StringTableEntries.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#ifndef STRING_TABLE_ENTRIES_H +#define STRING_TABLE_ENTRIES_H + +#include +#include +#include +#include + +/* ==================================== */ +/* String Table Structures */ + +struct exiPartition { + /* length of array */ + uint16_t len; + /* array of string entries */ + const char** entries; +}; + +struct exiStringTable { + /* length of both arrays (uris & localNames) */ + uint16_t len; + /* URI entries*/ + const char** uris; + /* localName entries divided by URI */ + struct exiPartition * localNames; +}; + + +/* ==================================== */ +/* String Table Population */ + +extern struct exiStringTable stringTable; + +#endif + diff --git a/src/codec/UCSString.c b/src/codec/UCSString.c new file mode 100644 index 0000000..5df6029 --- /dev/null +++ b/src/codec/UCSString.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#include +#include +#include +#include + +#include "BitDecoderChannel.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; ilen; i++) { + s->codepoints[i] = chars[i]; + } + return 0; + } else { + return -1; + } +} + +/* Note: fails if string contains non ASCII characters */ +int toASCIIString(string_ucs_t* string, char* outASCII) { + unsigned int i; + for(i=0; ilen; i++) { + outASCII[i] = (char)string->codepoints[i]; + } + outASCII[string->len] = '\0'; + + return 0; +} + +#endif + diff --git a/src/codec/UCSString.h b/src/codec/UCSString.h new file mode 100644 index 0000000..803d5b9 --- /dev/null +++ b/src/codec/UCSString.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007-2010 Siemens AG + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +/******************************************************************* + * + * @author Daniel.Peintner.EXT@siemens.com + * @version 0.3.1 + * @contact Joerg.Heuer@siemens.com + * + ********************************************************************/ + +#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