/*
 * Copyright (C) 2007-2018 Siemens AG
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/*******************************************************************
 *
 * @author Daniel.Peintner.EXT@siemens.com
 * @version 0.9.4 
 * @contact Richard.Kuntschke@siemens.com
 *
 * <p>Code generated by EXIdizer</p>
 * <p>Schema: V2G_CI_MsgDef.xsd</p>
 *
 *
 ********************************************************************/




#include "dinEXIDatatypesEncoder.h"

#include "EncoderChannel.h"
#include "EXIHeaderEncoder.h"

#include "dinEXIDatatypes.h"
#include "ErrorCodes.h"

#ifndef EXI_din_DATATYPES_ENCODER_C
#define EXI_din_DATATYPES_ENCODER_C

#if DEPLOY_DIN_CODEC == SUPPORT_YES

static int errn;

/* Forward Declarations */
static int encode_dinMeteringReceiptReqType(bitstream_t* stream, struct dinMeteringReceiptReqType* dinMeteringReceiptReqType);
static int encode_dinBodyType(bitstream_t* stream, struct dinBodyType* dinBodyType);
static int encode_dinSessionSetupReqType(bitstream_t* stream, struct dinSessionSetupReqType* dinSessionSetupReqType);
static int encode_dinPowerDeliveryResType(bitstream_t* stream, struct dinPowerDeliveryResType* dinPowerDeliveryResType);
static int encode_dinServiceDetailResType(bitstream_t* stream, struct dinServiceDetailResType* dinServiceDetailResType);
static int encode_dinWeldingDetectionResType(bitstream_t* stream, struct dinWeldingDetectionResType* dinWeldingDetectionResType);
static int encode_dinContractAuthenticationResType(bitstream_t* stream, struct dinContractAuthenticationResType* dinContractAuthenticationResType);
static int encode_dinCanonicalizationMethodType(bitstream_t* stream, struct dinCanonicalizationMethodType* dinCanonicalizationMethodType);
static int encode_dinSPKIDataType(bitstream_t* stream, struct dinSPKIDataType* dinSPKIDataType);
static int encode_dinListOfRootCertificateIDsType(bitstream_t* stream, struct dinListOfRootCertificateIDsType* dinListOfRootCertificateIDsType);
static int encode_dinSelectedServiceListType(bitstream_t* stream, struct dinSelectedServiceListType* dinSelectedServiceListType);
static int encode_dinCurrentDemandResType(bitstream_t* stream, struct dinCurrentDemandResType* dinCurrentDemandResType);
static int encode_dinTransformType(bitstream_t* stream, struct dinTransformType* dinTransformType);
static int encode_dinAC_EVChargeParameterType(bitstream_t* stream, struct dinAC_EVChargeParameterType* dinAC_EVChargeParameterType);
static int encode_dinX509DataType(bitstream_t* stream, struct dinX509DataType* dinX509DataType);
static int encode_dinChargingStatusResType(bitstream_t* stream, struct dinChargingStatusResType* dinChargingStatusResType);
static int encode_dinWeldingDetectionReqType(bitstream_t* stream, struct dinWeldingDetectionReqType* dinWeldingDetectionReqType);
static int encode_dinSignaturePropertiesType(bitstream_t* stream, struct dinSignaturePropertiesType* dinSignaturePropertiesType);
static int encode_dinContractAuthenticationReqType(bitstream_t* stream, struct dinContractAuthenticationReqType* dinContractAuthenticationReqType);
static int encode_dinDC_EVPowerDeliveryParameterType(bitstream_t* stream, struct dinDC_EVPowerDeliveryParameterType* dinDC_EVPowerDeliveryParameterType);
static int encode_dinEVSEChargeParameterType(bitstream_t* stream, struct dinEVSEChargeParameterType* dinEVSEChargeParameterType);
static int encode_dinCableCheckReqType(bitstream_t* stream, struct dinCableCheckReqType* dinCableCheckReqType);
static int encode_dinDC_EVChargeParameterType(bitstream_t* stream, struct dinDC_EVChargeParameterType* dinDC_EVChargeParameterType);
static int encode_dinSAScheduleListType(bitstream_t* stream, struct dinSAScheduleListType* dinSAScheduleListType);
static int encode_dinPMaxScheduleType(bitstream_t* stream, struct dinPMaxScheduleType* dinPMaxScheduleType);
static int encode_dinServicePaymentSelectionReqType(bitstream_t* stream, struct dinServicePaymentSelectionReqType* dinServicePaymentSelectionReqType);
static int encode_dinRelativeTimeIntervalType(bitstream_t* stream, struct dinRelativeTimeIntervalType* dinRelativeTimeIntervalType);
static int encode_dinEVStatusType(bitstream_t* stream, struct dinEVStatusType* dinEVStatusType);
static int encode_dinPreChargeResType(bitstream_t* stream, struct dinPreChargeResType* dinPreChargeResType);
static int encode_dinDC_EVSEChargeParameterType(bitstream_t* stream, struct dinDC_EVSEChargeParameterType* dinDC_EVSEChargeParameterType);
static int encode_dinPaymentDetailsResType(bitstream_t* stream, struct dinPaymentDetailsResType* dinPaymentDetailsResType);
static int encode_dinDSAKeyValueType(bitstream_t* stream, struct dinDSAKeyValueType* dinDSAKeyValueType);
static int encode_dinSASchedulesType(bitstream_t* stream, struct dinSASchedulesType* dinSASchedulesType);
static int encode_dinCertificateUpdateResType(bitstream_t* stream, struct dinCertificateUpdateResType* dinCertificateUpdateResType);
static int encode_dinEVChargeParameterType(bitstream_t* stream, struct dinEVChargeParameterType* dinEVChargeParameterType);
static int encode_dinMessageHeaderType(bitstream_t* stream, struct dinMessageHeaderType* dinMessageHeaderType);
static int encode_dinBodyBaseType(bitstream_t* stream, struct dinBodyBaseType* dinBodyBaseType);
static int encode_dinKeyValueType(bitstream_t* stream, struct dinKeyValueType* dinKeyValueType);
static int encode_dinIntervalType(bitstream_t* stream, struct dinIntervalType* dinIntervalType);
static int encode_dinChargeParameterDiscoveryResType(bitstream_t* stream, struct dinChargeParameterDiscoveryResType* dinChargeParameterDiscoveryResType);
static int encode_dinPowerDeliveryReqType(bitstream_t* stream, struct dinPowerDeliveryReqType* dinPowerDeliveryReqType);
static int encode_dinCertificateChainType(bitstream_t* stream, struct dinCertificateChainType* dinCertificateChainType);
static int encode_dinTransformsType(bitstream_t* stream, struct dinTransformsType* dinTransformsType);
static int encode_dinEntryType(bitstream_t* stream, struct dinEntryType* dinEntryType);
static int encode_dinSessionStopType(bitstream_t* stream, struct dinSessionStopType* dinSessionStopType);
static int encode_dinServiceDetailReqType(bitstream_t* stream, struct dinServiceDetailReqType* dinServiceDetailReqType);
static int encode_dinDigestMethodType(bitstream_t* stream, struct dinDigestMethodType* dinDigestMethodType);
static int encode_dinParameterType(bitstream_t* stream, struct dinParameterType* dinParameterType);
static int encode_dinChargingStatusReqType(bitstream_t* stream, struct dinChargingStatusReqType* dinChargingStatusReqType);
static int encode_dinSignatureMethodType(bitstream_t* stream, struct dinSignatureMethodType* dinSignatureMethodType);
static int encode_dinCertificateInstallationReqType(bitstream_t* stream, struct dinCertificateInstallationReqType* dinCertificateInstallationReqType);
static int encode_dinSalesTariffEntryType(bitstream_t* stream, struct dinSalesTariffEntryType* dinSalesTariffEntryType);
static int encode_dinServiceDiscoveryResType(bitstream_t* stream, struct dinServiceDiscoveryResType* dinServiceDiscoveryResType);
static int encode_dinParameterSetType(bitstream_t* stream, struct dinParameterSetType* dinParameterSetType);
static int encode_dinCurrentDemandReqType(bitstream_t* stream, struct dinCurrentDemandReqType* dinCurrentDemandReqType);
static int encode_dinPreChargeReqType(bitstream_t* stream, struct dinPreChargeReqType* dinPreChargeReqType);
static int encode_dinSignatureType(bitstream_t* stream, struct dinSignatureType* dinSignatureType);
static int encode_dinReferenceType(bitstream_t* stream, struct dinReferenceType* dinReferenceType);
static int encode_dinProfileEntryType(bitstream_t* stream, struct dinProfileEntryType* dinProfileEntryType);
static int encode_dinAnonType_V2G_Message(bitstream_t* stream, struct dinAnonType_V2G_Message* dinAnonType_V2G_Message);
static int encode_dinChargeParameterDiscoveryReqType(bitstream_t* stream, struct dinChargeParameterDiscoveryReqType* dinChargeParameterDiscoveryReqType);
static int encode_dinConsumptionCostType(bitstream_t* stream, struct dinConsumptionCostType* dinConsumptionCostType);
static int encode_dinRSAKeyValueType(bitstream_t* stream, struct dinRSAKeyValueType* dinRSAKeyValueType);
static int encode_dinServiceType(bitstream_t* stream, struct dinServiceType* dinServiceType);
static int encode_dinServiceTagListType(bitstream_t* stream, struct dinServiceTagListType* dinServiceTagListType);
static int encode_dinEVSEStatusType(bitstream_t* stream, struct dinEVSEStatusType* dinEVSEStatusType);
static int encode_dinSessionSetupResType(bitstream_t* stream, struct dinSessionSetupResType* dinSessionSetupResType);
static int encode_dinEVPowerDeliveryParameterType(bitstream_t* stream, struct dinEVPowerDeliveryParameterType* dinEVPowerDeliveryParameterType);
static int encode_dinX509IssuerSerialType(bitstream_t* stream, struct dinX509IssuerSerialType* dinX509IssuerSerialType);
static int encode_dinSelectedServiceType(bitstream_t* stream, struct dinSelectedServiceType* dinSelectedServiceType);
static int encode_dinMeteringReceiptResType(bitstream_t* stream, struct dinMeteringReceiptResType* dinMeteringReceiptResType);
static int encode_dinDC_EVStatusType(bitstream_t* stream, struct dinDC_EVStatusType* dinDC_EVStatusType);
static int encode_dinPhysicalValueType(bitstream_t* stream, struct dinPhysicalValueType* dinPhysicalValueType);
static int encode_dinManifestType(bitstream_t* stream, struct dinManifestType* dinManifestType);
static int encode_dinPMaxScheduleEntryType(bitstream_t* stream, struct dinPMaxScheduleEntryType* dinPMaxScheduleEntryType);
static int encode_dinServiceParameterListType(bitstream_t* stream, struct dinServiceParameterListType* dinServiceParameterListType);
static int encode_dinSignatureValueType(bitstream_t* stream, struct dinSignatureValueType* dinSignatureValueType);
static int encode_dinPaymentOptionsType(bitstream_t* stream, struct dinPaymentOptionsType* dinPaymentOptionsType);
static int encode_dinServiceTagType(bitstream_t* stream, struct dinServiceTagType* dinServiceTagType);
static int encode_dinAC_EVSEStatusType(bitstream_t* stream, struct dinAC_EVSEStatusType* dinAC_EVSEStatusType);
static int encode_dinCertificateUpdateReqType(bitstream_t* stream, struct dinCertificateUpdateReqType* dinCertificateUpdateReqType);
static int encode_dinServicePaymentSelectionResType(bitstream_t* stream, struct dinServicePaymentSelectionResType* dinServicePaymentSelectionResType);
static int encode_dinSAScheduleTupleType(bitstream_t* stream, struct dinSAScheduleTupleType* dinSAScheduleTupleType);
static int encode_dinChargingProfileType(bitstream_t* stream, struct dinChargingProfileType* dinChargingProfileType);
static int encode_dinServiceDiscoveryReqType(bitstream_t* stream, struct dinServiceDiscoveryReqType* dinServiceDiscoveryReqType);
static int encode_dinAC_EVSEChargeParameterType(bitstream_t* stream, struct dinAC_EVSEChargeParameterType* dinAC_EVSEChargeParameterType);
static int encode_dinKeyInfoType(bitstream_t* stream, struct dinKeyInfoType* dinKeyInfoType);
static int encode_dinPaymentDetailsReqType(bitstream_t* stream, struct dinPaymentDetailsReqType* dinPaymentDetailsReqType);
static int encode_dinCableCheckResType(bitstream_t* stream, struct dinCableCheckResType* dinCableCheckResType);
static int encode_dinObjectType(bitstream_t* stream, struct dinObjectType* dinObjectType);
static int encode_dinSessionStopResType(bitstream_t* stream, struct dinSessionStopResType* dinSessionStopResType);
static int encode_dinSignedInfoType(bitstream_t* stream, struct dinSignedInfoType* dinSignedInfoType);
static int encode_dinSalesTariffType(bitstream_t* stream, struct dinSalesTariffType* dinSalesTariffType);
static int encode_dinCostType(bitstream_t* stream, struct dinCostType* dinCostType);
static int encode_dinServiceChargeType(bitstream_t* stream, struct dinServiceChargeType* dinServiceChargeType);
static int encode_dinDC_EVSEStatusType(bitstream_t* stream, struct dinDC_EVSEStatusType* dinDC_EVSEStatusType);
static int encode_dinRetrievalMethodType(bitstream_t* stream, struct dinRetrievalMethodType* dinRetrievalMethodType);
static int encode_dinNotificationType(bitstream_t* stream, struct dinNotificationType* dinNotificationType);
static int encode_dinPGPDataType(bitstream_t* stream, struct dinPGPDataType* dinPGPDataType);
static int encode_dinCertificateInstallationResType(bitstream_t* stream, struct dinCertificateInstallationResType* dinCertificateInstallationResType);
static int encode_dinSignaturePropertyType(bitstream_t* stream, struct dinSignaturePropertyType* dinSignaturePropertyType);
static int encode_dinMeterInfoType(bitstream_t* stream, struct dinMeterInfoType* dinMeterInfoType);
static int encode_dinSubCertificatesType(bitstream_t* stream, struct dinSubCertificatesType* dinSubCertificatesType);



/* Complex type name='urn:iso:15118:2:2010:MsgBody,MeteringReceiptReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":SessionID,"urn:iso:15118:2:2010:MsgBody":SAScheduleTupleID{0-1},"urn:iso:15118:2:2010:MsgBody":MeterInfo)',  derivedBy='EXTENSION'.  */
static int encode_dinMeteringReceiptReqType(bitstream_t* stream, struct dinMeteringReceiptReqType* dinMeteringReceiptReqType) {
	int grammarID = 0;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 0:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionID)] */
			if ( dinMeteringReceiptReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeteringReceiptReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinMeteringReceiptReqType->Id.characters, dinMeteringReceiptReqType->Id.charactersLen);
					}
				}
				grammarID = 1;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeteringReceiptReqType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinMeteringReceiptReqType->SessionID.bytes, dinMeteringReceiptReqType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 2;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 1:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeteringReceiptReqType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinMeteringReceiptReqType->SessionID.bytes, dinMeteringReceiptReqType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 2;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 2:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo)] */
			if ( dinMeteringReceiptReqType->SAScheduleTupleID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinMeteringReceiptReqType->SAScheduleTupleID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 3;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinMeterInfoType(stream, &dinMeteringReceiptReqType->MeterInfo );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 3:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinMeterInfoType(stream, &dinMeteringReceiptReqType->MeterInfo );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDef,BodyType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDef":BodyElement{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinBodyType(bitstream_t* stream, struct dinBodyType* dinBodyType) {
	int grammarID = 6;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 6:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionRes), END_ELEMENT] */
			if ( dinBodyType->BodyElement_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 0);
				if(errn == 0) {
					errn = encode_dinBodyBaseType(stream, &dinBodyType->BodyElement );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CableCheckReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 1);
				if(errn == 0) {
					errn = encode_dinCableCheckReqType(stream, &dinBodyType->CableCheckReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CableCheckRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 2);
				if(errn == 0) {
					errn = encode_dinCableCheckResType(stream, &dinBodyType->CableCheckRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CertificateInstallationReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 3);
				if(errn == 0) {
					errn = encode_dinCertificateInstallationReqType(stream, &dinBodyType->CertificateInstallationReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CertificateInstallationRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 4);
				if(errn == 0) {
					errn = encode_dinCertificateInstallationResType(stream, &dinBodyType->CertificateInstallationRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CertificateUpdateReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 5);
				if(errn == 0) {
					errn = encode_dinCertificateUpdateReqType(stream, &dinBodyType->CertificateUpdateReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CertificateUpdateRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 6);
				if(errn == 0) {
					errn = encode_dinCertificateUpdateResType(stream, &dinBodyType->CertificateUpdateRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ChargeParameterDiscoveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 7);
				if(errn == 0) {
					errn = encode_dinChargeParameterDiscoveryReqType(stream, &dinBodyType->ChargeParameterDiscoveryReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ChargeParameterDiscoveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 8);
				if(errn == 0) {
					errn = encode_dinChargeParameterDiscoveryResType(stream, &dinBodyType->ChargeParameterDiscoveryRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ChargingStatusReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 9);
				if(errn == 0) {
					errn = encode_dinChargingStatusReqType(stream, &dinBodyType->ChargingStatusReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ChargingStatusRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 10);
				if(errn == 0) {
					errn = encode_dinChargingStatusResType(stream, &dinBodyType->ChargingStatusRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ContractAuthenticationReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 11);
				if(errn == 0) {
					errn = encode_dinContractAuthenticationReqType(stream, &dinBodyType->ContractAuthenticationReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ContractAuthenticationRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 12);
				if(errn == 0) {
					errn = encode_dinContractAuthenticationResType(stream, &dinBodyType->ContractAuthenticationRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CurrentDemandReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 13);
				if(errn == 0) {
					errn = encode_dinCurrentDemandReqType(stream, &dinBodyType->CurrentDemandReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->CurrentDemandRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 14);
				if(errn == 0) {
					errn = encode_dinCurrentDemandResType(stream, &dinBodyType->CurrentDemandRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->MeteringReceiptReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 15);
				if(errn == 0) {
					errn = encode_dinMeteringReceiptReqType(stream, &dinBodyType->MeteringReceiptReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->MeteringReceiptRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 16);
				if(errn == 0) {
					errn = encode_dinMeteringReceiptResType(stream, &dinBodyType->MeteringReceiptRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PaymentDetailsReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 17);
				if(errn == 0) {
					errn = encode_dinPaymentDetailsReqType(stream, &dinBodyType->PaymentDetailsReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PaymentDetailsRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 18);
				if(errn == 0) {
					errn = encode_dinPaymentDetailsResType(stream, &dinBodyType->PaymentDetailsRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PowerDeliveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 19);
				if(errn == 0) {
					errn = encode_dinPowerDeliveryReqType(stream, &dinBodyType->PowerDeliveryReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PowerDeliveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 20);
				if(errn == 0) {
					errn = encode_dinPowerDeliveryResType(stream, &dinBodyType->PowerDeliveryRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PreChargeReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 21);
				if(errn == 0) {
					errn = encode_dinPreChargeReqType(stream, &dinBodyType->PreChargeReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->PreChargeRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 22);
				if(errn == 0) {
					errn = encode_dinPreChargeResType(stream, &dinBodyType->PreChargeRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServiceDetailReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 23);
				if(errn == 0) {
					errn = encode_dinServiceDetailReqType(stream, &dinBodyType->ServiceDetailReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServiceDetailRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 24);
				if(errn == 0) {
					errn = encode_dinServiceDetailResType(stream, &dinBodyType->ServiceDetailRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServiceDiscoveryReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 25);
				if(errn == 0) {
					errn = encode_dinServiceDiscoveryReqType(stream, &dinBodyType->ServiceDiscoveryReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServiceDiscoveryRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 26);
				if(errn == 0) {
					errn = encode_dinServiceDiscoveryResType(stream, &dinBodyType->ServiceDiscoveryRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServicePaymentSelectionReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 27);
				if(errn == 0) {
					errn = encode_dinServicePaymentSelectionReqType(stream, &dinBodyType->ServicePaymentSelectionReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->ServicePaymentSelectionRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 28);
				if(errn == 0) {
					errn = encode_dinServicePaymentSelectionResType(stream, &dinBodyType->ServicePaymentSelectionRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->SessionSetupReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 29);
				if(errn == 0) {
					errn = encode_dinSessionSetupReqType(stream, &dinBodyType->SessionSetupReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->SessionSetupRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 30);
				if(errn == 0) {
					errn = encode_dinSessionSetupResType(stream, &dinBodyType->SessionSetupRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->SessionStopReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 31);
				if(errn == 0) {
					errn = encode_dinSessionStopType(stream, &dinBodyType->SessionStopReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->SessionStopRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 32);
				if(errn == 0) {
					errn = encode_dinSessionStopResType(stream, &dinBodyType->SessionStopRes );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->WeldingDetectionReq_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 33);
				if(errn == 0) {
					errn = encode_dinWeldingDetectionReqType(stream, &dinBodyType->WeldingDetectionReq );
				}
				grammarID = 4;
			} else 			if ( dinBodyType->WeldingDetectionRes_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 6, 34);
				if(errn == 0) {
					errn = encode_dinWeldingDetectionResType(stream, &dinBodyType->WeldingDetectionRes );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 6, 35);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,SessionSetupReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":EVCCID)',  derivedBy='EXTENSION'.  */
static int encode_dinSessionSetupReqType(bitstream_t* stream, struct dinSessionSetupReqType* dinSessionSetupReqType) {
	int grammarID = 7;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 7:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVCCID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSessionSetupReqType->EVCCID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSessionSetupReqType->EVCCID.bytes, dinSessionSetupReqType->EVCCID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PowerDeliveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgDataTypes":EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_dinPowerDeliveryResType(bitstream_t* stream, struct dinPowerDeliveryResType* dinPowerDeliveryResType) {
	int grammarID = 8;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 8:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinPowerDeliveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 9;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 9:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatus)] */
			if ( dinPowerDeliveryResType->AC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVSEStatusType(stream, &dinPowerDeliveryResType->AC_EVSEStatus );
				}
				grammarID = 4;
			} else 			if ( dinPowerDeliveryResType->DC_EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinPowerDeliveryResType->DC_EVSEStatus );
				}
				grammarID = 4;
			} else 			if ( dinPowerDeliveryResType->EVSEStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_dinEVSEStatusType(stream, &dinPowerDeliveryResType->EVSEStatus );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServiceDetailResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":ServiceID,"urn:iso:15118:2:2010:MsgBody":ServiceParameterList{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinServiceDetailResType(bitstream_t* stream, struct dinServiceDetailResType* dinServiceDetailResType) {
	int grammarID = 10;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 10:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinServiceDetailResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 11;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 11:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, dinServiceDetailResType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 12;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 12:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceParameterList), END_ELEMENT] */
			if ( dinServiceDetailResType->ServiceParameterList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinServiceParameterListType(stream, &dinServiceDetailResType->ServiceParameterList );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,WeldingDetectionResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2010:MsgBody":EVSEPresentVoltage)',  derivedBy='EXTENSION'.  */
static int encode_dinWeldingDetectionResType(bitstream_t* stream, struct dinWeldingDetectionResType* dinWeldingDetectionResType) {
	int grammarID = 13;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 13:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinWeldingDetectionResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 14;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 14:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinWeldingDetectionResType->DC_EVSEStatus );
				}
				grammarID = 15;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 15:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinWeldingDetectionResType->EVSEPresentVoltage );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ContractAuthenticationResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":EVSEProcessing)',  derivedBy='EXTENSION'.  */
static int encode_dinContractAuthenticationResType(bitstream_t* stream, struct dinContractAuthenticationResType* dinContractAuthenticationResType) {
	int grammarID = 16;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 16:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinContractAuthenticationResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 17;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 17:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinContractAuthenticationResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,CanonicalizationMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##any]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinCanonicalizationMethodType(bitstream_t* stream, struct dinCanonicalizationMethodType* dinCanonicalizationMethodType) {
	int grammarID = 18;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 18:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCanonicalizationMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCanonicalizationMethodType->Algorithm.characters, dinCanonicalizationMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 19;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 19:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinCanonicalizationMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinCanonicalizationMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCanonicalizationMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCanonicalizationMethodType->ANY.characters, dinCanonicalizationMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinCanonicalizationMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinCanonicalizationMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCanonicalizationMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCanonicalizationMethodType->ANY.characters, dinCanonicalizationMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SPKIDataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SPKISexp,(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-1}){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinSPKIDataType(bitstream_t* stream, struct dinSPKIDataType* dinSPKIDataType) {
	int grammarID = 21;
	int done = 0;
	int wcDone = 0;
	
	unsigned int dinSPKIDataType_SPKISexp_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 21:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp)] */
			if (dinSPKIDataType_SPKISexp_currArrayIndex < dinSPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytes, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							dinSPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 22;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 22:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT_GENERIC, END_ELEMENT] */
			if (dinSPKIDataType_SPKISexp_currArrayIndex < dinSPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytes, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							dinSPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 22;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 23;
			} else 			if ( dinSPKIDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 23:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), END_ELEMENT] */
			if (dinSPKIDataType_SPKISexp_currArrayIndex < dinSPKIDataType->SPKISexp.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytes, dinSPKIDataType->SPKISexp.array[dinSPKIDataType_SPKISexp_currArrayIndex].bytesLen);
							dinSPKIDataType_SPKISexp_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 22;
			} else 			if ( dinSPKIDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ListOfRootCertificateIDsType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":RootCertificateID{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinListOfRootCertificateIDsType(bitstream_t* stream, struct dinListOfRootCertificateIDsType* dinListOfRootCertificateIDsType) {
	int grammarID = 24;
	int done = 0;
	
	unsigned int dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 24:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RootCertificateID)] */
			if (dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex < dinListOfRootCertificateIDsType->RootCertificateID.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].characters, dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].charactersLen);
							dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 25;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 25:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RootCertificateID), END_ELEMENT] */
			if (dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex < dinListOfRootCertificateIDsType->RootCertificateID.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].characters, dinListOfRootCertificateIDsType->RootCertificateID.array[dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex].charactersLen);
							dinListOfRootCertificateIDsType_RootCertificateID_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 25;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SelectedServiceListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":SelectedService{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSelectedServiceListType(bitstream_t* stream, struct dinSelectedServiceListType* dinSelectedServiceListType) {
	int grammarID = 26;
	int done = 0;
	
	unsigned int dinSelectedServiceListType_SelectedService_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 26:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SelectedService)] */
			if (dinSelectedServiceListType_SelectedService_currArrayIndex < dinSelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSelectedServiceType(stream, &dinSelectedServiceListType->SelectedService.array [dinSelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 27;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 27:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SelectedService), END_ELEMENT] */
			if (dinSelectedServiceListType_SelectedService_currArrayIndex < dinSelectedServiceListType->SelectedService.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSelectedServiceType(stream, &dinSelectedServiceListType->SelectedService.array [dinSelectedServiceListType_SelectedService_currArrayIndex++]);
				}
				grammarID = 27;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CurrentDemandResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2010:MsgBody":EVSEPresentVoltage,"urn:iso:15118:2:2010:MsgBody":EVSEPresentCurrent,"urn:iso:15118:2:2010:MsgBody":EVSECurrentLimitAchieved,"urn:iso:15118:2:2010:MsgBody":EVSEVoltageLimitAchieved,"urn:iso:15118:2:2010:MsgBody":EVSEPowerLimitAchieved,"urn:iso:15118:2:2010:MsgBody":EVSEMaximumVoltageLimit{0-1},"urn:iso:15118:2:2010:MsgBody":EVSEMaximumCurrentLimit{0-1},"urn:iso:15118:2:2010:MsgBody":EVSEMaximumPowerLimit{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinCurrentDemandResType(bitstream_t* stream, struct dinCurrentDemandResType* dinCurrentDemandResType) {
	int grammarID = 28;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 28:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinCurrentDemandResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 29;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 29:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinCurrentDemandResType->DC_EVSEStatus );
				}
				grammarID = 30;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 30:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEPresentVoltage );
				}
				grammarID = 31;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 31:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEPresentCurrent );
				}
				grammarID = 32;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 32:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSECurrentLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandResType->EVSECurrentLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 33;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 33:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEVoltageLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandResType->EVSEVoltageLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 34;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 34:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPowerLimitAchieved)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandResType->EVSEPowerLimitAchieved);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 35;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 35:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumPowerLimit), END_ELEMENT] */
			if ( dinCurrentDemandResType->EVSEMaximumVoltageLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumVoltageLimit );
				}
				grammarID = 36;
			} else 			if ( dinCurrentDemandResType->EVSEMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumCurrentLimit );
				}
				grammarID = 37;
			} else 			if ( dinCurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 36:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumPowerLimit), END_ELEMENT] */
			if ( dinCurrentDemandResType->EVSEMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumCurrentLimit );
				}
				grammarID = 37;
			} else 			if ( dinCurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 37:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumPowerLimit), END_ELEMENT] */
			if ( dinCurrentDemandResType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandResType->EVSEMaximumPowerLimit );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,TransformType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"])|"http://www.w3.org/2000/09/xmldsig#":XPath){0-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinTransformType(bitstream_t* stream, struct dinTransformType* dinTransformType) {
	int grammarID = 38;
	int done = 0;
	int wcDone = 0;
	
	unsigned int dinTransformType_XPath_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 38:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinTransformType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinTransformType->Algorithm.characters, dinTransformType->Algorithm.charactersLen);
					}
				}
				grammarID = 39;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 39:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (dinTransformType_XPath_currArrayIndex < dinTransformType->XPath.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].characters, dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].charactersLen);
							dinTransformType_XPath_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 40;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 40;
			} else 			if ( dinTransformType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinTransformType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinTransformType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinTransformType->ANY.characters, dinTransformType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 40;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 40:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (dinTransformType_XPath_currArrayIndex < dinTransformType->XPath.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].characters, dinTransformType->XPath.array[dinTransformType_XPath_currArrayIndex].charactersLen);
							dinTransformType_XPath_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 40;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 40;
			} else 			if ( dinTransformType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinTransformType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinTransformType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinTransformType->ANY.characters, dinTransformType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 40;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,AC_EVChargeParameterType',  base type name='EVChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":DepartureTime,"urn:iso:15118:2:2010:MsgDataTypes":EAmount,"urn:iso:15118:2:2010:MsgDataTypes":EVMaxVoltage,"urn:iso:15118:2:2010:MsgDataTypes":EVMaxCurrent,"urn:iso:15118:2:2010:MsgDataTypes":EVMinCurrent)',  derivedBy='EXTENSION'.  */
static int encode_dinAC_EVChargeParameterType(bitstream_t* stream, struct dinAC_EVChargeParameterType* dinAC_EVChargeParameterType) {
	int grammarID = 41;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 41:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DepartureTime)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinAC_EVChargeParameterType->DepartureTime);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 42;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 42:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EAmount)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVChargeParameterType->EAmount );
				}
				grammarID = 43;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 43:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVChargeParameterType->EVMaxVoltage );
				}
				grammarID = 44;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 44:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVChargeParameterType->EVMaxCurrent );
				}
				grammarID = 45;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 45:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMinCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVChargeParameterType->EVMinCurrent );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,X509DataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":X509IssuerSerial|"http://www.w3.org/2000/09/xmldsig#":X509SKI|"http://www.w3.org/2000/09/xmldsig#":X509SubjectName|"http://www.w3.org/2000/09/xmldsig#":X509Certificate|"http://www.w3.org/2000/09/xmldsig#":X509CRL|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]))){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinX509DataType(bitstream_t* stream, struct dinX509DataType* dinX509DataType) {
	int grammarID = 46;
	int done = 0;
	int wcDone = 0;
	
	unsigned int dinX509DataType_X509IssuerSerial_currArrayIndex = 0;
	unsigned int dinX509DataType_X509SKI_currArrayIndex = 0;
	unsigned int dinX509DataType_X509SubjectName_currArrayIndex = 0;
	unsigned int dinX509DataType_X509Certificate_currArrayIndex = 0;
	unsigned int dinX509DataType_X509CRL_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 46:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT_GENERIC] */
			if (dinX509DataType_X509IssuerSerial_currArrayIndex < dinX509DataType->X509IssuerSerial.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinX509IssuerSerialType(stream, &dinX509DataType->X509IssuerSerial.array [dinX509DataType_X509IssuerSerial_currArrayIndex++]);
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509SKI_currArrayIndex < dinX509DataType->X509SKI.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytes, dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytesLen);
							dinX509DataType_X509SKI_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509SubjectName_currArrayIndex < dinX509DataType->X509SubjectName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].characters, dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].charactersLen);
							dinX509DataType_X509SubjectName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509Certificate_currArrayIndex < dinX509DataType->X509Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytes, dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytesLen);
							dinX509DataType_X509Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509CRL_currArrayIndex < dinX509DataType->X509CRL.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytes, dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytesLen);
							dinX509DataType_X509CRL_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 47;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 47:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT_GENERIC, END_ELEMENT] */
			if (dinX509DataType_X509IssuerSerial_currArrayIndex < dinX509DataType->X509IssuerSerial.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinX509IssuerSerialType(stream, &dinX509DataType->X509IssuerSerial.array [dinX509DataType_X509IssuerSerial_currArrayIndex++]);
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509SKI_currArrayIndex < dinX509DataType->X509SKI.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytes, dinX509DataType->X509SKI.array[dinX509DataType_X509SKI_currArrayIndex].bytesLen);
							dinX509DataType_X509SKI_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509SubjectName_currArrayIndex < dinX509DataType->X509SubjectName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].characters, dinX509DataType->X509SubjectName.array[dinX509DataType_X509SubjectName_currArrayIndex].charactersLen);
							dinX509DataType_X509SubjectName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509Certificate_currArrayIndex < dinX509DataType->X509Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytes, dinX509DataType->X509Certificate.array[dinX509DataType_X509Certificate_currArrayIndex].bytesLen);
							dinX509DataType_X509Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (dinX509DataType_X509CRL_currArrayIndex < dinX509DataType->X509CRL.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytes, dinX509DataType->X509CRL.array[dinX509DataType_X509CRL_currArrayIndex].bytesLen);
							dinX509DataType_X509CRL_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 47;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 47;
			} else 			if ( dinX509DataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 6);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ChargingStatusResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":EVSEID,"urn:iso:15118:2:2010:MsgBody":SAScheduleTupleID,"urn:iso:15118:2:2010:MsgBody":EVSEMaxCurrent{0-1},"urn:iso:15118:2:2010:MsgBody":MeterInfo{0-1},"urn:iso:15118:2:2010:MsgBody":ReceiptRequired,"urn:iso:15118:2:2010:MsgBody":AC_EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_dinChargingStatusResType(bitstream_t* stream, struct dinChargingStatusResType* dinChargingStatusResType) {
	int grammarID = 48;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 48:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinChargingStatusResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 49;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 49:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinChargingStatusResType->EVSEID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinChargingStatusResType->EVSEID.bytes, dinChargingStatusResType->EVSEID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 50;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 50:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinChargingStatusResType->SAScheduleTupleID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 51;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 51:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReceiptRequired)] */
			if ( dinChargingStatusResType->EVSEMaxCurrent_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinChargingStatusResType->EVSEMaxCurrent );
				}
				grammarID = 52;
			} else 			if ( dinChargingStatusResType->MeterInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinMeterInfoType(stream, &dinChargingStatusResType->MeterInfo );
				}
				grammarID = 53;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 54;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 52:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReceiptRequired)] */
			if ( dinChargingStatusResType->MeterInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinMeterInfoType(stream, &dinChargingStatusResType->MeterInfo );
				}
				grammarID = 53;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 54;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 53:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReceiptRequired)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinChargingStatusResType->ReceiptRequired);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 54;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 54:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}AC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVSEStatusType(stream, &dinChargingStatusResType->AC_EVSEStatus );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,WeldingDetectionReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":DC_EVStatus)',  derivedBy='EXTENSION'.  */
static int encode_dinWeldingDetectionReqType(bitstream_t* stream, struct dinWeldingDetectionReqType* dinWeldingDetectionReqType) {
	int grammarID = 55;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 55:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinWeldingDetectionReqType->DC_EVStatus );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignaturePropertiesType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SignatureProperty{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSignaturePropertiesType(bitstream_t* stream, struct dinSignaturePropertiesType* dinSignaturePropertiesType) {
	int grammarID = 56;
	int done = 0;
	
	unsigned int dinSignaturePropertiesType_SignatureProperty_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 56:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty)] */
			if ( dinSignaturePropertiesType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertiesType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertiesType->Id.characters, dinSignaturePropertiesType->Id.charactersLen);
					}
				}
				grammarID = 57;
			} else 			if (dinSignaturePropertiesType_SignatureProperty_currArrayIndex < dinSignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinSignaturePropertyType(stream, &dinSignaturePropertiesType->SignatureProperty.array [dinSignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 58;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 57:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty)] */
			if (dinSignaturePropertiesType_SignatureProperty_currArrayIndex < dinSignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSignaturePropertyType(stream, &dinSignaturePropertiesType->SignatureProperty.array [dinSignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 58;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 58:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), END_ELEMENT] */
			if (dinSignaturePropertiesType_SignatureProperty_currArrayIndex < dinSignaturePropertiesType->SignatureProperty.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSignaturePropertyType(stream, &dinSignaturePropertiesType->SignatureProperty.array [dinSignaturePropertiesType_SignatureProperty_currArrayIndex++]);
				}
				grammarID = 58;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ContractAuthenticationReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":GenChallenge{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinContractAuthenticationReqType(bitstream_t* stream, struct dinContractAuthenticationReqType* dinContractAuthenticationReqType) {
	int grammarID = 59;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 59:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}GenChallenge), END_ELEMENT] */
			if ( dinContractAuthenticationReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinContractAuthenticationReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinContractAuthenticationReqType->Id.characters, dinContractAuthenticationReqType->Id.charactersLen);
					}
				}
				grammarID = 60;
			} else 			if ( dinContractAuthenticationReqType->GenChallenge_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinContractAuthenticationReqType->GenChallenge.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinContractAuthenticationReqType->GenChallenge.characters, dinContractAuthenticationReqType->GenChallenge.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 60:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}GenChallenge), END_ELEMENT] */
			if ( dinContractAuthenticationReqType->GenChallenge_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinContractAuthenticationReqType->GenChallenge.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinContractAuthenticationReqType->GenChallenge.characters, dinContractAuthenticationReqType->GenChallenge.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,DC_EVPowerDeliveryParameterType',  base type name='EVPowerDeliveryParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":DC_EVStatus,"urn:iso:15118:2:2010:MsgDataTypes":BulkChargingComplete{0-1},"urn:iso:15118:2:2010:MsgDataTypes":ChargingComplete)',  derivedBy='EXTENSION'.  */
static int encode_dinDC_EVPowerDeliveryParameterType(bitstream_t* stream, struct dinDC_EVPowerDeliveryParameterType* dinDC_EVPowerDeliveryParameterType) {
	int grammarID = 61;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 61:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinDC_EVPowerDeliveryParameterType->DC_EVStatus );
				}
				grammarID = 62;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 62:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingComplete)] */
			if ( dinDC_EVPowerDeliveryParameterType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVPowerDeliveryParameterType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 63;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVPowerDeliveryParameterType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 63:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingComplete)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVPowerDeliveryParameterType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EVSEChargeParameterType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinEVSEChargeParameterType(bitstream_t* stream, struct dinEVSEChargeParameterType* dinEVSEChargeParameterType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CableCheckReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":DC_EVStatus)',  derivedBy='EXTENSION'.  */
static int encode_dinCableCheckReqType(bitstream_t* stream, struct dinCableCheckReqType* dinCableCheckReqType) {
	int grammarID = 55;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 55:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinCableCheckReqType->DC_EVStatus );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,DC_EVChargeParameterType',  base type name='EVChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":DC_EVStatus,"urn:iso:15118:2:2010:MsgDataTypes":EVMaximumCurrentLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVMaximumPowerLimit{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVMaximumVoltageLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVEnergyCapacity{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVEnergyRequest{0-1},"urn:iso:15118:2:2010:MsgDataTypes":FullSOC{0-1},"urn:iso:15118:2:2010:MsgDataTypes":BulkSOC{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinDC_EVChargeParameterType(bitstream_t* stream, struct dinDC_EVChargeParameterType* dinDC_EVChargeParameterType) {
	int grammarID = 65;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 65:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinDC_EVChargeParameterType->DC_EVStatus );
				}
				grammarID = 66;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 66:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVMaximumCurrentLimit );
				}
				grammarID = 67;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 67:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumVoltageLimit)] */
			if ( dinDC_EVChargeParameterType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVMaximumPowerLimit );
				}
				grammarID = 68;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVMaximumVoltageLimit );
				}
				grammarID = 69;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 68:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVMaximumVoltageLimit );
				}
				grammarID = 69;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 69:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( dinDC_EVChargeParameterType->EVEnergyCapacity_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVEnergyCapacity );
				}
				grammarID = 70;
			} else 			if ( dinDC_EVChargeParameterType->EVEnergyRequest_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVEnergyRequest );
				}
				grammarID = 71;
			} else 			if ( dinDC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 72;
			} else 			if ( dinDC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 70:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( dinDC_EVChargeParameterType->EVEnergyRequest_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVChargeParameterType->EVEnergyRequest );
				}
				grammarID = 71;
			} else 			if ( dinDC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 72;
			} else 			if ( dinDC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 71:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FullSOC), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( dinDC_EVChargeParameterType->FullSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->FullSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 72;
			} else 			if ( dinDC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 72:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC), END_ELEMENT] */
			if ( dinDC_EVChargeParameterType->BulkSOC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVChargeParameterType->BulkSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SAScheduleListType',  base type name='SASchedulesType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":SAScheduleTuple{1-UNBOUNDED})',  derivedBy='EXTENSION'.  */
static int encode_dinSAScheduleListType(bitstream_t* stream, struct dinSAScheduleListType* dinSAScheduleListType) {
	int grammarID = 73;
	int done = 0;
	
	unsigned int dinSAScheduleListType_SAScheduleTuple_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 73:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTuple)] */
			if (dinSAScheduleListType_SAScheduleTuple_currArrayIndex < dinSAScheduleListType->SAScheduleTuple.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSAScheduleTupleType(stream, &dinSAScheduleListType->SAScheduleTuple.array [dinSAScheduleListType_SAScheduleTuple_currArrayIndex++]);
				}
				grammarID = 74;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 74:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTuple), END_ELEMENT] */
			if (dinSAScheduleListType_SAScheduleTuple_currArrayIndex < dinSAScheduleListType->SAScheduleTuple.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSAScheduleTupleType(stream, &dinSAScheduleListType->SAScheduleTuple.array [dinSAScheduleListType_SAScheduleTuple_currArrayIndex++]);
				}
				grammarID = 74;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,PMaxScheduleType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":PMaxScheduleID,"urn:iso:15118:2:2010:MsgDataTypes":PMaxScheduleEntry{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinPMaxScheduleType(bitstream_t* stream, struct dinPMaxScheduleType* dinPMaxScheduleType) {
	int grammarID = 75;
	int done = 0;
	
	unsigned int dinPMaxScheduleType_PMaxScheduleEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 75:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinPMaxScheduleType->PMaxScheduleID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 76;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 76:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry)] */
			if (dinPMaxScheduleType_PMaxScheduleEntry_currArrayIndex < dinPMaxScheduleType->PMaxScheduleEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPMaxScheduleEntryType(stream, &dinPMaxScheduleType->PMaxScheduleEntry.array [dinPMaxScheduleType_PMaxScheduleEntry_currArrayIndex++]);
				}
				grammarID = 77;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 77:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry), END_ELEMENT] */
			if (dinPMaxScheduleType_PMaxScheduleEntry_currArrayIndex < dinPMaxScheduleType->PMaxScheduleEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPMaxScheduleEntryType(stream, &dinPMaxScheduleType->PMaxScheduleEntry.array [dinPMaxScheduleType_PMaxScheduleEntry_currArrayIndex++]);
				}
				grammarID = 77;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServicePaymentSelectionReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":SelectedPaymentOption,"urn:iso:15118:2:2010:MsgBody":SelectedServiceList)',  derivedBy='EXTENSION'.  */
static int encode_dinServicePaymentSelectionReqType(bitstream_t* stream, struct dinServicePaymentSelectionReqType* dinServicePaymentSelectionReqType) {
	int grammarID = 78;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 78:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedPaymentOption)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinServicePaymentSelectionReqType->SelectedPaymentOption);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 79;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 79:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedServiceList)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSelectedServiceListType(stream, &dinServicePaymentSelectionReqType->SelectedServiceList );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,RelativeTimeIntervalType',  base type name='IntervalType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":start,"urn:iso:15118:2:2010:MsgDataTypes":duration{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinRelativeTimeIntervalType(bitstream_t* stream, struct dinRelativeTimeIntervalType* dinRelativeTimeIntervalType) {
	int grammarID = 80;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 80:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}start)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinRelativeTimeIntervalType->start);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 81;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 81:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}duration), END_ELEMENT] */
			if ( dinRelativeTimeIntervalType->duration_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinRelativeTimeIntervalType->duration);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EVStatusType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinEVStatusType(bitstream_t* stream, struct dinEVStatusType* dinEVStatusType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PreChargeResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2010:MsgBody":EVSEPresentVoltage)',  derivedBy='EXTENSION'.  */
static int encode_dinPreChargeResType(bitstream_t* stream, struct dinPreChargeResType* dinPreChargeResType) {
	int grammarID = 13;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 13:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinPreChargeResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 14;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 14:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinPreChargeResType->DC_EVSEStatus );
				}
				grammarID = 15;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 15:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinPreChargeResType->EVSEPresentVoltage );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,DC_EVSEChargeParameterType',  base type name='EVSEChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":DC_EVSEStatus,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMaximumCurrentLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMaximumPowerLimit{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVSEMaximumVoltageLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMinimumCurrentLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMinimumVoltageLimit,"urn:iso:15118:2:2010:MsgDataTypes":EVSECurrentRegulationTolerance{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVSEPeakCurrentRipple,"urn:iso:15118:2:2010:MsgDataTypes":EVSEEnergyToBeDelivered{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinDC_EVSEChargeParameterType(bitstream_t* stream, struct dinDC_EVSEChargeParameterType* dinDC_EVSEChargeParameterType) {
	int grammarID = 82;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 82:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinDC_EVSEChargeParameterType->DC_EVSEStatus );
				}
				grammarID = 83;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 83:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMaximumCurrentLimit );
				}
				grammarID = 84;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 84:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumVoltageLimit)] */
			if ( dinDC_EVSEChargeParameterType->EVSEMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMaximumPowerLimit );
				}
				grammarID = 85;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMaximumVoltageLimit );
				}
				grammarID = 86;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 85:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMaximumVoltageLimit );
				}
				grammarID = 86;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 86:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumCurrentLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMinimumCurrentLimit );
				}
				grammarID = 87;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 87:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumVoltageLimit)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEMinimumVoltageLimit );
				}
				grammarID = 88;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 88:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEPeakCurrentRipple)] */
			if ( dinDC_EVSEChargeParameterType->EVSECurrentRegulationTolerance_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSECurrentRegulationTolerance );
				}
				grammarID = 89;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEPeakCurrentRipple );
				}
				grammarID = 90;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 89:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEPeakCurrentRipple)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEPeakCurrentRipple );
				}
				grammarID = 90;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 90:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEEnergyToBeDelivered), END_ELEMENT] */
			if ( dinDC_EVSEChargeParameterType->EVSEEnergyToBeDelivered_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinDC_EVSEChargeParameterType->EVSEEnergyToBeDelivered );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PaymentDetailsResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":GenChallenge,"urn:iso:15118:2:2010:MsgBody":DateTimeNow)',  derivedBy='EXTENSION'.  */
static int encode_dinPaymentDetailsResType(bitstream_t* stream, struct dinPaymentDetailsResType* dinPaymentDetailsResType) {
	int grammarID = 91;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 91:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinPaymentDetailsResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 92;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 92:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}GenChallenge)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinPaymentDetailsResType->GenChallenge.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinPaymentDetailsResType->GenChallenge.characters, dinPaymentDetailsResType->GenChallenge.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 93;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 93:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DateTimeNow)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinPaymentDetailsResType->DateTimeNow);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,DSAKeyValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":P,"http://www.w3.org/2000/09/xmldsig#":Q){0-1},"http://www.w3.org/2000/09/xmldsig#":G{0-1},"http://www.w3.org/2000/09/xmldsig#":Y,"http://www.w3.org/2000/09/xmldsig#":J{0-1},("http://www.w3.org/2000/09/xmldsig#":Seed,"http://www.w3.org/2000/09/xmldsig#":PgenCounter){0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinDSAKeyValueType(bitstream_t* stream, struct dinDSAKeyValueType* dinDSAKeyValueType) {
	int grammarID = 94;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 94:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( dinDSAKeyValueType->P_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->P.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->P.bytes, dinDSAKeyValueType->P.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 95;
			} else 			if ( dinDSAKeyValueType->G_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->G.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->G.bytes, dinDSAKeyValueType->G.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 96;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Y.bytes, dinDSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 97;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 95:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q)] */
			if ( dinDSAKeyValueType->Q_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Q.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Q.bytes, dinDSAKeyValueType->Q.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 98;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 98:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( dinDSAKeyValueType->G_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->G.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->G.bytes, dinDSAKeyValueType->G.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 96;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Y.bytes, dinDSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 97;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 96:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Y.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Y.bytes, dinDSAKeyValueType->Y.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 97;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 97:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), END_ELEMENT] */
			if ( dinDSAKeyValueType->J_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->J.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->J.bytes, dinDSAKeyValueType->J.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 99;
			} else 			if ( dinDSAKeyValueType->Seed_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Seed.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Seed.bytes, dinDSAKeyValueType->Seed.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 100;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 99:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), END_ELEMENT] */
			if ( dinDSAKeyValueType->Seed_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->Seed.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->Seed.bytes, dinDSAKeyValueType->Seed.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 100;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 100:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter)] */
			if ( dinDSAKeyValueType->PgenCounter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDSAKeyValueType->PgenCounter.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinDSAKeyValueType->PgenCounter.bytes, dinDSAKeyValueType->PgenCounter.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SASchedulesType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinSASchedulesType(bitstream_t* stream, struct dinSASchedulesType* dinSASchedulesType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CertificateUpdateResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2010:MsgBody":ContractSignatureEncryptedPrivateKey,"urn:iso:15118:2:2010:MsgBody":DHParams,"urn:iso:15118:2:2010:MsgBody":ContractID,"urn:iso:15118:2:2010:MsgBody":RetryCounter)',  derivedBy='EXTENSION'.  */
static int encode_dinCertificateUpdateResType(bitstream_t* stream, struct dinCertificateUpdateResType* dinCertificateUpdateResType) {
	int grammarID = 101;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 101:
			/* FirstStartTag[ATTRIBUTE[STRING](Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateResType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCertificateUpdateResType->Id.characters, dinCertificateUpdateResType->Id.charactersLen);
					}
				}
				grammarID = 102;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 102:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinCertificateUpdateResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 103;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 103:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinCertificateChainType(stream, &dinCertificateUpdateResType->ContractSignatureCertChain );
				}
				grammarID = 104;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 104:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureEncryptedPrivateKey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateResType->ContractSignatureEncryptedPrivateKey.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateUpdateResType->ContractSignatureEncryptedPrivateKey.bytes, dinCertificateUpdateResType->ContractSignatureEncryptedPrivateKey.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 105;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 105:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateResType->DHParams.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateUpdateResType->DHParams.bytes, dinCertificateUpdateResType->DHParams.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 106;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 106:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateResType->ContractID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinCertificateUpdateResType->ContractID.characters, dinCertificateUpdateResType->ContractID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 107;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 107:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RetryCounter)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinCertificateUpdateResType->RetryCounter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EVChargeParameterType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinEVChargeParameterType(bitstream_t* stream, struct dinEVChargeParameterType* dinEVChargeParameterType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgHeader,MessageHeaderType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgHeader":SessionID,"urn:iso:15118:2:2010:MsgHeader":Notification{0-1},"http://www.w3.org/2000/09/xmldsig#":Signature{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinMessageHeaderType(bitstream_t* stream, struct dinMessageHeaderType* dinMessageHeaderType) {
	int grammarID = 108;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 108:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}SessionID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMessageHeaderType->SessionID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinMessageHeaderType->SessionID.bytes, dinMessageHeaderType->SessionID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 109;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 109:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}Notification), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), END_ELEMENT] */
			if ( dinMessageHeaderType->Notification_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinNotificationType(stream, &dinMessageHeaderType->Notification );
				}
				grammarID = 110;
			} else 			if ( dinMessageHeaderType->Signature_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinSignatureType(stream, &dinMessageHeaderType->Signature );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 110:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), END_ELEMENT] */
			if ( dinMessageHeaderType->Signature_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSignatureType(stream, &dinMessageHeaderType->Signature );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDef,BodyBaseType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinBodyBaseType(bitstream_t* stream, struct dinBodyBaseType* dinBodyBaseType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,KeyValueType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":DSAKeyValue|"http://www.w3.org/2000/09/xmldsig#":RSAKeyValue|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]))',  derivedBy='RESTRICTION'.  */
static int encode_dinKeyValueType(bitstream_t* stream, struct dinKeyValueType* dinKeyValueType) {
	int grammarID = 111;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 111:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( dinKeyValueType->DSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinDSAKeyValueType(stream, &dinKeyValueType->DSAKeyValue );
				}
				grammarID = 112;
			} else 			if ( dinKeyValueType->RSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinRSAKeyValueType(stream, &dinKeyValueType->RSAKeyValue );
				}
				grammarID = 112;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 112;
			} else 			if ( dinKeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyValueType->ANY.characters, dinKeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 113;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 112:
			/* Element[END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinKeyValueType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinKeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyValueType->ANY.characters, dinKeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 112;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 113:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( dinKeyValueType->DSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinDSAKeyValueType(stream, &dinKeyValueType->DSAKeyValue );
				}
				grammarID = 112;
			} else 			if ( dinKeyValueType->RSAKeyValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinRSAKeyValueType(stream, &dinKeyValueType->RSAKeyValue );
				}
				grammarID = 112;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 112;
			} else 			if ( dinKeyValueType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyValueType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyValueType->ANY.characters, dinKeyValueType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 113;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,IntervalType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinIntervalType(bitstream_t* stream, struct dinIntervalType* dinIntervalType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ChargeParameterDiscoveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":EVSEProcessing,"urn:iso:15118:2:2010:MsgDataTypes":SASchedules,"urn:iso:15118:2:2010:MsgDataTypes":EVSEChargeParameter)',  derivedBy='EXTENSION'.  */
static int encode_dinChargeParameterDiscoveryResType(bitstream_t* stream, struct dinChargeParameterDiscoveryResType* dinChargeParameterDiscoveryResType) {
	int grammarID = 114;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 114:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinChargeParameterDiscoveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 115;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 115:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinChargeParameterDiscoveryResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 116;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 116:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SASchedules)] */
			if ( dinChargeParameterDiscoveryResType->SAScheduleList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSAScheduleListType(stream, &dinChargeParameterDiscoveryResType->SAScheduleList );
				}
				grammarID = 117;
			} else 			if ( dinChargeParameterDiscoveryResType->SASchedules_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinSASchedulesType(stream, &dinChargeParameterDiscoveryResType->SASchedules );
				}
				grammarID = 117;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 117:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEChargeParameter)] */
			if ( dinChargeParameterDiscoveryResType->AC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVSEChargeParameterType(stream, &dinChargeParameterDiscoveryResType->AC_EVSEChargeParameter );
				}
				grammarID = 4;
			} else 			if ( dinChargeParameterDiscoveryResType->DC_EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinDC_EVSEChargeParameterType(stream, &dinChargeParameterDiscoveryResType->DC_EVSEChargeParameter );
				}
				grammarID = 4;
			} else 			if ( dinChargeParameterDiscoveryResType->EVSEChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_dinEVSEChargeParameterType(stream, &dinChargeParameterDiscoveryResType->EVSEChargeParameter );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PowerDeliveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ReadyToChargeState,"urn:iso:15118:2:2010:MsgBody":ChargingProfile{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVPowerDeliveryParameter{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinPowerDeliveryReqType(bitstream_t* stream, struct dinPowerDeliveryReqType* dinPowerDeliveryReqType) {
	int grammarID = 118;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 118:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReadyToChargeState)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinPowerDeliveryReqType->ReadyToChargeState);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 119;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 119:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter), END_ELEMENT] */
			if ( dinPowerDeliveryReqType->ChargingProfile_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinChargingProfileType(stream, &dinPowerDeliveryReqType->ChargingProfile );
				}
				grammarID = 120;
			} else 			if ( dinPowerDeliveryReqType->DC_EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinDC_EVPowerDeliveryParameterType(stream, &dinPowerDeliveryReqType->DC_EVPowerDeliveryParameter );
				}
				grammarID = 4;
			} else 			if ( dinPowerDeliveryReqType->EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_dinEVPowerDeliveryParameterType(stream, &dinPowerDeliveryReqType->EVPowerDeliveryParameter );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 120:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter), END_ELEMENT] */
			if ( dinPowerDeliveryReqType->DC_EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVPowerDeliveryParameterType(stream, &dinPowerDeliveryReqType->DC_EVPowerDeliveryParameter );
				}
				grammarID = 4;
			} else 			if ( dinPowerDeliveryReqType->EVPowerDeliveryParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinEVPowerDeliveryParameterType(stream, &dinPowerDeliveryReqType->EVPowerDeliveryParameter );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,CertificateChainType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":Certificate,"urn:iso:15118:2:2010:MsgDataTypes":SubCertificates{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinCertificateChainType(bitstream_t* stream, struct dinCertificateChainType* dinCertificateChainType) {
	int grammarID = 121;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 121:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Certificate)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateChainType->Certificate.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateChainType->Certificate.bytes, dinCertificateChainType->Certificate.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 122;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 122:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SubCertificates), END_ELEMENT] */
			if ( dinCertificateChainType->SubCertificates_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSubCertificatesType(stream, &dinCertificateChainType->SubCertificates );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,TransformsType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transform{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinTransformsType(bitstream_t* stream, struct dinTransformsType* dinTransformsType) {
	int grammarID = 123;
	int done = 0;
	
	unsigned int dinTransformsType_Transform_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 123:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform)] */
			if (dinTransformsType_Transform_currArrayIndex < dinTransformsType->Transform.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinTransformType(stream, &dinTransformsType->Transform.array [dinTransformsType_Transform_currArrayIndex++]);
				}
				grammarID = 124;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 124:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), END_ELEMENT] */
			if (dinTransformsType_Transform_currArrayIndex < dinTransformsType->Transform.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinTransformType(stream, &dinTransformsType->Transform.array [dinTransformsType_Transform_currArrayIndex++]);
				}
				grammarID = 124;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EntryType',  base type name='anyType',  content type='ELEMENT',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":TimeInterval)',  derivedBy='RESTRICTION'.  */
static int encode_dinEntryType(bitstream_t* stream, struct dinEntryType* dinEntryType) {
	int grammarID = 125;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 125:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval)] */
			if ( dinEntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinRelativeTimeIntervalType(stream, &dinEntryType->RelativeTimeInterval );
				}
				grammarID = 4;
			} else 			if ( dinEntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinIntervalType(stream, &dinEntryType->TimeInterval );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,SessionStopType',  base type name='BodyBaseType',  content type='EMPTY',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_dinSessionStopType(bitstream_t* stream, struct dinSessionStopType* dinSessionStopType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServiceDetailReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ServiceID)',  derivedBy='EXTENSION'.  */
static int encode_dinServiceDetailReqType(bitstream_t* stream, struct dinServiceDetailReqType* dinServiceDetailReqType) {
	int grammarID = 126;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 126:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, dinServiceDetailReqType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,DigestMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinDigestMethodType(bitstream_t* stream, struct dinDigestMethodType* dinDigestMethodType) {
	int grammarID = 18;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 18:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDigestMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinDigestMethodType->Algorithm.characters, dinDigestMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 19;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 19:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinDigestMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinDigestMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDigestMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinDigestMethodType->ANY.characters, dinDigestMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinDigestMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinDigestMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinDigestMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinDigestMethodType->ANY.characters, dinDigestMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ParameterType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":boolValue|"urn:iso:15118:2:2010:MsgDataTypes":byteValue|"urn:iso:15118:2:2010:MsgDataTypes":shortValue|"urn:iso:15118:2:2010:MsgDataTypes":intValue|"urn:iso:15118:2:2010:MsgDataTypes":physicalValue|"urn:iso:15118:2:2010:MsgDataTypes":stringValue)',  derivedBy='RESTRICTION'.  */
static int encode_dinParameterType(bitstream_t* stream, struct dinParameterType* dinParameterType) {
	int grammarID = 127;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 127:
			/* FirstStartTag[ATTRIBUTE[STRING](Name)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinParameterType->Name.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinParameterType->Name.characters, dinParameterType->Name.charactersLen);
					}
				}
				grammarID = 128;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 128:
			/* StartTag[ATTRIBUTE[ENUMERATION](ValueType)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, dinParameterType->ValueType);
				}
				grammarID = 129;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 129:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}stringValue)] */
			if ( dinParameterType->boolValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinParameterType->boolValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if ( dinParameterType->byteValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(dinParameterType->byteValue + 128));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if ( dinParameterType->shortValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinParameterType->shortValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if ( dinParameterType->intValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger32(stream, dinParameterType->intValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if ( dinParameterType->physicalValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinParameterType->physicalValue );
				}
				grammarID = 4;
			} else 			if ( dinParameterType->stringValue_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 5);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinParameterType->stringValue.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinParameterType->stringValue.characters, dinParameterType->stringValue.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ChargingStatusReqType',  base type name='BodyBaseType',  content type='EMPTY',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_dinChargingStatusReqType(bitstream_t* stream, struct dinChargingStatusReqType* dinChargingStatusReqType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureMethodType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":HMACOutputLength{0-1},(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSignatureMethodType(bitstream_t* stream, struct dinSignatureMethodType* dinSignatureMethodType) {
	int grammarID = 130;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 130:
			/* FirstStartTag[ATTRIBUTE[STRING](Algorithm)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureMethodType->Algorithm.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureMethodType->Algorithm.characters, dinSignatureMethodType->Algorithm.charactersLen);
					}
				}
				grammarID = 131;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 131:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinSignatureMethodType->HMACOutputLength_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinSignatureMethodType->HMACOutputLength);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 20;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureMethodType->ANY.characters, dinSignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 132;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureMethodType->ANY.characters, dinSignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 132:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinSignatureMethodType->HMACOutputLength_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinSignatureMethodType->HMACOutputLength);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 20;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinSignatureMethodType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureMethodType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureMethodType->ANY.characters, dinSignatureMethodType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 132;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CertificateInstallationReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":OEMProvisioningCert,"urn:iso:15118:2:2010:MsgBody":ListOfRootCertificateIDs,"urn:iso:15118:2:2010:MsgBody":DHParams)',  derivedBy='EXTENSION'.  */
static int encode_dinCertificateInstallationReqType(bitstream_t* stream, struct dinCertificateInstallationReqType* dinCertificateInstallationReqType) {
	int grammarID = 133;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 133:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}OEMProvisioningCert)] */
			if ( dinCertificateInstallationReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCertificateInstallationReqType->Id.characters, dinCertificateInstallationReqType->Id.charactersLen);
					}
				}
				grammarID = 134;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationReqType->OEMProvisioningCert.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateInstallationReqType->OEMProvisioningCert.bytes, dinCertificateInstallationReqType->OEMProvisioningCert.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 135;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 134:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}OEMProvisioningCert)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationReqType->OEMProvisioningCert.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateInstallationReqType->OEMProvisioningCert.bytes, dinCertificateInstallationReqType->OEMProvisioningCert.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 135;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 135:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ListOfRootCertificateIDs)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinListOfRootCertificateIDsType(stream, &dinCertificateInstallationReqType->ListOfRootCertificateIDs );
				}
				grammarID = 136;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 136:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationReqType->DHParams.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateInstallationReqType->DHParams.bytes, dinCertificateInstallationReqType->DHParams.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SalesTariffEntryType',  base type name='EntryType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2010:MsgDataTypes":TimeInterval),("urn:iso:15118:2:2010:MsgDataTypes":EPriceLevel,"urn:iso:15118:2:2010:MsgDataTypes":ConsumptionCost{0-UNBOUNDED}))',  derivedBy='EXTENSION'.  */
static int encode_dinSalesTariffEntryType(bitstream_t* stream, struct dinSalesTariffEntryType* dinSalesTariffEntryType) {
	int grammarID = 137;
	int done = 0;
	
	unsigned int dinSalesTariffEntryType_ConsumptionCost_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 137:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval)] */
			if ( dinSalesTariffEntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinRelativeTimeIntervalType(stream, &dinSalesTariffEntryType->RelativeTimeInterval );
				}
				grammarID = 138;
			} else 			if ( dinSalesTariffEntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinIntervalType(stream, &dinSalesTariffEntryType->TimeInterval );
				}
				grammarID = 138;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 138:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EPriceLevel)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(dinSalesTariffEntryType->EPriceLevel - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 139;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 139:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ConsumptionCost), END_ELEMENT] */
			if (dinSalesTariffEntryType_ConsumptionCost_currArrayIndex < dinSalesTariffEntryType->ConsumptionCost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinConsumptionCostType(stream, &dinSalesTariffEntryType->ConsumptionCost.array [dinSalesTariffEntryType_ConsumptionCost_currArrayIndex++]);
				}
				grammarID = 139;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServiceDiscoveryResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":PaymentOptions,"urn:iso:15118:2:2010:MsgBody":ChargeService,"urn:iso:15118:2:2010:MsgBody":ServiceList{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinServiceDiscoveryResType(bitstream_t* stream, struct dinServiceDiscoveryResType* dinServiceDiscoveryResType) {
	int grammarID = 140;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 140:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinServiceDiscoveryResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 141;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 141:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentOptions)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPaymentOptionsType(stream, &dinServiceDiscoveryResType->PaymentOptions );
				}
				grammarID = 142;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 142:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinServiceChargeType(stream, &dinServiceDiscoveryResType->ChargeService );
				}
				grammarID = 143;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 143:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceList), END_ELEMENT] */
			if ( dinServiceDiscoveryResType->ServiceList_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinServiceTagListType(stream, &dinServiceDiscoveryResType->ServiceList );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ParameterSetType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ParameterSetID,"urn:iso:15118:2:2010:MsgDataTypes":Parameter{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinParameterSetType(bitstream_t* stream, struct dinParameterSetType* dinParameterSetType) {
	int grammarID = 144;
	int done = 0;
	
	unsigned int dinParameterSetType_Parameter_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 144:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSetID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinParameterSetType->ParameterSetID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 145;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 145:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Parameter)] */
			if (dinParameterSetType_Parameter_currArrayIndex < dinParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinParameterType(stream, &dinParameterSetType->Parameter.array [dinParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 146;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 146:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Parameter), END_ELEMENT] */
			if (dinParameterSetType_Parameter_currArrayIndex < dinParameterSetType->Parameter.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinParameterType(stream, &dinParameterSetType->Parameter.array [dinParameterSetType_Parameter_currArrayIndex++]);
				}
				grammarID = 146;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CurrentDemandReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":DC_EVStatus,"urn:iso:15118:2:2010:MsgBody":EVTargetCurrent,"urn:iso:15118:2:2010:MsgBody":EVMaximumVoltageLimit{0-1},"urn:iso:15118:2:2010:MsgBody":EVMaximumCurrentLimit{0-1},"urn:iso:15118:2:2010:MsgBody":EVMaximumPowerLimit{0-1},"urn:iso:15118:2:2010:MsgBody":BulkChargingComplete{0-1},"urn:iso:15118:2:2010:MsgBody":ChargingComplete,"urn:iso:15118:2:2010:MsgBody":RemainingTimeToFullSoC{0-1},"urn:iso:15118:2:2010:MsgBody":RemainingTimeToBulkSoC{0-1},"urn:iso:15118:2:2010:MsgBody":EVTargetVoltage)',  derivedBy='EXTENSION'.  */
static int encode_dinCurrentDemandReqType(bitstream_t* stream, struct dinCurrentDemandReqType* dinCurrentDemandReqType) {
	int grammarID = 147;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 147:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinCurrentDemandReqType->DC_EVStatus );
				}
				grammarID = 148;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 148:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVTargetCurrent );
				}
				grammarID = 149;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 149:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete)] */
			if ( dinCurrentDemandReqType->EVMaximumVoltageLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumVoltageLimit );
				}
				grammarID = 150;
			} else 			if ( dinCurrentDemandReqType->EVMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumCurrentLimit );
				}
				grammarID = 151;
			} else 			if ( dinCurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 152;
			} else 			if ( dinCurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 150:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete)] */
			if ( dinCurrentDemandReqType->EVMaximumCurrentLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumCurrentLimit );
				}
				grammarID = 151;
			} else 			if ( dinCurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 152;
			} else 			if ( dinCurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 151:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete)] */
			if ( dinCurrentDemandReqType->EVMaximumPowerLimit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVMaximumPowerLimit );
				}
				grammarID = 152;
			} else 			if ( dinCurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 152:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete)] */
			if ( dinCurrentDemandReqType->BulkChargingComplete_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->BulkChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 153;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 153:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinCurrentDemandReqType->ChargingComplete);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 154;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 154:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage)] */
			if ( dinCurrentDemandReqType->RemainingTimeToFullSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->RemainingTimeToFullSoC );
				}
				grammarID = 155;
			} else 			if ( dinCurrentDemandReqType->RemainingTimeToBulkSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->RemainingTimeToBulkSoC );
				}
				grammarID = 156;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 155:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage)] */
			if ( dinCurrentDemandReqType->RemainingTimeToBulkSoC_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->RemainingTimeToBulkSoC );
				}
				grammarID = 156;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 156:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinCurrentDemandReqType->EVTargetVoltage );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PreChargeReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":DC_EVStatus,"urn:iso:15118:2:2010:MsgBody":EVTargetVoltage,"urn:iso:15118:2:2010:MsgBody":EVTargetCurrent)',  derivedBy='EXTENSION'.  */
static int encode_dinPreChargeReqType(bitstream_t* stream, struct dinPreChargeReqType* dinPreChargeReqType) {
	int grammarID = 157;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 157:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVStatusType(stream, &dinPreChargeReqType->DC_EVStatus );
				}
				grammarID = 158;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 158:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinPreChargeReqType->EVTargetVoltage );
				}
				grammarID = 159;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 159:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinPreChargeReqType->EVTargetCurrent );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":SignedInfo,"http://www.w3.org/2000/09/xmldsig#":SignatureValue,"http://www.w3.org/2000/09/xmldsig#":KeyInfo{0-1},"http://www.w3.org/2000/09/xmldsig#":Object{0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSignatureType(bitstream_t* stream, struct dinSignatureType* dinSignatureType) {
	int grammarID = 160;
	int done = 0;
	
	unsigned int dinSignatureType_Object_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 160:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo)] */
			if ( dinSignatureType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureType->Id.characters, dinSignatureType->Id.charactersLen);
					}
				}
				grammarID = 161;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinSignedInfoType(stream, &dinSignatureType->SignedInfo );
				}
				grammarID = 162;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 161:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSignedInfoType(stream, &dinSignatureType->SignedInfo );
				}
				grammarID = 162;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 162:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSignatureValueType(stream, &dinSignatureType->SignatureValue );
				}
				grammarID = 163;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 163:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), END_ELEMENT] */
			if ( dinSignatureType->KeyInfo_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinKeyInfoType(stream, &dinSignatureType->KeyInfo );
				}
				grammarID = 164;
			} else 			if (dinSignatureType_Object_currArrayIndex < dinSignatureType->Object.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinObjectType(stream, &dinSignatureType->Object.array [dinSignatureType_Object_currArrayIndex++]);
				}
				grammarID = 164;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 164:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), END_ELEMENT] */
			if (dinSignatureType_Object_currArrayIndex < dinSignatureType->Object.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinObjectType(stream, &dinSignatureType->Object.array [dinSignatureType_Object_currArrayIndex++]);
				}
				grammarID = 164;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ReferenceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transforms{0-1},"http://www.w3.org/2000/09/xmldsig#":DigestMethod,"http://www.w3.org/2000/09/xmldsig#":DigestValue)',  derivedBy='RESTRICTION'.  */
static int encode_dinReferenceType(bitstream_t* stream, struct dinReferenceType* dinReferenceType) {
	int grammarID = 165;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 165:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( dinReferenceType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->Id.characters, dinReferenceType->Id.charactersLen);
					}
				}
				grammarID = 166;
			} else 			if ( dinReferenceType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->Type.characters, dinReferenceType->Type.charactersLen);
					}
				}
				grammarID = 167;
			} else 			if ( dinReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->URI.characters, dinReferenceType->URI.charactersLen);
					}
				}
				grammarID = 168;
			} else 			if ( dinReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinReferenceType->Transforms );
				}
				grammarID = 169;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					errn = encode_dinDigestMethodType(stream, &dinReferenceType->DigestMethod );
				}
				grammarID = 170;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 166:
			/* StartTag[ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( dinReferenceType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->Type.characters, dinReferenceType->Type.charactersLen);
					}
				}
				grammarID = 167;
			} else 			if ( dinReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->URI.characters, dinReferenceType->URI.charactersLen);
					}
				}
				grammarID = 168;
			} else 			if ( dinReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinReferenceType->Transforms );
				}
				grammarID = 169;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					errn = encode_dinDigestMethodType(stream, &dinReferenceType->DigestMethod );
				}
				grammarID = 170;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 167:
			/* StartTag[ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( dinReferenceType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinReferenceType->URI.characters, dinReferenceType->URI.charactersLen);
					}
				}
				grammarID = 168;
			} else 			if ( dinReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinReferenceType->Transforms );
				}
				grammarID = 169;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_dinDigestMethodType(stream, &dinReferenceType->DigestMethod );
				}
				grammarID = 170;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 168:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( dinReferenceType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinReferenceType->Transforms );
				}
				grammarID = 169;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinDigestMethodType(stream, &dinReferenceType->DigestMethod );
				}
				grammarID = 170;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 169:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDigestMethodType(stream, &dinReferenceType->DigestMethod );
				}
				grammarID = 170;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 170:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinReferenceType->DigestValue.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinReferenceType->DigestValue.bytes, dinReferenceType->DigestValue.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ProfileEntryType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ChargingProfileEntryStart,"urn:iso:15118:2:2010:MsgDataTypes":ChargingProfileEntryMaxPower)',  derivedBy='RESTRICTION'.  */
static int encode_dinProfileEntryType(bitstream_t* stream, struct dinProfileEntryType* dinProfileEntryType) {
	int grammarID = 171;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 171:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryStart)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinProfileEntryType->ChargingProfileEntryStart);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 172;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 172:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryMaxPower)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinProfileEntryType->ChargingProfileEntryMaxPower);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDef,#AnonType_V2G_Message',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDef":Header,"urn:iso:15118:2:2010:MsgDef":Body)',  derivedBy='RESTRICTION'.  */
static int encode_dinAnonType_V2G_Message(bitstream_t* stream, struct dinAnonType_V2G_Message* dinAnonType_V2G_Message) {
	int grammarID = 173;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 173:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Header)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinMessageHeaderType(stream, &dinAnonType_V2G_Message->Header );
				}
				grammarID = 174;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 174:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Body)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinBodyType(stream, &dinAnonType_V2G_Message->Body );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ChargeParameterDiscoveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":EVRequestedEnergyTransferType,"urn:iso:15118:2:2010:MsgDataTypes":EVChargeParameter)',  derivedBy='EXTENSION'.  */
static int encode_dinChargeParameterDiscoveryReqType(bitstream_t* stream, struct dinChargeParameterDiscoveryReqType* dinChargeParameterDiscoveryReqType) {
	int grammarID = 175;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 175:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVRequestedEnergyTransferType)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, dinChargeParameterDiscoveryReqType->EVRequestedEnergyTransferType);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 176;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 176:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVChargeParameter)] */
			if ( dinChargeParameterDiscoveryReqType->AC_EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVChargeParameterType(stream, &dinChargeParameterDiscoveryReqType->AC_EVChargeParameter );
				}
				grammarID = 4;
			} else 			if ( dinChargeParameterDiscoveryReqType->DC_EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinDC_EVChargeParameterType(stream, &dinChargeParameterDiscoveryReqType->DC_EVChargeParameter );
				}
				grammarID = 4;
			} else 			if ( dinChargeParameterDiscoveryReqType->EVChargeParameter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					errn = encode_dinEVChargeParameterType(stream, &dinChargeParameterDiscoveryReqType->EVChargeParameter );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ConsumptionCostType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":startValue,"urn:iso:15118:2:2010:MsgDataTypes":Cost{0-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinConsumptionCostType(bitstream_t* stream, struct dinConsumptionCostType* dinConsumptionCostType) {
	int grammarID = 177;
	int done = 0;
	
	unsigned int dinConsumptionCostType_Cost_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 177:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}startValue)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinConsumptionCostType->startValue);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 178;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 178:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Cost), END_ELEMENT] */
			if (dinConsumptionCostType_Cost_currArrayIndex < dinConsumptionCostType->Cost.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinCostType(stream, &dinConsumptionCostType->Cost.array [dinConsumptionCostType_Cost_currArrayIndex++]);
				}
				grammarID = 178;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,RSAKeyValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Modulus,"http://www.w3.org/2000/09/xmldsig#":Exponent)',  derivedBy='RESTRICTION'.  */
static int encode_dinRSAKeyValueType(bitstream_t* stream, struct dinRSAKeyValueType* dinRSAKeyValueType) {
	int grammarID = 179;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 179:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinRSAKeyValueType->Modulus.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinRSAKeyValueType->Modulus.bytes, dinRSAKeyValueType->Modulus.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 180;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 180:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinRSAKeyValueType->Exponent.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinRSAKeyValueType->Exponent.bytes, dinRSAKeyValueType->Exponent.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ServiceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ServiceTag,"urn:iso:15118:2:2010:MsgDataTypes":FreeService)',  derivedBy='RESTRICTION'.  */
static int encode_dinServiceType(bitstream_t* stream, struct dinServiceType* dinServiceType) {
	int grammarID = 181;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 181:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceTag)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinServiceTagType(stream, &dinServiceType->ServiceTag );
				}
				grammarID = 182;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 182:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FreeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinServiceType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ServiceTagListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":Service{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinServiceTagListType(bitstream_t* stream, struct dinServiceTagListType* dinServiceTagListType) {
	int grammarID = 183;
	int done = 0;
	
	unsigned int dinServiceTagListType_Service_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 183:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service)] */
			if (dinServiceTagListType_Service_currArrayIndex < dinServiceTagListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinServiceType(stream, &dinServiceTagListType->Service.array [dinServiceTagListType_Service_currArrayIndex++]);
				}
				grammarID = 184;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 184:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service), END_ELEMENT] */
			if (dinServiceTagListType_Service_currArrayIndex < dinServiceTagListType->Service.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinServiceType(stream, &dinServiceTagListType->Service.array [dinServiceTagListType_Service_currArrayIndex++]);
				}
				grammarID = 184;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EVSEStatusType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinEVSEStatusType(bitstream_t* stream, struct dinEVSEStatusType* dinEVSEStatusType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,SessionSetupResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":EVSEID,"urn:iso:15118:2:2010:MsgBody":DateTimeNow{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinSessionSetupResType(bitstream_t* stream, struct dinSessionSetupResType* dinSessionSetupResType) {
	int grammarID = 185;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 185:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinSessionSetupResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 186;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 186:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSessionSetupResType->EVSEID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSessionSetupResType->EVSEID.bytes, dinSessionSetupResType->EVSEID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 187;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 187:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DateTimeNow), END_ELEMENT] */
			if ( dinSessionSetupResType->DateTimeNow_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinSessionSetupResType->DateTimeNow);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,EVPowerDeliveryParameterType',  base type name='anyType',  content type='EMPTY',  isAbstract='true',  hasTypeId='false',  final='0',  block='0',  derivedBy='RESTRICTION'.  */
static int encode_dinEVPowerDeliveryParameterType(bitstream_t* stream, struct dinEVPowerDeliveryParameterType* dinEVPowerDeliveryParameterType) {
	int grammarID = 64;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 64:
			/* FirstStartTag[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,X509IssuerSerialType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":X509IssuerName,"http://www.w3.org/2000/09/xmldsig#":X509SerialNumber)',  derivedBy='RESTRICTION'.  */
static int encode_dinX509IssuerSerialType(bitstream_t* stream, struct dinX509IssuerSerialType* dinX509IssuerSerialType) {
	int grammarID = 188;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 188:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinX509IssuerSerialType->X509IssuerName.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinX509IssuerSerialType->X509IssuerName.characters, dinX509IssuerSerialType->X509IssuerName.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 189;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 189:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinX509IssuerSerialType->X509SerialNumber);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SelectedServiceType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ServiceID,"urn:iso:15118:2:2010:MsgDataTypes":ParameterSetID{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinSelectedServiceType(bitstream_t* stream, struct dinSelectedServiceType* dinSelectedServiceType) {
	int grammarID = 190;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 190:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, dinSelectedServiceType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 191;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 191:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSetID), END_ELEMENT] */
			if ( dinSelectedServiceType->ParameterSetID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinSelectedServiceType->ParameterSetID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,MeteringReceiptResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":AC_EVSEStatus)',  derivedBy='EXTENSION'.  */
static int encode_dinMeteringReceiptResType(bitstream_t* stream, struct dinMeteringReceiptResType* dinMeteringReceiptResType) {
	int grammarID = 192;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 192:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinMeteringReceiptResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 54;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 54:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}AC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVSEStatusType(stream, &dinMeteringReceiptResType->AC_EVSEStatus );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,DC_EVStatusType',  base type name='EVStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":EVReady,"urn:iso:15118:2:2010:MsgDataTypes":EVCabinConditioning{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVRESSConditioning{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVErrorCode,"urn:iso:15118:2:2010:MsgDataTypes":EVRESSSOC)',  derivedBy='EXTENSION'.  */
static int encode_dinDC_EVStatusType(bitstream_t* stream, struct dinDC_EVStatusType* dinDC_EVStatusType) {
	int grammarID = 193;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 193:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVReady)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVStatusType->EVReady);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 194;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 194:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVCabinConditioning), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSConditioning), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVErrorCode)] */
			if ( dinDC_EVStatusType->EVCabinConditioning_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVStatusType->EVCabinConditioning);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 195;
			} else 			if ( dinDC_EVStatusType->EVRESSConditioning_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVStatusType->EVRESSConditioning);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 196;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinDC_EVStatusType->EVErrorCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 197;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 195:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSConditioning), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVErrorCode)] */
			if ( dinDC_EVStatusType->EVRESSConditioning_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinDC_EVStatusType->EVRESSConditioning);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 196;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinDC_EVStatusType->EVErrorCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 197;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 196:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVErrorCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinDC_EVStatusType->EVErrorCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 197;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 197:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSSOC)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(dinDC_EVStatusType->EVRESSSOC - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,PhysicalValueType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":Multiplier,"urn:iso:15118:2:2010:MsgDataTypes":Unit{0-1},"urn:iso:15118:2:2010:MsgDataTypes":Value)',  derivedBy='RESTRICTION'.  */
static int encode_dinPhysicalValueType(bitstream_t* stream, struct dinPhysicalValueType* dinPhysicalValueType) {
	int grammarID = 198;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 198:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Multiplier)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(dinPhysicalValueType->Multiplier + 3));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 199;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 199:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Value)] */
			if ( dinPhysicalValueType->Unit_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinPhysicalValueType->Unit);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 200;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinPhysicalValueType->Value);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 200:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Value)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinPhysicalValueType->Value);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ManifestType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Reference{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinManifestType(bitstream_t* stream, struct dinManifestType* dinManifestType) {
	int grammarID = 201;
	int done = 0;
	
	unsigned int dinManifestType_Reference_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 201:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if ( dinManifestType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinManifestType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinManifestType->Id.characters, dinManifestType->Id.charactersLen);
					}
				}
				grammarID = 202;
			} else 			if (dinManifestType_Reference_currArrayIndex < dinManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinReferenceType(stream, &dinManifestType->Reference.array [dinManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 203;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 202:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if (dinManifestType_Reference_currArrayIndex < dinManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinReferenceType(stream, &dinManifestType->Reference.array [dinManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 203;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 203:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), END_ELEMENT] */
			if (dinManifestType_Reference_currArrayIndex < dinManifestType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinReferenceType(stream, &dinManifestType->Reference.array [dinManifestType_Reference_currArrayIndex++]);
				}
				grammarID = 203;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,PMaxScheduleEntryType',  base type name='EntryType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2010:MsgDataTypes":TimeInterval),("urn:iso:15118:2:2010:MsgDataTypes":PMax))',  derivedBy='EXTENSION'.  */
static int encode_dinPMaxScheduleEntryType(bitstream_t* stream, struct dinPMaxScheduleEntryType* dinPMaxScheduleEntryType) {
	int grammarID = 204;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 204:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval)] */
			if ( dinPMaxScheduleEntryType->RelativeTimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinRelativeTimeIntervalType(stream, &dinPMaxScheduleEntryType->RelativeTimeInterval );
				}
				grammarID = 205;
			} else 			if ( dinPMaxScheduleEntryType->TimeInterval_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinIntervalType(stream, &dinPMaxScheduleEntryType->TimeInterval );
				}
				grammarID = 205;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 205:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMax)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinPMaxScheduleEntryType->PMax);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ServiceParameterListType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ParameterSet{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinServiceParameterListType(bitstream_t* stream, struct dinServiceParameterListType* dinServiceParameterListType) {
	int grammarID = 206;
	int done = 0;
	
	unsigned int dinServiceParameterListType_ParameterSet_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 206:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSet)] */
			if (dinServiceParameterListType_ParameterSet_currArrayIndex < dinServiceParameterListType->ParameterSet.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinParameterSetType(stream, &dinServiceParameterListType->ParameterSet.array [dinServiceParameterListType_ParameterSet_currArrayIndex++]);
				}
				grammarID = 207;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 207:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSet), END_ELEMENT] */
			if (dinServiceParameterListType_ParameterSet_currArrayIndex < dinServiceParameterListType->ParameterSet.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinParameterSetType(stream, &dinServiceParameterListType->ParameterSet.array [dinServiceParameterListType_ParameterSet_currArrayIndex++]);
				}
				grammarID = 207;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignatureValueType',  base type name='base64Binary',  content type='SIMPLE',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  derivedBy='EXTENSION'.  */
static int encode_dinSignatureValueType(bitstream_t* stream, struct dinSignatureValueType* dinSignatureValueType) {
	int grammarID = 208;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 208:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), CHARACTERS[BINARY_BASE64]] */
			if ( dinSignatureValueType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureValueType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignatureValueType->Id.characters, dinSignatureValueType->Id.charactersLen);
					}
				}
				grammarID = 209;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureValueType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, dinSignatureValueType->CONTENT.bytes, dinSignatureValueType->CONTENT.bytesLen);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 209:
			/* StartTag[CHARACTERS[BINARY_BASE64]] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignatureValueType->CONTENT.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, dinSignatureValueType->CONTENT.bytes, dinSignatureValueType->CONTENT.bytesLen);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,PaymentOptionsType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":PaymentOption{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinPaymentOptionsType(bitstream_t* stream, struct dinPaymentOptionsType* dinPaymentOptionsType) {
	int grammarID = 210;
	int done = 0;
	
	unsigned int dinPaymentOptionsType_PaymentOption_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 210:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PaymentOption)] */
			if (dinPaymentOptionsType_PaymentOption_currArrayIndex < dinPaymentOptionsType->PaymentOption.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinPaymentOptionsType->PaymentOption.array[dinPaymentOptionsType_PaymentOption_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 211;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 211:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PaymentOption), END_ELEMENT] */
			if (dinPaymentOptionsType_PaymentOption_currArrayIndex < dinPaymentOptionsType->PaymentOption.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinPaymentOptionsType->PaymentOption.array[dinPaymentOptionsType_PaymentOption_currArrayIndex++]);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 211;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ServiceTagType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":ServiceID,"urn:iso:15118:2:2010:MsgDataTypes":ServiceName{0-1},"urn:iso:15118:2:2010:MsgDataTypes":ServiceCategory,"urn:iso:15118:2:2010:MsgDataTypes":ServiceScope{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinServiceTagType(bitstream_t* stream, struct dinServiceTagType* dinServiceTagType) {
	int grammarID = 212;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 212:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, dinServiceTagType->ServiceID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 213;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 213:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCategory)] */
			if ( dinServiceTagType->ServiceName_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinServiceTagType->ServiceName.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinServiceTagType->ServiceName.characters, dinServiceTagType->ServiceName.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 214;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinServiceTagType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 215;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 214:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCategory)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinServiceTagType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 215;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 215:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), END_ELEMENT] */
			if ( dinServiceTagType->ServiceScope_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinServiceTagType->ServiceScope.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinServiceTagType->ServiceScope.characters, dinServiceTagType->ServiceScope.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,AC_EVSEStatusType',  base type name='EVSEStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":PowerSwitchClosed,"urn:iso:15118:2:2010:MsgDataTypes":RCD,"urn:iso:15118:2:2010:MsgDataTypes":NotificationMaxDelay,"urn:iso:15118:2:2010:MsgDataTypes":EVSENotification)',  derivedBy='EXTENSION'.  */
static int encode_dinAC_EVSEStatusType(bitstream_t* stream, struct dinAC_EVSEStatusType* dinAC_EVSEStatusType) {
	int grammarID = 216;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 216:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PowerSwitchClosed)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinAC_EVSEStatusType->PowerSwitchClosed);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 217;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 217:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RCD)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinAC_EVSEStatusType->RCD);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 218;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 218:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NotificationMaxDelay)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinAC_EVSEStatusType->NotificationMaxDelay);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 219;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 219:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSENotification)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinAC_EVSEStatusType->EVSENotification);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CertificateUpdateReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2010:MsgBody":ContractID,"urn:iso:15118:2:2010:MsgBody":ListOfRootCertificateIDs,"urn:iso:15118:2:2010:MsgBody":DHParams)',  derivedBy='EXTENSION'.  */
static int encode_dinCertificateUpdateReqType(bitstream_t* stream, struct dinCertificateUpdateReqType* dinCertificateUpdateReqType) {
	int grammarID = 220;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 220:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain)] */
			if ( dinCertificateUpdateReqType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateReqType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCertificateUpdateReqType->Id.characters, dinCertificateUpdateReqType->Id.charactersLen);
					}
				}
				grammarID = 221;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinCertificateChainType(stream, &dinCertificateUpdateReqType->ContractSignatureCertChain );
				}
				grammarID = 222;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 221:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinCertificateChainType(stream, &dinCertificateUpdateReqType->ContractSignatureCertChain );
				}
				grammarID = 222;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 222:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateReqType->ContractID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinCertificateUpdateReqType->ContractID.characters, dinCertificateUpdateReqType->ContractID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 135;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 135:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ListOfRootCertificateIDs)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinListOfRootCertificateIDsType(stream, &dinCertificateUpdateReqType->ListOfRootCertificateIDs );
				}
				grammarID = 136;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 136:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateUpdateReqType->DHParams.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateUpdateReqType->DHParams.bytes, dinCertificateUpdateReqType->DHParams.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServicePaymentSelectionResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode)',  derivedBy='EXTENSION'.  */
static int encode_dinServicePaymentSelectionResType(bitstream_t* stream, struct dinServicePaymentSelectionResType* dinServicePaymentSelectionResType) {
	int grammarID = 223;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 223:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinServicePaymentSelectionResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SAScheduleTupleType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":SAScheduleTupleID,"urn:iso:15118:2:2010:MsgDataTypes":PMaxSchedule,"urn:iso:15118:2:2010:MsgDataTypes":SalesTariff{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinSAScheduleTupleType(bitstream_t* stream, struct dinSAScheduleTupleType* dinSAScheduleTupleType) {
	int grammarID = 224;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 224:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinSAScheduleTupleType->SAScheduleTupleID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 225;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 225:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxSchedule)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPMaxScheduleType(stream, &dinSAScheduleTupleType->PMaxSchedule );
				}
				grammarID = 226;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 226:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariff), END_ELEMENT] */
			if ( dinSAScheduleTupleType->SalesTariff_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSalesTariffType(stream, &dinSAScheduleTupleType->SalesTariff );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ChargingProfileType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":SAScheduleTupleID,"urn:iso:15118:2:2010:MsgDataTypes":ProfileEntry{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinChargingProfileType(bitstream_t* stream, struct dinChargingProfileType* dinChargingProfileType) {
	int grammarID = 227;
	int done = 0;
	
	unsigned int dinChargingProfileType_ProfileEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 227:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTupleID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinChargingProfileType->SAScheduleTupleID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 228;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 228:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProfileEntry)] */
			if (dinChargingProfileType_ProfileEntry_currArrayIndex < dinChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinProfileEntryType(stream, &dinChargingProfileType->ProfileEntry.array [dinChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 229;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 229:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProfileEntry), END_ELEMENT] */
			if (dinChargingProfileType_ProfileEntry_currArrayIndex < dinChargingProfileType->ProfileEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinProfileEntryType(stream, &dinChargingProfileType->ProfileEntry.array [dinChargingProfileType_ProfileEntry_currArrayIndex++]);
				}
				grammarID = 229;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,ServiceDiscoveryReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ServiceScope{0-1},"urn:iso:15118:2:2010:MsgBody":ServiceCategory{0-1})',  derivedBy='EXTENSION'.  */
static int encode_dinServiceDiscoveryReqType(bitstream_t* stream, struct dinServiceDiscoveryReqType* dinServiceDiscoveryReqType) {
	int grammarID = 230;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 230:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceCategory), END_ELEMENT] */
			if ( dinServiceDiscoveryReqType->ServiceScope_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinServiceDiscoveryReqType->ServiceScope.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinServiceDiscoveryReqType->ServiceScope.characters, dinServiceDiscoveryReqType->ServiceScope.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 231;
			} else 			if ( dinServiceDiscoveryReqType->ServiceCategory_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinServiceDiscoveryReqType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 231:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceCategory), END_ELEMENT] */
			if ( dinServiceDiscoveryReqType->ServiceCategory_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinServiceDiscoveryReqType->ServiceCategory);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,AC_EVSEChargeParameterType',  base type name='EVSEChargeParameterType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":AC_EVSEStatus,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMaxVoltage,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMaxCurrent,"urn:iso:15118:2:2010:MsgDataTypes":EVSEMinCurrent)',  derivedBy='EXTENSION'.  */
static int encode_dinAC_EVSEChargeParameterType(bitstream_t* stream, struct dinAC_EVSEChargeParameterType* dinAC_EVSEChargeParameterType) {
	int grammarID = 232;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 232:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinAC_EVSEStatusType(stream, &dinAC_EVSEChargeParameterType->AC_EVSEStatus );
				}
				grammarID = 233;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 233:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxVoltage)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVSEChargeParameterType->EVSEMaxVoltage );
				}
				grammarID = 234;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 234:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVSEChargeParameterType->EVSEMaxCurrent );
				}
				grammarID = 235;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 235:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinCurrent)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinAC_EVSEChargeParameterType->EVSEMinCurrent );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,KeyInfoType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":KeyName|"http://www.w3.org/2000/09/xmldsig#":KeyValue|"http://www.w3.org/2000/09/xmldsig#":RetrievalMethod|"http://www.w3.org/2000/09/xmldsig#":X509Data|"http://www.w3.org/2000/09/xmldsig#":PGPData|"http://www.w3.org/2000/09/xmldsig#":SPKIData|"http://www.w3.org/2000/09/xmldsig#":MgmtData|(WC[##other:"http://www.w3.org/2000/09/xmldsig#"])){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinKeyInfoType(bitstream_t* stream, struct dinKeyInfoType* dinKeyInfoType) {
	int grammarID = 236;
	int done = 0;
	int wcDone = 0;
	
	unsigned int dinKeyInfoType_KeyName_currArrayIndex = 0;
	unsigned int dinKeyInfoType_KeyValue_currArrayIndex = 0;
	unsigned int dinKeyInfoType_RetrievalMethod_currArrayIndex = 0;
	unsigned int dinKeyInfoType_X509Data_currArrayIndex = 0;
	unsigned int dinKeyInfoType_PGPData_currArrayIndex = 0;
	unsigned int dinKeyInfoType_SPKIData_currArrayIndex = 0;
	unsigned int dinKeyInfoType_MgmtData_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 236:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if ( dinKeyInfoType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyInfoType->Id.characters, dinKeyInfoType->Id.charactersLen);
					}
				}
				grammarID = 237;
			} else 			if (dinKeyInfoType_KeyName_currArrayIndex < dinKeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].characters, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen);
							dinKeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_KeyValue_currArrayIndex < dinKeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_dinKeyValueType(stream, &dinKeyInfoType->KeyValue.array [dinKeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_RetrievalMethod_currArrayIndex < dinKeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_dinRetrievalMethodType(stream, &dinKeyInfoType->RetrievalMethod.array [dinKeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_X509Data_currArrayIndex < dinKeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_dinX509DataType(stream, &dinKeyInfoType->X509Data.array [dinKeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_PGPData_currArrayIndex < dinKeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_dinPGPDataType(stream, &dinKeyInfoType->PGPData.array [dinKeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_SPKIData_currArrayIndex < dinKeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					errn = encode_dinSPKIDataType(stream, &dinKeyInfoType->SPKIData.array [dinKeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_MgmtData_currArrayIndex < dinKeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 7);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].characters, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen);
							dinKeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 238;
			} else 			if ( dinKeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 9);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyInfoType->ANY.characters, dinKeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 239;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 237:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (dinKeyInfoType_KeyName_currArrayIndex < dinKeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].characters, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen);
							dinKeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_KeyValue_currArrayIndex < dinKeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_dinKeyValueType(stream, &dinKeyInfoType->KeyValue.array [dinKeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_RetrievalMethod_currArrayIndex < dinKeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_dinRetrievalMethodType(stream, &dinKeyInfoType->RetrievalMethod.array [dinKeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_X509Data_currArrayIndex < dinKeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_dinX509DataType(stream, &dinKeyInfoType->X509Data.array [dinKeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_PGPData_currArrayIndex < dinKeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_dinPGPDataType(stream, &dinKeyInfoType->PGPData.array [dinKeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_SPKIData_currArrayIndex < dinKeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_dinSPKIDataType(stream, &dinKeyInfoType->SPKIData.array [dinKeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_MgmtData_currArrayIndex < dinKeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].characters, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen);
							dinKeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 238;
			} else 			if ( dinKeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyInfoType->ANY.characters, dinKeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 239;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 238:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (dinKeyInfoType_KeyName_currArrayIndex < dinKeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].characters, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen);
							dinKeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_KeyValue_currArrayIndex < dinKeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_dinKeyValueType(stream, &dinKeyInfoType->KeyValue.array [dinKeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_RetrievalMethod_currArrayIndex < dinKeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_dinRetrievalMethodType(stream, &dinKeyInfoType->RetrievalMethod.array [dinKeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_X509Data_currArrayIndex < dinKeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_dinX509DataType(stream, &dinKeyInfoType->X509Data.array [dinKeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_PGPData_currArrayIndex < dinKeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_dinPGPDataType(stream, &dinKeyInfoType->PGPData.array [dinKeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_SPKIData_currArrayIndex < dinKeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_dinSPKIDataType(stream, &dinKeyInfoType->SPKIData.array [dinKeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_MgmtData_currArrayIndex < dinKeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].characters, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen);
							dinKeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 238;
			} else 			if ( dinKeyInfoType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinKeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 9);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyInfoType->ANY.characters, dinKeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 238;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 239:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (dinKeyInfoType_KeyName_currArrayIndex < dinKeyInfoType->KeyName.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].characters, dinKeyInfoType->KeyName.array[dinKeyInfoType_KeyName_currArrayIndex].charactersLen);
							dinKeyInfoType_KeyName_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_KeyValue_currArrayIndex < dinKeyInfoType->KeyValue.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 1);
				if(errn == 0) {
					errn = encode_dinKeyValueType(stream, &dinKeyInfoType->KeyValue.array [dinKeyInfoType_KeyValue_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_RetrievalMethod_currArrayIndex < dinKeyInfoType->RetrievalMethod.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 2);
				if(errn == 0) {
					errn = encode_dinRetrievalMethodType(stream, &dinKeyInfoType->RetrievalMethod.array [dinKeyInfoType_RetrievalMethod_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_X509Data_currArrayIndex < dinKeyInfoType->X509Data.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 3);
				if(errn == 0) {
					errn = encode_dinX509DataType(stream, &dinKeyInfoType->X509Data.array [dinKeyInfoType_X509Data_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_PGPData_currArrayIndex < dinKeyInfoType->PGPData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 4);
				if(errn == 0) {
					errn = encode_dinPGPDataType(stream, &dinKeyInfoType->PGPData.array [dinKeyInfoType_PGPData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_SPKIData_currArrayIndex < dinKeyInfoType->SPKIData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 5);
				if(errn == 0) {
					errn = encode_dinSPKIDataType(stream, &dinKeyInfoType->SPKIData.array [dinKeyInfoType_SPKIData_currArrayIndex++]);
				}
				grammarID = 238;
			} else 			if (dinKeyInfoType_MgmtData_currArrayIndex < dinKeyInfoType->MgmtData.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 6);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].characters, dinKeyInfoType->MgmtData.array[dinKeyInfoType_MgmtData_currArrayIndex].charactersLen);
							dinKeyInfoType_MgmtData_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 238;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 238;
			} else 			if ( dinKeyInfoType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 4, 8);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinKeyInfoType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinKeyInfoType->ANY.characters, dinKeyInfoType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 239;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,PaymentDetailsReqType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ContractID,"urn:iso:15118:2:2010:MsgBody":ContractSignatureCertChain)',  derivedBy='EXTENSION'.  */
static int encode_dinPaymentDetailsReqType(bitstream_t* stream, struct dinPaymentDetailsReqType* dinPaymentDetailsReqType) {
	int grammarID = 240;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 240:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinPaymentDetailsReqType->ContractID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinPaymentDetailsReqType->ContractID.characters, dinPaymentDetailsReqType->ContractID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 241;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 241:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinCertificateChainType(stream, &dinPaymentDetailsReqType->ContractSignatureCertChain );
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CableCheckResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":DC_EVSEStatus,"urn:iso:15118:2:2010:MsgBody":EVSEProcessing)',  derivedBy='EXTENSION'.  */
static int encode_dinCableCheckResType(bitstream_t* stream, struct dinCableCheckResType* dinCableCheckResType) {
	int grammarID = 242;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 242:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinCableCheckResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 243;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 243:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinDC_EVSEStatusType(stream, &dinCableCheckResType->DC_EVSEStatus );
				}
				grammarID = 17;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 17:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEProcessing)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 1, dinCableCheckResType->EVSEProcessing);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,ObjectType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##any])){0-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinObjectType(bitstream_t* stream, struct dinObjectType* dinObjectType) {
	int grammarID = 244;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 244:
			/* FirstStartTag[ATTRIBUTE[STRING](Encoding), ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinObjectType->Encoding_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->Encoding.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->Encoding.characters, dinObjectType->Encoding.charactersLen);
					}
				}
				grammarID = 245;
			} else 			if ( dinObjectType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->Id.characters, dinObjectType->Id.charactersLen);
					}
				}
				grammarID = 246;
			} else 			if ( dinObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->MimeType.characters, dinObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 19;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 5);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->ANY.characters, dinObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 245:
			/* StartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinObjectType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->Id.characters, dinObjectType->Id.charactersLen);
					}
				}
				grammarID = 246;
			} else 			if ( dinObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->MimeType.characters, dinObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 19;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->ANY.characters, dinObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 246:
			/* StartTag[ATTRIBUTE[STRING](MimeType), START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if ( dinObjectType->MimeType_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->MimeType.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->MimeType.characters, dinObjectType->MimeType.charactersLen);
					}
				}
				grammarID = 19;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->ANY.characters, dinObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 19:
			/* StartTag[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->ANY.characters, dinObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinObjectType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinObjectType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinObjectType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinObjectType->ANY.characters, dinObjectType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,SessionStopResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode)',  derivedBy='EXTENSION'.  */
static int encode_dinSessionStopResType(bitstream_t* stream, struct dinSessionStopResType* dinSessionStopResType) {
	int grammarID = 223;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 223:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinSessionStopResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignedInfoType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":CanonicalizationMethod,"http://www.w3.org/2000/09/xmldsig#":SignatureMethod,"http://www.w3.org/2000/09/xmldsig#":Reference{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSignedInfoType(bitstream_t* stream, struct dinSignedInfoType* dinSignedInfoType) {
	int grammarID = 247;
	int done = 0;
	
	unsigned int dinSignedInfoType_Reference_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 247:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod)] */
			if ( dinSignedInfoType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignedInfoType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignedInfoType->Id.characters, dinSignedInfoType->Id.charactersLen);
					}
				}
				grammarID = 248;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinCanonicalizationMethodType(stream, &dinSignedInfoType->CanonicalizationMethod );
				}
				grammarID = 249;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 248:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinCanonicalizationMethodType(stream, &dinSignedInfoType->CanonicalizationMethod );
				}
				grammarID = 249;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 249:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSignatureMethodType(stream, &dinSignedInfoType->SignatureMethod );
				}
				grammarID = 250;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 250:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference)] */
			if (dinSignedInfoType_Reference_currArrayIndex < dinSignedInfoType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinReferenceType(stream, &dinSignedInfoType->Reference.array [dinSignedInfoType_Reference_currArrayIndex++]);
				}
				grammarID = 203;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 203:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), END_ELEMENT] */
			if (dinSignedInfoType_Reference_currArrayIndex < dinSignedInfoType->Reference.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinReferenceType(stream, &dinSignedInfoType->Reference.array [dinSignedInfoType_Reference_currArrayIndex++]);
				}
				grammarID = 203;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SalesTariffType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":SalesTariffID,"urn:iso:15118:2:2010:MsgDataTypes":SalesTariffDescription{0-1},"urn:iso:15118:2:2010:MsgDataTypes":NumEPriceLevels,"urn:iso:15118:2:2010:MsgDataTypes":SalesTariffEntry{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSalesTariffType(bitstream_t* stream, struct dinSalesTariffType* dinSalesTariffType) {
	int grammarID = 251;
	int done = 0;
	
	unsigned int dinSalesTariffType_SalesTariffEntry_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 251:
			/* FirstStartTag[ATTRIBUTE[STRING](Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSalesTariffType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSalesTariffType->Id.characters, dinSalesTariffType->Id.charactersLen);
					}
				}
				grammarID = 252;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 252:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinSalesTariffType->SalesTariffID);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 253;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 253:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NumEPriceLevels)] */
			if ( dinSalesTariffType->SalesTariffDescription_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSalesTariffType->SalesTariffDescription.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinSalesTariffType->SalesTariffDescription.characters, dinSalesTariffType->SalesTariffDescription.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 254;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(dinSalesTariffType->NumEPriceLevels - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 255;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 254:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NumEPriceLevels)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(dinSalesTariffType->NumEPriceLevels - 0));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 255;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 255:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry)] */
			if (dinSalesTariffType_SalesTariffEntry_currArrayIndex < dinSalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinSalesTariffEntryType(stream, &dinSalesTariffType->SalesTariffEntry.array [dinSalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 256;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 256:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry), END_ELEMENT] */
			if (dinSalesTariffType_SalesTariffEntry_currArrayIndex < dinSalesTariffType->SalesTariffEntry.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinSalesTariffEntryType(stream, &dinSalesTariffType->SalesTariffEntry.array [dinSalesTariffType_SalesTariffEntry_currArrayIndex++]);
				}
				grammarID = 256;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,CostType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":costKind,"urn:iso:15118:2:2010:MsgDataTypes":amount,"urn:iso:15118:2:2010:MsgDataTypes":amountMultiplier{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinCostType(bitstream_t* stream, struct dinCostType* dinCostType) {
	int grammarID = 257;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 257:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}costKind)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinCostType->costKind);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 258;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 258:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amount)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinCostType->amount);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 259;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 259:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amountMultiplier), END_ELEMENT] */
			if ( dinCostType->amountMultiplier_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(dinCostType->amountMultiplier + 3));
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,ServiceChargeType',  base type name='ServiceType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("urn:iso:15118:2:2010:MsgDataTypes":ServiceTag,"urn:iso:15118:2:2010:MsgDataTypes":FreeService),("urn:iso:15118:2:2010:MsgDataTypes":EnergyTransferType))',  derivedBy='EXTENSION'.  */
static int encode_dinServiceChargeType(bitstream_t* stream, struct dinServiceChargeType* dinServiceChargeType) {
	int grammarID = 260;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 260:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceTag)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinServiceTagType(stream, &dinServiceChargeType->ServiceTag );
				}
				grammarID = 261;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 261:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FreeService)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BOOLEAN]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeBoolean(stream, dinServiceChargeType->FreeService);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 262;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 262:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EnergyTransferType)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinServiceChargeType->EnergyTransferType);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,DC_EVSEStatusType',  base type name='EVSEStatusType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":EVSEIsolationStatus{0-1},"urn:iso:15118:2:2010:MsgDataTypes":EVSEStatusCode,"urn:iso:15118:2:2010:MsgDataTypes":NotificationMaxDelay,"urn:iso:15118:2:2010:MsgDataTypes":EVSENotification)',  derivedBy='EXTENSION'.  */
static int encode_dinDC_EVSEStatusType(bitstream_t* stream, struct dinDC_EVSEStatusType* dinDC_EVSEStatusType) {
	int grammarID = 263;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 263:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatusCode)] */
			if ( dinDC_EVSEStatusType->EVSEIsolationStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinDC_EVSEStatusType->EVSEIsolationStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 264;
			} else 			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinDC_EVSEStatusType->EVSEStatusCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 218;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 264:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatusCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 4, dinDC_EVSEStatusType->EVSEStatusCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 218;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 218:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NotificationMaxDelay)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger32(stream, dinDC_EVSEStatusType->NotificationMaxDelay);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 219;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 219:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSENotification)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinDC_EVSEStatusType->EVSENotification);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,RetrievalMethodType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("http://www.w3.org/2000/09/xmldsig#":Transforms{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinRetrievalMethodType(bitstream_t* stream, struct dinRetrievalMethodType* dinRetrievalMethodType) {
	int grammarID = 265;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 265:
			/* FirstStartTag[ATTRIBUTE[STRING](Type), ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( dinRetrievalMethodType->Type_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinRetrievalMethodType->Type.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinRetrievalMethodType->Type.characters, dinRetrievalMethodType->Type.charactersLen);
					}
				}
				grammarID = 266;
			} else 			if ( dinRetrievalMethodType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinRetrievalMethodType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinRetrievalMethodType->URI.characters, dinRetrievalMethodType->URI.charactersLen);
					}
				}
				grammarID = 267;
			} else 			if ( dinRetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinRetrievalMethodType->Transforms );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 266:
			/* StartTag[ATTRIBUTE[STRING](URI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( dinRetrievalMethodType->URI_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinRetrievalMethodType->URI.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinRetrievalMethodType->URI.characters, dinRetrievalMethodType->URI.charactersLen);
					}
				}
				grammarID = 267;
			} else 			if ( dinRetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinRetrievalMethodType->Transforms );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 267:
			/* StartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), END_ELEMENT] */
			if ( dinRetrievalMethodType->Transforms_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					errn = encode_dinTransformsType(stream, &dinRetrievalMethodType->Transforms );
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,NotificationType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":FaultCode,"urn:iso:15118:2:2010:MsgDataTypes":FaultMsg{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinNotificationType(bitstream_t* stream, struct dinNotificationType* dinNotificationType) {
	int grammarID = 268;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 268:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 2, dinNotificationType->FaultCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 269;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 269:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg), END_ELEMENT] */
			if ( dinNotificationType->FaultMsg_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinNotificationType->FaultMsg.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinNotificationType->FaultMsg.characters, dinNotificationType->FaultMsg.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,PGPDataType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='(("http://www.w3.org/2000/09/xmldsig#":PGPKeyID,"http://www.w3.org/2000/09/xmldsig#":PGPKeyPacket{0-1},(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED})|("http://www.w3.org/2000/09/xmldsig#":PGPKeyPacket,(WC[##other:"http://www.w3.org/2000/09/xmldsig#"]){0-UNBOUNDED}))',  derivedBy='RESTRICTION'.  */
static int encode_dinPGPDataType(bitstream_t* stream, struct dinPGPDataType* dinPGPDataType) {
	int grammarID = 270;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 270:
			/* FirstStartTag[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket)] */
			if ( dinPGPDataType->PGPKeyID_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinPGPDataType->PGPKeyID.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinPGPDataType->PGPKeyID.bytes, dinPGPDataType->PGPKeyID.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 271;
			} else 			if ( dinPGPDataType->PGPKeyPacket_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinPGPDataType->PGPKeyPacket.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinPGPDataType->PGPKeyPacket.bytes, dinPGPDataType->PGPKeyPacket.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 272;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 271:
			/* Element[START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT_GENERIC, END_ELEMENT] */
			if ( dinPGPDataType->PGPKeyPacket_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinPGPDataType->PGPKeyPacket.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinPGPDataType->PGPKeyPacket.bytes, dinPGPDataType->PGPKeyPacket.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 272;
			} else 			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 272;
			} else 			if ( dinPGPDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 272:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 272;
			} else 			if ( dinPGPDataType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgBody,CertificateInstallationResType',  base type name='BodyBaseType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgBody":ResponseCode,"urn:iso:15118:2:2010:MsgBody":ContractSignatureCertChain,"urn:iso:15118:2:2010:MsgBody":ContractSignatureEncryptedPrivateKey,"urn:iso:15118:2:2010:MsgBody":DHParams,"urn:iso:15118:2:2010:MsgBody":ContractID)',  derivedBy='EXTENSION'.  */
static int encode_dinCertificateInstallationResType(bitstream_t* stream, struct dinCertificateInstallationResType* dinCertificateInstallationResType) {
	int grammarID = 273;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 273:
			/* FirstStartTag[ATTRIBUTE[STRING](Id)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationResType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinCertificateInstallationResType->Id.characters, dinCertificateInstallationResType->Id.charactersLen);
					}
				}
				grammarID = 274;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 274:
			/* StartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[ENUMERATION]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeNBitUnsignedInteger(stream, 5, dinCertificateInstallationResType->ResponseCode);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 275;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 275:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encode_dinCertificateChainType(stream, &dinCertificateInstallationResType->ContractSignatureCertChain );
				}
				grammarID = 276;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 276:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureEncryptedPrivateKey)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationResType->ContractSignatureEncryptedPrivateKey.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateInstallationResType->ContractSignatureEncryptedPrivateKey.bytes, dinCertificateInstallationResType->ContractSignatureEncryptedPrivateKey.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 277;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 277:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationResType->DHParams.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinCertificateInstallationResType->DHParams.bytes, dinCertificateInstallationResType->DHParams.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 278;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 278:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinCertificateInstallationResType->ContractID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinCertificateInstallationResType->ContractID.characters, dinCertificateInstallationResType->ContractID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='http://www.w3.org/2000/09/xmldsig#,SignaturePropertyType',  base type name='anyType',  content type='MIXED',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='((WC[##other:"http://www.w3.org/2000/09/xmldsig#"])){1-UNBOUNDED}',  derivedBy='RESTRICTION'.  */
static int encode_dinSignaturePropertyType(bitstream_t* stream, struct dinSignaturePropertyType* dinSignaturePropertyType) {
	int grammarID = 279;
	int done = 0;
	int wcDone = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 279:
			/* FirstStartTag[ATTRIBUTE[STRING](Id), ATTRIBUTE[STRING](Target)] */
			if ( dinSignaturePropertyType->Id_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->Id.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->Id.characters, dinSignaturePropertyType->Id.charactersLen);
					}
				}
				grammarID = 280;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->Target.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->Target.characters, dinSignaturePropertyType->Target.charactersLen);
					}
				}
				grammarID = 281;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 280:
			/* StartTag[ATTRIBUTE[STRING](Target)] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->Target.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->Target.characters, dinSignaturePropertyType->Target.charactersLen);
					}
				}
				grammarID = 281;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 281:
			/* StartTag[START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->ANY.characters, dinSignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 282;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 20:
			/* Element[START_ELEMENT_GENERIC, END_ELEMENT, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignaturePropertyType->ANY_isUsed == 0u || wcDone ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else 			if ( dinSignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->ANY.characters, dinSignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 20;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 282:
			/* Element[START_ELEMENT_GENERIC, CHARACTERS_GENERIC[STRING]] */
			if (1==0) {
				errn = EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS;
				grammarID = 20;
			} else 			if ( dinSignaturePropertyType->ANY_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSignaturePropertyType->ANY.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, dinSignaturePropertyType->ANY.characters, dinSignaturePropertyType->ANY.charactersLen);
					}
				}
				wcDone = 1;
				grammarID = 282;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,MeterInfoType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":MeterID,"urn:iso:15118:2:2010:MsgDataTypes":MeterReading{0-1},"urn:iso:15118:2:2010:MsgDataTypes":SigMeterReading{0-1},"urn:iso:15118:2:2010:MsgDataTypes":MeterStatus{0-1},"urn:iso:15118:2:2010:MsgDataTypes":TMeter{0-1})',  derivedBy='RESTRICTION'.  */
static int encode_dinMeterInfoType(bitstream_t* stream, struct dinMeterInfoType* dinMeterInfoType) {
	int grammarID = 283;
	int done = 0;
	
	
	while(!done) {
		switch(grammarID) {
		case 283:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID)] */
			if ( 1 == 1 ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[STRING]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						/* encode string as string table miss (+2 len)*/
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeterInfoType->MeterID.charactersLen + 2));
						if (errn == 0) {
							errn = encodeCharacters(stream, dinMeterInfoType->MeterID.characters, dinMeterInfoType->MeterID.charactersLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 284;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 284:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SigMeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( dinMeterInfoType->MeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					errn = encode_dinPhysicalValueType(stream, &dinMeterInfoType->MeterReading );
				}
				grammarID = 285;
			} else 			if ( dinMeterInfoType->SigMeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeterInfoType->SigMeterReading.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinMeterInfoType->SigMeterReading.bytes, dinMeterInfoType->SigMeterReading.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 286;
			} else 			if ( dinMeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinMeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 287;
			} else 			if ( dinMeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinMeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 4);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 285:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SigMeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( dinMeterInfoType->SigMeterReading_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinMeterInfoType->SigMeterReading.bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinMeterInfoType->SigMeterReading.bytes, dinMeterInfoType->SigMeterReading.bytesLen);
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 286;
			} else 			if ( dinMeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 1);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinMeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 287;
			} else 			if ( dinMeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 3, 2);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinMeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 3, 3);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 286:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( dinMeterInfoType->MeterStatus_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger16(stream, dinMeterInfoType->MeterStatus);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 287;
			} else 			if ( dinMeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinMeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 2);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 287:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), END_ELEMENT] */
			if ( dinMeterInfoType->TMeter_isUsed == 1u ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeInteger64(stream, dinMeterInfoType->TMeter);
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 4;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 4:
			/* Element[END_ELEMENT] */
			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}

/* Complex type name='urn:iso:15118:2:2010:MsgDataTypes,SubCertificatesType',  base type name='anyType',  content type='ELEMENT',  isAbstract='false',  hasTypeId='false',  final='0',  block='0',  particle='("urn:iso:15118:2:2010:MsgDataTypes":Certificate{1-UNBOUNDED})',  derivedBy='RESTRICTION'.  */
static int encode_dinSubCertificatesType(bitstream_t* stream, struct dinSubCertificatesType* dinSubCertificatesType) {
	int grammarID = 288;
	int done = 0;
	
	unsigned int dinSubCertificatesType_Certificate_currArrayIndex = 0;
	
	while(!done) {
		switch(grammarID) {
		case 288:
			/* FirstStartTag[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Certificate)] */
			if (dinSubCertificatesType_Certificate_currArrayIndex < dinSubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytes, dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytesLen);
							dinSubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 289;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		case 289:
			/* Element[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Certificate), END_ELEMENT] */
			if (dinSubCertificatesType_Certificate_currArrayIndex < dinSubCertificatesType->Certificate.arrayLen ) {
				errn = encodeNBitUnsignedInteger(stream, 2, 0);
				if(errn == 0) {
					/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
					if(errn == 0) {
						errn = encodeUnsignedInteger16(stream, (uint16_t)(dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytesLen));
						if (errn == 0) {
							errn = encodeBytes(stream, dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytes, dinSubCertificatesType->Certificate.array[dinSubCertificatesType_Certificate_currArrayIndex].bytesLen);
							dinSubCertificatesType_Certificate_currArrayIndex++;
						}
						/* valid EE */
						errn = encodeNBitUnsignedInteger(stream, 1, 0);
					}
				}
				grammarID = 289;
			} else 			if (1==1) {
				errn = encodeNBitUnsignedInteger(stream, 2, 1);
				if(errn == 0) {
					done = 1;
				}
				grammarID = 5;
			} else {
				errn = EXI_ERROR_UNKOWN_EVENT;
			}
			break;
		default:
			errn = EXI_ERROR_UNKOWN_GRAMMAR_ID;
			break;
		}
		if(errn) {
			done = 1;
		}
	}
	return errn;
}



int encode_dinExiDocument(bitstream_t* stream, struct dinEXIDocument* exiDoc) {
	errn = writeEXIHeader(stream);

	if(errn == 0) {
		/* DocContent[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCharge), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT_GENERIC] */
		if ( exiDoc->AC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 0);
			if(errn == 0) {
				errn = encode_dinAC_EVChargeParameterType(stream, &exiDoc->AC_EVChargeParameter );
			}
		} else if ( exiDoc->AC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 1);
			if(errn == 0) {
				errn = encode_dinAC_EVSEChargeParameterType(stream, &exiDoc->AC_EVSEChargeParameter );
			}
		} else if ( exiDoc->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 2);
			if(errn == 0) {
				errn = encode_dinAC_EVSEStatusType(stream, &exiDoc->AC_EVSEStatus );
			}
		} else if ( exiDoc->BodyElement_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement) */
			errn = encodeNBitUnsignedInteger(stream, 7, 3);
			if(errn == 0) {
				errn = encode_dinBodyBaseType(stream, &exiDoc->BodyElement );
			}
		} else if ( exiDoc->CableCheckReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 4);
			if(errn == 0) {
				errn = encode_dinCableCheckReqType(stream, &exiDoc->CableCheckReq );
			}
		} else if ( exiDoc->CableCheckRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 5);
			if(errn == 0) {
				errn = encode_dinCableCheckResType(stream, &exiDoc->CableCheckRes );
			}
		} else if ( exiDoc->CanonicalizationMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 6);
			if(errn == 0) {
				errn = encode_dinCanonicalizationMethodType(stream, &exiDoc->CanonicalizationMethod );
			}
		} else if ( exiDoc->CertificateInstallationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 7);
			if(errn == 0) {
				errn = encode_dinCertificateInstallationReqType(stream, &exiDoc->CertificateInstallationReq );
			}
		} else if ( exiDoc->CertificateInstallationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 8);
			if(errn == 0) {
				errn = encode_dinCertificateInstallationResType(stream, &exiDoc->CertificateInstallationRes );
			}
		} else if ( exiDoc->CertificateUpdateReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 9);
			if(errn == 0) {
				errn = encode_dinCertificateUpdateReqType(stream, &exiDoc->CertificateUpdateReq );
			}
		} else if ( exiDoc->CertificateUpdateRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 10);
			if(errn == 0) {
				errn = encode_dinCertificateUpdateResType(stream, &exiDoc->CertificateUpdateRes );
			}
		} else if ( exiDoc->ChargeParameterDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 11);
			if(errn == 0) {
				errn = encode_dinChargeParameterDiscoveryReqType(stream, &exiDoc->ChargeParameterDiscoveryReq );
			}
		} else if ( exiDoc->ChargeParameterDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 12);
			if(errn == 0) {
				errn = encode_dinChargeParameterDiscoveryResType(stream, &exiDoc->ChargeParameterDiscoveryRes );
			}
		} else if ( exiDoc->ChargingStatusReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 13);
			if(errn == 0) {
				errn = encode_dinChargingStatusReqType(stream, &exiDoc->ChargingStatusReq );
			}
		} else if ( exiDoc->ChargingStatusRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 14);
			if(errn == 0) {
				errn = encode_dinChargingStatusResType(stream, &exiDoc->ChargingStatusRes );
			}
		} else if ( exiDoc->ContractAuthenticationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 15);
			if(errn == 0) {
				errn = encode_dinContractAuthenticationReqType(stream, &exiDoc->ContractAuthenticationReq );
			}
		} else if ( exiDoc->ContractAuthenticationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 16);
			if(errn == 0) {
				errn = encode_dinContractAuthenticationResType(stream, &exiDoc->ContractAuthenticationRes );
			}
		} else if ( exiDoc->CurrentDemandReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 17);
			if(errn == 0) {
				errn = encode_dinCurrentDemandReqType(stream, &exiDoc->CurrentDemandReq );
			}
		} else if ( exiDoc->CurrentDemandRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 18);
			if(errn == 0) {
				errn = encode_dinCurrentDemandResType(stream, &exiDoc->CurrentDemandRes );
			}
		} else if ( exiDoc->DC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 19);
			if(errn == 0) {
				errn = encode_dinDC_EVChargeParameterType(stream, &exiDoc->DC_EVChargeParameter );
			}
		} else if ( exiDoc->DC_EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 20);
			if(errn == 0) {
				errn = encode_dinDC_EVPowerDeliveryParameterType(stream, &exiDoc->DC_EVPowerDeliveryParameter );
			}
		} else if ( exiDoc->DC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 21);
			if(errn == 0) {
				errn = encode_dinDC_EVSEChargeParameterType(stream, &exiDoc->DC_EVSEChargeParameter );
			}
		} else if ( exiDoc->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 22);
			if(errn == 0) {
				errn = encode_dinDC_EVSEStatusType(stream, &exiDoc->DC_EVSEStatus );
			}
		} else if ( exiDoc->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 23);
			if(errn == 0) {
				errn = encode_dinDC_EVStatusType(stream, &exiDoc->DC_EVStatus );
			}
		} else if ( exiDoc->DSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 24);
			if(errn == 0) {
				errn = encode_dinDSAKeyValueType(stream, &exiDoc->DSAKeyValue );
			}
		} else if ( exiDoc->DigestMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 25);
			if(errn == 0) {
				errn = encode_dinDigestMethodType(stream, &exiDoc->DigestMethod );
			}
		} else if ( exiDoc->DigestValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 26);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->DigestValue.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiDoc->DigestValue.bytes, exiDoc->DigestValue.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 27);
			if(errn == 0) {
				errn = encode_dinEVChargeParameterType(stream, &exiDoc->EVChargeParameter );
			}
		} else if ( exiDoc->EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 28);
			if(errn == 0) {
				errn = encode_dinEVPowerDeliveryParameterType(stream, &exiDoc->EVPowerDeliveryParameter );
			}
		} else if ( exiDoc->EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 7, 29);
			if(errn == 0) {
				errn = encode_dinEVSEChargeParameterType(stream, &exiDoc->EVSEChargeParameter );
			}
		} else if ( exiDoc->EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 30);
			if(errn == 0) {
				errn = encode_dinEVSEStatusType(stream, &exiDoc->EVSEStatus );
			}
		} else if ( exiDoc->EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 7, 31);
			if(errn == 0) {
				errn = encode_dinEVStatusType(stream, &exiDoc->EVStatus );
			}
		} else if ( exiDoc->Entry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Entry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 32);
			if(errn == 0) {
				errn = encode_dinEntryType(stream, &exiDoc->Entry );
			}
		} else if ( exiDoc->KeyInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo) */
			errn = encodeNBitUnsignedInteger(stream, 7, 33);
			if(errn == 0) {
				errn = encode_dinKeyInfoType(stream, &exiDoc->KeyInfo );
			}
		} else if ( exiDoc->KeyName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName) */
			errn = encodeNBitUnsignedInteger(stream, 7, 34);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->KeyName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiDoc->KeyName.characters, exiDoc->KeyName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->KeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 35);
			if(errn == 0) {
				errn = encode_dinKeyValueType(stream, &exiDoc->KeyValue );
			}
		} else if ( exiDoc->Manifest_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest) */
			errn = encodeNBitUnsignedInteger(stream, 7, 36);
			if(errn == 0) {
				errn = encode_dinManifestType(stream, &exiDoc->Manifest );
			}
		} else if ( exiDoc->MeteringReceiptReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 37);
			if(errn == 0) {
				errn = encode_dinMeteringReceiptReqType(stream, &exiDoc->MeteringReceiptReq );
			}
		} else if ( exiDoc->MeteringReceiptRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 38);
			if(errn == 0) {
				errn = encode_dinMeteringReceiptResType(stream, &exiDoc->MeteringReceiptRes );
			}
		} else if ( exiDoc->MgmtData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 39);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiDoc->MgmtData.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiDoc->MgmtData.characters, exiDoc->MgmtData.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiDoc->Object_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object) */
			errn = encodeNBitUnsignedInteger(stream, 7, 40);
			if(errn == 0) {
				errn = encode_dinObjectType(stream, &exiDoc->Object );
			}
		} else if ( exiDoc->PGPData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 41);
			if(errn == 0) {
				errn = encode_dinPGPDataType(stream, &exiDoc->PGPData );
			}
		} else if ( exiDoc->PMaxScheduleEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 42);
			if(errn == 0) {
				errn = encode_dinPMaxScheduleEntryType(stream, &exiDoc->PMaxScheduleEntry );
			}
		} else if ( exiDoc->PaymentDetailsReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 43);
			if(errn == 0) {
				errn = encode_dinPaymentDetailsReqType(stream, &exiDoc->PaymentDetailsReq );
			}
		} else if ( exiDoc->PaymentDetailsRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 44);
			if(errn == 0) {
				errn = encode_dinPaymentDetailsResType(stream, &exiDoc->PaymentDetailsRes );
			}
		} else if ( exiDoc->PowerDeliveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 45);
			if(errn == 0) {
				errn = encode_dinPowerDeliveryReqType(stream, &exiDoc->PowerDeliveryReq );
			}
		} else if ( exiDoc->PowerDeliveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 46);
			if(errn == 0) {
				errn = encode_dinPowerDeliveryResType(stream, &exiDoc->PowerDeliveryRes );
			}
		} else if ( exiDoc->PreChargeReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 47);
			if(errn == 0) {
				errn = encode_dinPreChargeReqType(stream, &exiDoc->PreChargeReq );
			}
		} else if ( exiDoc->PreChargeRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 48);
			if(errn == 0) {
				errn = encode_dinPreChargeResType(stream, &exiDoc->PreChargeRes );
			}
		} else if ( exiDoc->RSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 49);
			if(errn == 0) {
				errn = encode_dinRSAKeyValueType(stream, &exiDoc->RSAKeyValue );
			}
		} else if ( exiDoc->Reference_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference) */
			errn = encodeNBitUnsignedInteger(stream, 7, 50);
			if(errn == 0) {
				errn = encode_dinReferenceType(stream, &exiDoc->Reference );
			}
		} else if ( exiDoc->RelativeTimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 7, 51);
			if(errn == 0) {
				errn = encode_dinRelativeTimeIntervalType(stream, &exiDoc->RelativeTimeInterval );
			}
		} else if ( exiDoc->RetrievalMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 52);
			if(errn == 0) {
				errn = encode_dinRetrievalMethodType(stream, &exiDoc->RetrievalMethod );
			}
		} else if ( exiDoc->SAScheduleList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleList) */
			errn = encodeNBitUnsignedInteger(stream, 7, 53);
			if(errn == 0) {
				errn = encode_dinSAScheduleListType(stream, &exiDoc->SAScheduleList );
			}
		} else if ( exiDoc->SASchedules_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SASchedules) */
			errn = encodeNBitUnsignedInteger(stream, 7, 54);
			if(errn == 0) {
				errn = encode_dinSASchedulesType(stream, &exiDoc->SASchedules );
			}
		} else if ( exiDoc->SPKIData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData) */
			errn = encodeNBitUnsignedInteger(stream, 7, 55);
			if(errn == 0) {
				errn = encode_dinSPKIDataType(stream, &exiDoc->SPKIData );
			}
		} else if ( exiDoc->SalesTariffEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry) */
			errn = encodeNBitUnsignedInteger(stream, 7, 56);
			if(errn == 0) {
				errn = encode_dinSalesTariffEntryType(stream, &exiDoc->SalesTariffEntry );
			}
		} else if ( exiDoc->ServiceCharge_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCharge) */
			errn = encodeNBitUnsignedInteger(stream, 7, 57);
			if(errn == 0) {
				errn = encode_dinServiceChargeType(stream, &exiDoc->ServiceCharge );
			}
		} else if ( exiDoc->ServiceDetailReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 58);
			if(errn == 0) {
				errn = encode_dinServiceDetailReqType(stream, &exiDoc->ServiceDetailReq );
			}
		} else if ( exiDoc->ServiceDetailRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 59);
			if(errn == 0) {
				errn = encode_dinServiceDetailResType(stream, &exiDoc->ServiceDetailRes );
			}
		} else if ( exiDoc->ServiceDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 60);
			if(errn == 0) {
				errn = encode_dinServiceDiscoveryReqType(stream, &exiDoc->ServiceDiscoveryReq );
			}
		} else if ( exiDoc->ServiceDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 61);
			if(errn == 0) {
				errn = encode_dinServiceDiscoveryResType(stream, &exiDoc->ServiceDiscoveryRes );
			}
		} else if ( exiDoc->ServicePaymentSelectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 62);
			if(errn == 0) {
				errn = encode_dinServicePaymentSelectionReqType(stream, &exiDoc->ServicePaymentSelectionReq );
			}
		} else if ( exiDoc->ServicePaymentSelectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 63);
			if(errn == 0) {
				errn = encode_dinServicePaymentSelectionResType(stream, &exiDoc->ServicePaymentSelectionRes );
			}
		} else if ( exiDoc->SessionSetupReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 64);
			if(errn == 0) {
				errn = encode_dinSessionSetupReqType(stream, &exiDoc->SessionSetupReq );
			}
		} else if ( exiDoc->SessionSetupRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 65);
			if(errn == 0) {
				errn = encode_dinSessionSetupResType(stream, &exiDoc->SessionSetupRes );
			}
		} else if ( exiDoc->SessionStopReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 66);
			if(errn == 0) {
				errn = encode_dinSessionStopType(stream, &exiDoc->SessionStopReq );
			}
		} else if ( exiDoc->SessionStopRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 67);
			if(errn == 0) {
				errn = encode_dinSessionStopResType(stream, &exiDoc->SessionStopRes );
			}
		} else if ( exiDoc->Signature_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature) */
			errn = encodeNBitUnsignedInteger(stream, 7, 68);
			if(errn == 0) {
				errn = encode_dinSignatureType(stream, &exiDoc->Signature );
			}
		} else if ( exiDoc->SignatureMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod) */
			errn = encodeNBitUnsignedInteger(stream, 7, 69);
			if(errn == 0) {
				errn = encode_dinSignatureMethodType(stream, &exiDoc->SignatureMethod );
			}
		} else if ( exiDoc->SignatureProperties_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties) */
			errn = encodeNBitUnsignedInteger(stream, 7, 70);
			if(errn == 0) {
				errn = encode_dinSignaturePropertiesType(stream, &exiDoc->SignatureProperties );
			}
		} else if ( exiDoc->SignatureProperty_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty) */
			errn = encodeNBitUnsignedInteger(stream, 7, 71);
			if(errn == 0) {
				errn = encode_dinSignaturePropertyType(stream, &exiDoc->SignatureProperty );
			}
		} else if ( exiDoc->SignatureValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue) */
			errn = encodeNBitUnsignedInteger(stream, 7, 72);
			if(errn == 0) {
				errn = encode_dinSignatureValueType(stream, &exiDoc->SignatureValue );
			}
		} else if ( exiDoc->SignedInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo) */
			errn = encodeNBitUnsignedInteger(stream, 7, 73);
			if(errn == 0) {
				errn = encode_dinSignedInfoType(stream, &exiDoc->SignedInfo );
			}
		} else if ( exiDoc->TimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 7, 74);
			if(errn == 0) {
				errn = encode_dinIntervalType(stream, &exiDoc->TimeInterval );
			}
		} else if ( exiDoc->Transform_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform) */
			errn = encodeNBitUnsignedInteger(stream, 7, 75);
			if(errn == 0) {
				errn = encode_dinTransformType(stream, &exiDoc->Transform );
			}
		} else if ( exiDoc->Transforms_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms) */
			errn = encodeNBitUnsignedInteger(stream, 7, 76);
			if(errn == 0) {
				errn = encode_dinTransformsType(stream, &exiDoc->Transforms );
			}
		} else if ( exiDoc->V2G_Message_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message) */
			errn = encodeNBitUnsignedInteger(stream, 7, 77);
			if(errn == 0) {
				errn = encode_dinAnonType_V2G_Message(stream, &exiDoc->V2G_Message );
			}
		} else if ( exiDoc->WeldingDetectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 7, 78);
			if(errn == 0) {
				errn = encode_dinWeldingDetectionReqType(stream, &exiDoc->WeldingDetectionReq );
			}
		} else if ( exiDoc->WeldingDetectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 7, 79);
			if(errn == 0) {
				errn = encode_dinWeldingDetectionResType(stream, &exiDoc->WeldingDetectionRes );
			}
		} else if ( exiDoc->X509Data_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data) */
			errn = encodeNBitUnsignedInteger(stream, 7, 80);
			if(errn == 0) {
				errn = encode_dinX509DataType(stream, &exiDoc->X509Data );
			}
		} else {
			errn = EXI_ERROR_UNKOWN_EVENT;
		}

	}

	if(errn == 0) {
		/* flush any pending bits */
		errn = encodeFinish(stream);
	}

	return errn;
}

#if DEPLOY_DIN_CODEC_FRAGMENT == SUPPORT_YES
int encode_dinExiFragment(bitstream_t* stream, struct dinEXIFragment* exiFrag) {
	errn = writeEXIHeader(stream);

	if(errn == 0) {
		/* FragmentContent[START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Body), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Certificate), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeService), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingComplete), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingProfile), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryMaxPower), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryStart), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ConsumptionCost), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureEncryptedPrivateKey), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Cost), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DateTimeNow), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DepartureTime), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EAmount), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EPriceLevel), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVCCID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVCabinConditioning), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyCapacity), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyRequest), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVErrorCode), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxVoltage), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMinCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSConditioning), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSSOC), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVReady), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVRequestedEnergyTransferType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEChargeParameter), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSECurrentLimitAchieved), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSECurrentRegulationTolerance), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEEnergyToBeDelivered), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEIsolationStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxVoltage), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumPowerLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumCurrentLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumVoltageLimit), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSENotification), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEPeakCurrentRipple), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPowerLimitAchieved), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentVoltage), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEProcessing), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatusCode), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEVoltageLimitAchieved), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetCurrent), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EnergyTransferType), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Entry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FreeService), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FullSOC), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}GenChallenge), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Header), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ListOfRootCertificateIDs), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Multiplier), START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}Notification), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NotificationMaxDelay), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NumEPriceLevels), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}OEMProvisioningCert), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMax), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxSchedule), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Parameter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSet), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSetID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PaymentOption), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentOptions), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PowerSwitchClosed), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProfileEntry), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RCD), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReadyToChargeState), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReceiptRequired), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToBulkSoC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToFullSoC), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RetryCounter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RootCertificateID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleList), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTuple), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTupleID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SASchedules), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariff), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffDescription), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffID), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedPaymentOption), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SelectedService), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedServiceList), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCategory), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCharge), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceID), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceList), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceParameterList), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceTag), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionID), START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}SessionID), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopRes), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SigMeterReading), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SubCertificates), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Unit), START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Value), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionReq), START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionRes), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath), START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amount), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amountMultiplier), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}boolValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}byteValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}costKind), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}duration), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}intValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}physicalValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}shortValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}start), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}startValue), START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}stringValue), START_ELEMENT_GENERIC, END_DOCUMENT] */
		if ( exiFrag->AC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 0);
			if(errn == 0) {
				errn = encode_dinAC_EVChargeParameterType(stream, &exiFrag->AC_EVChargeParameter );
			}
		} else if ( exiFrag->AC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 1);
			if(errn == 0) {
				errn = encode_dinAC_EVSEChargeParameterType(stream, &exiFrag->AC_EVSEChargeParameter );
			}
		} else if ( exiFrag->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 2);
			if(errn == 0) {
				errn = encode_dinAC_EVSEStatusType(stream, &exiFrag->AC_EVSEStatus );
			}
		} else if ( exiFrag->AC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}AC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 3);
			if(errn == 0) {
				errn = encode_dinAC_EVSEStatusType(stream, &exiFrag->AC_EVSEStatus );
			}
		} else if ( exiFrag->Body_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Body) */
			errn = encodeNBitUnsignedInteger(stream, 8, 4);
			if(errn == 0) {
				errn = encode_dinBodyType(stream, &exiFrag->Body );
			}
		} else if ( exiFrag->BodyElement_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}BodyElement) */
			errn = encodeNBitUnsignedInteger(stream, 8, 5);
			if(errn == 0) {
				errn = encode_dinBodyBaseType(stream, &exiFrag->BodyElement );
			}
		} else if ( exiFrag->BulkChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}BulkChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 6);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->BulkChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->BulkChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 7);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->BulkChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->BulkSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}BulkSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 8);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->BulkSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->CableCheckReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 9);
			if(errn == 0) {
				errn = encode_dinCableCheckReqType(stream, &exiFrag->CableCheckReq );
			}
		} else if ( exiFrag->CableCheckRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CableCheckRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 10);
			if(errn == 0) {
				errn = encode_dinCableCheckResType(stream, &exiFrag->CableCheckRes );
			}
		} else if ( exiFrag->CanonicalizationMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}CanonicalizationMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 11);
			if(errn == 0) {
				errn = encode_dinCanonicalizationMethodType(stream, &exiFrag->CanonicalizationMethod );
			}
		} else if ( exiFrag->Certificate_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Certificate) */
			errn = encodeNBitUnsignedInteger(stream, 8, 12);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Certificate.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Certificate.bytes, exiFrag->Certificate.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->CertificateInstallationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 13);
			if(errn == 0) {
				errn = encode_dinCertificateInstallationReqType(stream, &exiFrag->CertificateInstallationReq );
			}
		} else if ( exiFrag->CertificateInstallationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateInstallationRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 14);
			if(errn == 0) {
				errn = encode_dinCertificateInstallationResType(stream, &exiFrag->CertificateInstallationRes );
			}
		} else if ( exiFrag->CertificateUpdateReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 15);
			if(errn == 0) {
				errn = encode_dinCertificateUpdateReqType(stream, &exiFrag->CertificateUpdateReq );
			}
		} else if ( exiFrag->CertificateUpdateRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CertificateUpdateRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 16);
			if(errn == 0) {
				errn = encode_dinCertificateUpdateResType(stream, &exiFrag->CertificateUpdateRes );
			}
		} else if ( exiFrag->ChargeParameterDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 17);
			if(errn == 0) {
				errn = encode_dinChargeParameterDiscoveryReqType(stream, &exiFrag->ChargeParameterDiscoveryReq );
			}
		} else if ( exiFrag->ChargeParameterDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeParameterDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 18);
			if(errn == 0) {
				errn = encode_dinChargeParameterDiscoveryResType(stream, &exiFrag->ChargeParameterDiscoveryRes );
			}
		} else if ( exiFrag->ChargeService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargeService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 19);
			if(errn == 0) {
				errn = encode_dinServiceChargeType(stream, &exiFrag->ChargeService );
			}
		} else if ( exiFrag->ChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 20);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingComplete_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingComplete) */
			errn = encodeNBitUnsignedInteger(stream, 8, 21);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ChargingComplete);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingProfile_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingProfile) */
			errn = encodeNBitUnsignedInteger(stream, 8, 22);
			if(errn == 0) {
				errn = encode_dinChargingProfileType(stream, &exiFrag->ChargingProfile );
			}
		} else if ( exiFrag->ChargingProfileEntryMaxPower_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryMaxPower) */
			errn = encodeNBitUnsignedInteger(stream, 8, 23);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->ChargingProfileEntryMaxPower);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingProfileEntryStart_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ChargingProfileEntryStart) */
			errn = encodeNBitUnsignedInteger(stream, 8, 24);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->ChargingProfileEntryStart);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ChargingStatusReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 25);
			if(errn == 0) {
				errn = encode_dinChargingStatusReqType(stream, &exiFrag->ChargingStatusReq );
			}
		} else if ( exiFrag->ChargingStatusRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ChargingStatusRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 26);
			if(errn == 0) {
				errn = encode_dinChargingStatusResType(stream, &exiFrag->ChargingStatusRes );
			}
		} else if ( exiFrag->ConsumptionCost_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ConsumptionCost) */
			errn = encodeNBitUnsignedInteger(stream, 8, 27);
			if(errn == 0) {
				errn = encode_dinConsumptionCostType(stream, &exiFrag->ConsumptionCost );
			}
		} else if ( exiFrag->ContractAuthenticationReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 28);
			if(errn == 0) {
				errn = encode_dinContractAuthenticationReqType(stream, &exiFrag->ContractAuthenticationReq );
			}
		} else if ( exiFrag->ContractAuthenticationRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractAuthenticationRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 29);
			if(errn == 0) {
				errn = encode_dinContractAuthenticationResType(stream, &exiFrag->ContractAuthenticationRes );
			}
		} else if ( exiFrag->ContractID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 30);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ContractID.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ContractID.characters, exiFrag->ContractID.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ContractSignatureCertChain_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureCertChain) */
			errn = encodeNBitUnsignedInteger(stream, 8, 31);
			if(errn == 0) {
				errn = encode_dinCertificateChainType(stream, &exiFrag->ContractSignatureCertChain );
			}
		} else if ( exiFrag->ContractSignatureEncryptedPrivateKey_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ContractSignatureEncryptedPrivateKey) */
			errn = encodeNBitUnsignedInteger(stream, 8, 32);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ContractSignatureEncryptedPrivateKey.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->ContractSignatureEncryptedPrivateKey.bytes, exiFrag->ContractSignatureEncryptedPrivateKey.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Cost_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Cost) */
			errn = encodeNBitUnsignedInteger(stream, 8, 33);
			if(errn == 0) {
				errn = encode_dinCostType(stream, &exiFrag->Cost );
			}
		} else if ( exiFrag->CurrentDemandReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 34);
			if(errn == 0) {
				errn = encode_dinCurrentDemandReqType(stream, &exiFrag->CurrentDemandReq );
			}
		} else if ( exiFrag->CurrentDemandRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}CurrentDemandRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 35);
			if(errn == 0) {
				errn = encode_dinCurrentDemandResType(stream, &exiFrag->CurrentDemandRes );
			}
		} else if ( exiFrag->DC_EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 36);
			if(errn == 0) {
				errn = encode_dinDC_EVChargeParameterType(stream, &exiFrag->DC_EVChargeParameter );
			}
		} else if ( exiFrag->DC_EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 37);
			if(errn == 0) {
				errn = encode_dinDC_EVPowerDeliveryParameterType(stream, &exiFrag->DC_EVPowerDeliveryParameter );
			}
		} else if ( exiFrag->DC_EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 38);
			if(errn == 0) {
				errn = encode_dinDC_EVSEChargeParameterType(stream, &exiFrag->DC_EVSEChargeParameter );
			}
		} else if ( exiFrag->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 39);
			if(errn == 0) {
				errn = encode_dinDC_EVSEStatusType(stream, &exiFrag->DC_EVSEStatus );
			}
		} else if ( exiFrag->DC_EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 40);
			if(errn == 0) {
				errn = encode_dinDC_EVSEStatusType(stream, &exiFrag->DC_EVSEStatus );
			}
		} else if ( exiFrag->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 41);
			if(errn == 0) {
				errn = encode_dinDC_EVStatusType(stream, &exiFrag->DC_EVStatus );
			}
		} else if ( exiFrag->DC_EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DC_EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 42);
			if(errn == 0) {
				errn = encode_dinDC_EVStatusType(stream, &exiFrag->DC_EVStatus );
			}
		} else if ( exiFrag->DHParams_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DHParams) */
			errn = encodeNBitUnsignedInteger(stream, 8, 43);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->DHParams.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->DHParams.bytes, exiFrag->DHParams.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->DSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 44);
			if(errn == 0) {
				errn = encode_dinDSAKeyValueType(stream, &exiFrag->DSAKeyValue );
			}
		} else if ( exiFrag->DateTimeNow_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}DateTimeNow) */
			errn = encodeNBitUnsignedInteger(stream, 8, 45);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->DateTimeNow);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->DepartureTime_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}DepartureTime) */
			errn = encodeNBitUnsignedInteger(stream, 8, 46);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->DepartureTime);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->DigestMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 47);
			if(errn == 0) {
				errn = encode_dinDigestMethodType(stream, &exiFrag->DigestMethod );
			}
		} else if ( exiFrag->DigestValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}DigestValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 48);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->DigestValue.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->DigestValue.bytes, exiFrag->DigestValue.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EAmount_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EAmount) */
			errn = encodeNBitUnsignedInteger(stream, 8, 49);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EAmount );
			}
		} else if ( exiFrag->EPriceLevel_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EPriceLevel) */
			errn = encodeNBitUnsignedInteger(stream, 8, 50);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->EPriceLevel - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVCCID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVCCID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 51);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->EVCCID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->EVCCID.bytes, exiFrag->EVCCID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVCabinConditioning_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVCabinConditioning) */
			errn = encodeNBitUnsignedInteger(stream, 8, 52);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVCabinConditioning);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 53);
			if(errn == 0) {
				errn = encode_dinEVChargeParameterType(stream, &exiFrag->EVChargeParameter );
			}
		} else if ( exiFrag->EVEnergyCapacity_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyCapacity) */
			errn = encodeNBitUnsignedInteger(stream, 8, 54);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVEnergyCapacity );
			}
		} else if ( exiFrag->EVEnergyRequest_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVEnergyRequest) */
			errn = encodeNBitUnsignedInteger(stream, 8, 55);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVEnergyRequest );
			}
		} else if ( exiFrag->EVErrorCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVErrorCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 56);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->EVErrorCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 57);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaxCurrent );
			}
		} else if ( exiFrag->EVMaxVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaxVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 58);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaxVoltage );
			}
		} else if ( exiFrag->EVMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 59);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 60);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 61);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumPowerLimit );
			}
		} else if ( exiFrag->EVMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 62);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumPowerLimit );
			}
		} else if ( exiFrag->EVMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 63);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 64);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVMinCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVMinCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 65);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVMinCurrent );
			}
		} else if ( exiFrag->EVPowerDeliveryParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVPowerDeliveryParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 66);
			if(errn == 0) {
				errn = encode_dinEVPowerDeliveryParameterType(stream, &exiFrag->EVPowerDeliveryParameter );
			}
		} else if ( exiFrag->EVRESSConditioning_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSConditioning) */
			errn = encodeNBitUnsignedInteger(stream, 8, 67);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVRESSConditioning);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVRESSSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVRESSSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 68);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->EVRESSSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVReady_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVReady) */
			errn = encodeNBitUnsignedInteger(stream, 8, 69);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVReady);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVRequestedEnergyTransferType_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVRequestedEnergyTransferType) */
			errn = encodeNBitUnsignedInteger(stream, 8, 70);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, exiFrag->EVRequestedEnergyTransferType);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEChargeParameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEChargeParameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 71);
			if(errn == 0) {
				errn = encode_dinEVSEChargeParameterType(stream, &exiFrag->EVSEChargeParameter );
			}
		} else if ( exiFrag->EVSECurrentLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSECurrentLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 72);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSECurrentLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSECurrentRegulationTolerance_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSECurrentRegulationTolerance) */
			errn = encodeNBitUnsignedInteger(stream, 8, 73);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSECurrentRegulationTolerance );
			}
		} else if ( exiFrag->EVSEEnergyToBeDelivered_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEEnergyToBeDelivered) */
			errn = encodeNBitUnsignedInteger(stream, 8, 74);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEEnergyToBeDelivered );
			}
		} else if ( exiFrag->EVSEID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 75);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->EVSEID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->EVSEID.bytes, exiFrag->EVSEID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEIsolationStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEIsolationStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 76);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->EVSEIsolationStatus);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 77);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaxCurrent );
			}
		} else if ( exiFrag->EVSEMaxCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 78);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaxCurrent );
			}
		} else if ( exiFrag->EVSEMaxVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaxVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 79);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaxVoltage );
			}
		} else if ( exiFrag->EVSEMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 80);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMaximumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 81);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 82);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumPowerLimit );
			}
		} else if ( exiFrag->EVSEMaximumPowerLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumPowerLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 83);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumPowerLimit );
			}
		} else if ( exiFrag->EVSEMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 84);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVSEMaximumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMaximumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 85);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMaximumVoltageLimit );
			}
		} else if ( exiFrag->EVSEMinCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 86);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMinCurrent );
			}
		} else if ( exiFrag->EVSEMinimumCurrentLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumCurrentLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 87);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMinimumCurrentLimit );
			}
		} else if ( exiFrag->EVSEMinimumVoltageLimit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEMinimumVoltageLimit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 88);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEMinimumVoltageLimit );
			}
		} else if ( exiFrag->EVSENotification_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSENotification) */
			errn = encodeNBitUnsignedInteger(stream, 8, 89);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->EVSENotification);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEPeakCurrentRipple_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEPeakCurrentRipple) */
			errn = encodeNBitUnsignedInteger(stream, 8, 90);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEPeakCurrentRipple );
			}
		} else if ( exiFrag->EVSEPowerLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPowerLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 91);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSEPowerLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEPresentCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 92);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEPresentCurrent );
			}
		} else if ( exiFrag->EVSEPresentVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEPresentVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 93);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVSEPresentVoltage );
			}
		} else if ( exiFrag->EVSEProcessing_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEProcessing) */
			errn = encodeNBitUnsignedInteger(stream, 8, 94);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->EVSEProcessing);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 95);
			if(errn == 0) {
				errn = encode_dinEVSEStatusType(stream, &exiFrag->EVSEStatus );
			}
		} else if ( exiFrag->EVSEStatusCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVSEStatusCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 96);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->EVSEStatusCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVSEVoltageLimitAchieved_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVSEVoltageLimitAchieved) */
			errn = encodeNBitUnsignedInteger(stream, 8, 97);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->EVSEVoltageLimitAchieved);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->EVStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EVStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 98);
			if(errn == 0) {
				errn = encode_dinEVStatusType(stream, &exiFrag->EVStatus );
			}
		} else if ( exiFrag->EVTargetCurrent_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetCurrent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 99);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVTargetCurrent );
			}
		} else if ( exiFrag->EVTargetVoltage_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}EVTargetVoltage) */
			errn = encodeNBitUnsignedInteger(stream, 8, 100);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->EVTargetVoltage );
			}
		} else if ( exiFrag->EnergyTransferType_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}EnergyTransferType) */
			errn = encodeNBitUnsignedInteger(stream, 8, 101);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->EnergyTransferType);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Entry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Entry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 102);
			if(errn == 0) {
				errn = encode_dinEntryType(stream, &exiFrag->Entry );
			}
		} else if ( exiFrag->Exponent_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Exponent) */
			errn = encodeNBitUnsignedInteger(stream, 8, 103);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Exponent.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Exponent.bytes, exiFrag->Exponent.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FaultCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 104);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->FaultCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FaultMsg_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FaultMsg) */
			errn = encodeNBitUnsignedInteger(stream, 8, 105);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->FaultMsg.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->FaultMsg.characters, exiFrag->FaultMsg.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FreeService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FreeService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 106);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->FreeService);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->FullSOC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}FullSOC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 107);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 7, (uint32_t)(exiFrag->FullSOC - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->G_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}G) */
			errn = encodeNBitUnsignedInteger(stream, 8, 108);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->G.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->G.bytes, exiFrag->G.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->GenChallenge_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}GenChallenge) */
			errn = encodeNBitUnsignedInteger(stream, 8, 109);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->GenChallenge.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->GenChallenge.characters, exiFrag->GenChallenge.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->HMACOutputLength_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}HMACOutputLength) */
			errn = encodeNBitUnsignedInteger(stream, 8, 110);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->HMACOutputLength);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Header_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}Header) */
			errn = encodeNBitUnsignedInteger(stream, 8, 111);
			if(errn == 0) {
				errn = encode_dinMessageHeaderType(stream, &exiFrag->Header );
			}
		} else if ( exiFrag->J_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}J) */
			errn = encodeNBitUnsignedInteger(stream, 8, 112);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->J.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->J.bytes, exiFrag->J.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->KeyInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 113);
			if(errn == 0) {
				errn = encode_dinKeyInfoType(stream, &exiFrag->KeyInfo );
			}
		} else if ( exiFrag->KeyName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 114);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->KeyName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->KeyName.characters, exiFrag->KeyName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->KeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}KeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 115);
			if(errn == 0) {
				errn = encode_dinKeyValueType(stream, &exiFrag->KeyValue );
			}
		} else if ( exiFrag->ListOfRootCertificateIDs_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ListOfRootCertificateIDs) */
			errn = encodeNBitUnsignedInteger(stream, 8, 116);
			if(errn == 0) {
				errn = encode_dinListOfRootCertificateIDsType(stream, &exiFrag->ListOfRootCertificateIDs );
			}
		} else if ( exiFrag->Manifest_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Manifest) */
			errn = encodeNBitUnsignedInteger(stream, 8, 117);
			if(errn == 0) {
				errn = encode_dinManifestType(stream, &exiFrag->Manifest );
			}
		} else if ( exiFrag->MeterID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 118);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->MeterID.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->MeterID.characters, exiFrag->MeterID.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeterInfo_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeterInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 119);
			if(errn == 0) {
				errn = encode_dinMeterInfoType(stream, &exiFrag->MeterInfo );
			}
		} else if ( exiFrag->MeterReading_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterReading) */
			errn = encodeNBitUnsignedInteger(stream, 8, 120);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->MeterReading );
			}
		} else if ( exiFrag->MeterStatus_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}MeterStatus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 121);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->MeterStatus);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->MeteringReceiptReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 122);
			if(errn == 0) {
				errn = encode_dinMeteringReceiptReqType(stream, &exiFrag->MeteringReceiptReq );
			}
		} else if ( exiFrag->MeteringReceiptRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}MeteringReceiptRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 123);
			if(errn == 0) {
				errn = encode_dinMeteringReceiptResType(stream, &exiFrag->MeteringReceiptRes );
			}
		} else if ( exiFrag->MgmtData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}MgmtData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 124);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->MgmtData.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->MgmtData.characters, exiFrag->MgmtData.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Modulus_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Modulus) */
			errn = encodeNBitUnsignedInteger(stream, 8, 125);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Modulus.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Modulus.bytes, exiFrag->Modulus.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Multiplier_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Multiplier) */
			errn = encodeNBitUnsignedInteger(stream, 8, 126);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(exiFrag->Multiplier + 3));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Notification_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}Notification) */
			errn = encodeNBitUnsignedInteger(stream, 8, 127);
			if(errn == 0) {
				errn = encode_dinNotificationType(stream, &exiFrag->Notification );
			}
		} else if ( exiFrag->NotificationMaxDelay_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NotificationMaxDelay) */
			errn = encodeNBitUnsignedInteger(stream, 8, 128);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->NotificationMaxDelay);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->NumEPriceLevels_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}NumEPriceLevels) */
			errn = encodeNBitUnsignedInteger(stream, 8, 129);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->NumEPriceLevels - 0));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->OEMProvisioningCert_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}OEMProvisioningCert) */
			errn = encodeNBitUnsignedInteger(stream, 8, 130);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->OEMProvisioningCert.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->OEMProvisioningCert.bytes, exiFrag->OEMProvisioningCert.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Object_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Object) */
			errn = encodeNBitUnsignedInteger(stream, 8, 131);
			if(errn == 0) {
				errn = encode_dinObjectType(stream, &exiFrag->Object );
			}
		} else if ( exiFrag->P_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}P) */
			errn = encodeNBitUnsignedInteger(stream, 8, 132);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->P.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->P.bytes, exiFrag->P.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PGPData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 133);
			if(errn == 0) {
				errn = encode_dinPGPDataType(stream, &exiFrag->PGPData );
			}
		} else if ( exiFrag->PGPKeyID_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 134);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PGPKeyID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PGPKeyID.bytes, exiFrag->PGPKeyID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PGPKeyPacket_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PGPKeyPacket) */
			errn = encodeNBitUnsignedInteger(stream, 8, 135);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PGPKeyPacket.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PGPKeyPacket.bytes, exiFrag->PGPKeyPacket.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PMax_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMax) */
			errn = encodeNBitUnsignedInteger(stream, 8, 136);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->PMax);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PMaxSchedule_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxSchedule) */
			errn = encodeNBitUnsignedInteger(stream, 8, 137);
			if(errn == 0) {
				errn = encode_dinPMaxScheduleType(stream, &exiFrag->PMaxSchedule );
			}
		} else if ( exiFrag->PMaxScheduleEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 138);
			if(errn == 0) {
				errn = encode_dinPMaxScheduleEntryType(stream, &exiFrag->PMaxScheduleEntry );
			}
		} else if ( exiFrag->PMaxScheduleID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PMaxScheduleID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 139);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->PMaxScheduleID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Parameter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Parameter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 140);
			if(errn == 0) {
				errn = encode_dinParameterType(stream, &exiFrag->Parameter );
			}
		} else if ( exiFrag->ParameterSet_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSet) */
			errn = encodeNBitUnsignedInteger(stream, 8, 141);
			if(errn == 0) {
				errn = encode_dinParameterSetType(stream, &exiFrag->ParameterSet );
			}
		} else if ( exiFrag->ParameterSetID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ParameterSetID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 142);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->ParameterSetID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PaymentDetailsReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 143);
			if(errn == 0) {
				errn = encode_dinPaymentDetailsReqType(stream, &exiFrag->PaymentDetailsReq );
			}
		} else if ( exiFrag->PaymentDetailsRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentDetailsRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 144);
			if(errn == 0) {
				errn = encode_dinPaymentDetailsResType(stream, &exiFrag->PaymentDetailsRes );
			}
		} else if ( exiFrag->PaymentOption_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PaymentOption) */
			errn = encodeNBitUnsignedInteger(stream, 8, 145);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->PaymentOption);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PaymentOptions_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PaymentOptions) */
			errn = encodeNBitUnsignedInteger(stream, 8, 146);
			if(errn == 0) {
				errn = encode_dinPaymentOptionsType(stream, &exiFrag->PaymentOptions );
			}
		} else if ( exiFrag->PgenCounter_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}PgenCounter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 147);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->PgenCounter.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->PgenCounter.bytes, exiFrag->PgenCounter.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PowerDeliveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 148);
			if(errn == 0) {
				errn = encode_dinPowerDeliveryReqType(stream, &exiFrag->PowerDeliveryReq );
			}
		} else if ( exiFrag->PowerDeliveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PowerDeliveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 149);
			if(errn == 0) {
				errn = encode_dinPowerDeliveryResType(stream, &exiFrag->PowerDeliveryRes );
			}
		} else if ( exiFrag->PowerSwitchClosed_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}PowerSwitchClosed) */
			errn = encodeNBitUnsignedInteger(stream, 8, 150);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->PowerSwitchClosed);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->PreChargeReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 151);
			if(errn == 0) {
				errn = encode_dinPreChargeReqType(stream, &exiFrag->PreChargeReq );
			}
		} else if ( exiFrag->PreChargeRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}PreChargeRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 152);
			if(errn == 0) {
				errn = encode_dinPreChargeResType(stream, &exiFrag->PreChargeRes );
			}
		} else if ( exiFrag->ProfileEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ProfileEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 153);
			if(errn == 0) {
				errn = encode_dinProfileEntryType(stream, &exiFrag->ProfileEntry );
			}
		} else if ( exiFrag->Q_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Q) */
			errn = encodeNBitUnsignedInteger(stream, 8, 154);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Q.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Q.bytes, exiFrag->Q.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RCD_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RCD) */
			errn = encodeNBitUnsignedInteger(stream, 8, 155);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->RCD);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RSAKeyValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RSAKeyValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 156);
			if(errn == 0) {
				errn = encode_dinRSAKeyValueType(stream, &exiFrag->RSAKeyValue );
			}
		} else if ( exiFrag->ReadyToChargeState_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReadyToChargeState) */
			errn = encodeNBitUnsignedInteger(stream, 8, 157);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ReadyToChargeState);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ReceiptRequired_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ReceiptRequired) */
			errn = encodeNBitUnsignedInteger(stream, 8, 158);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->ReceiptRequired);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Reference_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Reference) */
			errn = encodeNBitUnsignedInteger(stream, 8, 159);
			if(errn == 0) {
				errn = encode_dinReferenceType(stream, &exiFrag->Reference );
			}
		} else if ( exiFrag->RelativeTimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RelativeTimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 8, 160);
			if(errn == 0) {
				errn = encode_dinRelativeTimeIntervalType(stream, &exiFrag->RelativeTimeInterval );
			}
		} else if ( exiFrag->RemainingTimeToBulkSoC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToBulkSoC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 161);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->RemainingTimeToBulkSoC );
			}
		} else if ( exiFrag->RemainingTimeToFullSoC_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RemainingTimeToFullSoC) */
			errn = encodeNBitUnsignedInteger(stream, 8, 162);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->RemainingTimeToFullSoC );
			}
		} else if ( exiFrag->ResponseCode_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ResponseCode) */
			errn = encodeNBitUnsignedInteger(stream, 8, 163);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 5, exiFrag->ResponseCode);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RetrievalMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}RetrievalMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 164);
			if(errn == 0) {
				errn = encode_dinRetrievalMethodType(stream, &exiFrag->RetrievalMethod );
			}
		} else if ( exiFrag->RetryCounter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}RetryCounter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 165);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->RetryCounter);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->RootCertificateID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}RootCertificateID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 166);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->RootCertificateID.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->RootCertificateID.characters, exiFrag->RootCertificateID.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SAScheduleList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 167);
			if(errn == 0) {
				errn = encode_dinSAScheduleListType(stream, &exiFrag->SAScheduleList );
			}
		} else if ( exiFrag->SAScheduleTuple_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTuple) */
			errn = encodeNBitUnsignedInteger(stream, 8, 168);
			if(errn == 0) {
				errn = encode_dinSAScheduleTupleType(stream, &exiFrag->SAScheduleTuple );
			}
		} else if ( exiFrag->SAScheduleTupleID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SAScheduleTupleID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 169);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->SAScheduleTupleID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SAScheduleTupleID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SAScheduleTupleID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 170);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->SAScheduleTupleID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SASchedules_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SASchedules) */
			errn = encodeNBitUnsignedInteger(stream, 8, 171);
			if(errn == 0) {
				errn = encode_dinSASchedulesType(stream, &exiFrag->SASchedules );
			}
		} else if ( exiFrag->SPKIData_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKIData) */
			errn = encodeNBitUnsignedInteger(stream, 8, 172);
			if(errn == 0) {
				errn = encode_dinSPKIDataType(stream, &exiFrag->SPKIData );
			}
		} else if ( exiFrag->SPKISexp_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SPKISexp) */
			errn = encodeNBitUnsignedInteger(stream, 8, 173);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SPKISexp.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SPKISexp.bytes, exiFrag->SPKISexp.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SalesTariff_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariff) */
			errn = encodeNBitUnsignedInteger(stream, 8, 174);
			if(errn == 0) {
				errn = encode_dinSalesTariffType(stream, &exiFrag->SalesTariff );
			}
		} else if ( exiFrag->SalesTariffDescription_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffDescription) */
			errn = encodeNBitUnsignedInteger(stream, 8, 175);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SalesTariffDescription.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->SalesTariffDescription.characters, exiFrag->SalesTariffDescription.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SalesTariffEntry_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffEntry) */
			errn = encodeNBitUnsignedInteger(stream, 8, 176);
			if(errn == 0) {
				errn = encode_dinSalesTariffEntryType(stream, &exiFrag->SalesTariffEntry );
			}
		} else if ( exiFrag->SalesTariffID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SalesTariffID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 177);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->SalesTariffID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Seed_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Seed) */
			errn = encodeNBitUnsignedInteger(stream, 8, 178);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Seed.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Seed.bytes, exiFrag->Seed.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SelectedPaymentOption_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedPaymentOption) */
			errn = encodeNBitUnsignedInteger(stream, 8, 179);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 1, exiFrag->SelectedPaymentOption);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SelectedService_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SelectedService) */
			errn = encodeNBitUnsignedInteger(stream, 8, 180);
			if(errn == 0) {
				errn = encode_dinSelectedServiceType(stream, &exiFrag->SelectedService );
			}
		} else if ( exiFrag->SelectedServiceList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SelectedServiceList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 181);
			if(errn == 0) {
				errn = encode_dinSelectedServiceListType(stream, &exiFrag->SelectedServiceList );
			}
		} else if ( exiFrag->Service_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Service) */
			errn = encodeNBitUnsignedInteger(stream, 8, 182);
			if(errn == 0) {
				errn = encode_dinServiceType(stream, &exiFrag->Service );
			}
		} else if ( exiFrag->ServiceCategory_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceCategory) */
			errn = encodeNBitUnsignedInteger(stream, 8, 183);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->ServiceCategory);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceCategory_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCategory) */
			errn = encodeNBitUnsignedInteger(stream, 8, 184);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->ServiceCategory);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceCharge_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceCharge) */
			errn = encodeNBitUnsignedInteger(stream, 8, 185);
			if(errn == 0) {
				errn = encode_dinServiceChargeType(stream, &exiFrag->ServiceCharge );
			}
		} else if ( exiFrag->ServiceDetailReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 186);
			if(errn == 0) {
				errn = encode_dinServiceDetailReqType(stream, &exiFrag->ServiceDetailReq );
			}
		} else if ( exiFrag->ServiceDetailRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDetailRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 187);
			if(errn == 0) {
				errn = encode_dinServiceDetailResType(stream, &exiFrag->ServiceDetailRes );
			}
		} else if ( exiFrag->ServiceDiscoveryReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 188);
			if(errn == 0) {
				errn = encode_dinServiceDiscoveryReqType(stream, &exiFrag->ServiceDiscoveryReq );
			}
		} else if ( exiFrag->ServiceDiscoveryRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceDiscoveryRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 189);
			if(errn == 0) {
				errn = encode_dinServiceDiscoveryResType(stream, &exiFrag->ServiceDiscoveryRes );
			}
		} else if ( exiFrag->ServiceID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 190);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->ServiceID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 191);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, exiFrag->ServiceID);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 192);
			if(errn == 0) {
				errn = encode_dinServiceTagListType(stream, &exiFrag->ServiceList );
			}
		} else if ( exiFrag->ServiceName_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 193);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceName.characters, exiFrag->ServiceName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceParameterList_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceParameterList) */
			errn = encodeNBitUnsignedInteger(stream, 8, 194);
			if(errn == 0) {
				errn = encode_dinServiceParameterListType(stream, &exiFrag->ServiceParameterList );
			}
		} else if ( exiFrag->ServicePaymentSelectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 195);
			if(errn == 0) {
				errn = encode_dinServicePaymentSelectionReqType(stream, &exiFrag->ServicePaymentSelectionReq );
			}
		} else if ( exiFrag->ServicePaymentSelectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServicePaymentSelectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 196);
			if(errn == 0) {
				errn = encode_dinServicePaymentSelectionResType(stream, &exiFrag->ServicePaymentSelectionRes );
			}
		} else if ( exiFrag->ServiceScope_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}ServiceScope) */
			errn = encodeNBitUnsignedInteger(stream, 8, 197);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceScope.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceScope.characters, exiFrag->ServiceScope.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceScope_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceScope) */
			errn = encodeNBitUnsignedInteger(stream, 8, 198);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->ServiceScope.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->ServiceScope.characters, exiFrag->ServiceScope.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->ServiceTag_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}ServiceTag) */
			errn = encodeNBitUnsignedInteger(stream, 8, 199);
			if(errn == 0) {
				errn = encode_dinServiceTagType(stream, &exiFrag->ServiceTag );
			}
		} else if ( exiFrag->SessionID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 200);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SessionID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SessionID.bytes, exiFrag->SessionID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SessionID_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgHeader}SessionID) */
			errn = encodeNBitUnsignedInteger(stream, 8, 201);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_HEX]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SessionID.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SessionID.bytes, exiFrag->SessionID.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->SessionSetupReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 202);
			if(errn == 0) {
				errn = encode_dinSessionSetupReqType(stream, &exiFrag->SessionSetupReq );
			}
		} else if ( exiFrag->SessionSetupRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionSetupRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 203);
			if(errn == 0) {
				errn = encode_dinSessionSetupResType(stream, &exiFrag->SessionSetupRes );
			}
		} else if ( exiFrag->SessionStopReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 204);
			if(errn == 0) {
				errn = encode_dinSessionStopType(stream, &exiFrag->SessionStopReq );
			}
		} else if ( exiFrag->SessionStopRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}SessionStopRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 205);
			if(errn == 0) {
				errn = encode_dinSessionStopResType(stream, &exiFrag->SessionStopRes );
			}
		} else if ( exiFrag->SigMeterReading_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SigMeterReading) */
			errn = encodeNBitUnsignedInteger(stream, 8, 206);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->SigMeterReading.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->SigMeterReading.bytes, exiFrag->SigMeterReading.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Signature_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Signature) */
			errn = encodeNBitUnsignedInteger(stream, 8, 207);
			if(errn == 0) {
				errn = encode_dinSignatureType(stream, &exiFrag->Signature );
			}
		} else if ( exiFrag->SignatureMethod_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureMethod) */
			errn = encodeNBitUnsignedInteger(stream, 8, 208);
			if(errn == 0) {
				errn = encode_dinSignatureMethodType(stream, &exiFrag->SignatureMethod );
			}
		} else if ( exiFrag->SignatureProperties_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperties) */
			errn = encodeNBitUnsignedInteger(stream, 8, 209);
			if(errn == 0) {
				errn = encode_dinSignaturePropertiesType(stream, &exiFrag->SignatureProperties );
			}
		} else if ( exiFrag->SignatureProperty_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureProperty) */
			errn = encodeNBitUnsignedInteger(stream, 8, 210);
			if(errn == 0) {
				errn = encode_dinSignaturePropertyType(stream, &exiFrag->SignatureProperty );
			}
		} else if ( exiFrag->SignatureValue_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignatureValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 211);
			if(errn == 0) {
				errn = encode_dinSignatureValueType(stream, &exiFrag->SignatureValue );
			}
		} else if ( exiFrag->SignedInfo_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}SignedInfo) */
			errn = encodeNBitUnsignedInteger(stream, 8, 212);
			if(errn == 0) {
				errn = encode_dinSignedInfoType(stream, &exiFrag->SignedInfo );
			}
		} else if ( exiFrag->SubCertificates_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}SubCertificates) */
			errn = encodeNBitUnsignedInteger(stream, 8, 213);
			if(errn == 0) {
				errn = encode_dinSubCertificatesType(stream, &exiFrag->SubCertificates );
			}
		} else if ( exiFrag->TMeter_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TMeter) */
			errn = encodeNBitUnsignedInteger(stream, 8, 214);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->TMeter);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->TimeInterval_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}TimeInterval) */
			errn = encodeNBitUnsignedInteger(stream, 8, 215);
			if(errn == 0) {
				errn = encode_dinIntervalType(stream, &exiFrag->TimeInterval );
			}
		} else if ( exiFrag->Transform_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transform) */
			errn = encodeNBitUnsignedInteger(stream, 8, 216);
			if(errn == 0) {
				errn = encode_dinTransformType(stream, &exiFrag->Transform );
			}
		} else if ( exiFrag->Transforms_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Transforms) */
			errn = encodeNBitUnsignedInteger(stream, 8, 217);
			if(errn == 0) {
				errn = encode_dinTransformsType(stream, &exiFrag->Transforms );
			}
		} else if ( exiFrag->Unit_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Unit) */
			errn = encodeNBitUnsignedInteger(stream, 8, 218);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 4, exiFrag->Unit);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->V2G_Message_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDef}V2G_Message) */
			errn = encodeNBitUnsignedInteger(stream, 8, 219);
			if(errn == 0) {
				errn = encode_dinAnonType_V2G_Message(stream, &exiFrag->V2G_Message );
			}
		} else if ( exiFrag->Value_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}Value) */
			errn = encodeNBitUnsignedInteger(stream, 8, 220);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->Value);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->WeldingDetectionReq_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionReq) */
			errn = encodeNBitUnsignedInteger(stream, 8, 221);
			if(errn == 0) {
				errn = encode_dinWeldingDetectionReqType(stream, &exiFrag->WeldingDetectionReq );
			}
		} else if ( exiFrag->WeldingDetectionRes_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgBody}WeldingDetectionRes) */
			errn = encodeNBitUnsignedInteger(stream, 8, 222);
			if(errn == 0) {
				errn = encode_dinWeldingDetectionResType(stream, &exiFrag->WeldingDetectionRes );
			}
		} else if ( exiFrag->X509CRL_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509CRL) */
			errn = encodeNBitUnsignedInteger(stream, 8, 223);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509CRL.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509CRL.bytes, exiFrag->X509CRL.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509Certificate_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Certificate) */
			errn = encodeNBitUnsignedInteger(stream, 8, 224);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509Certificate.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509Certificate.bytes, exiFrag->X509Certificate.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509Data_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509Data) */
			errn = encodeNBitUnsignedInteger(stream, 8, 225);
			if(errn == 0) {
				errn = encode_dinX509DataType(stream, &exiFrag->X509Data );
			}
		} else if ( exiFrag->X509IssuerName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 226);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509IssuerName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->X509IssuerName.characters, exiFrag->X509IssuerName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509IssuerSerial_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509IssuerSerial) */
			errn = encodeNBitUnsignedInteger(stream, 8, 227);
			if(errn == 0) {
				errn = encode_dinX509IssuerSerialType(stream, &exiFrag->X509IssuerSerial );
			}
		} else if ( exiFrag->X509SKI_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SKI) */
			errn = encodeNBitUnsignedInteger(stream, 8, 228);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509SKI.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->X509SKI.bytes, exiFrag->X509SKI.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509SerialNumber_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SerialNumber) */
			errn = encodeNBitUnsignedInteger(stream, 8, 229);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger64(stream, exiFrag->X509SerialNumber);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->X509SubjectName_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}X509SubjectName) */
			errn = encodeNBitUnsignedInteger(stream, 8, 230);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->X509SubjectName.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->X509SubjectName.characters, exiFrag->X509SubjectName.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->XPath_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}XPath) */
			errn = encodeNBitUnsignedInteger(stream, 8, 231);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->XPath.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->XPath.characters, exiFrag->XPath.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->Y_isUsed == 1u ) { 
			/* START_ELEMENT({http://www.w3.org/2000/09/xmldsig#}Y) */
			errn = encodeNBitUnsignedInteger(stream, 8, 232);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BINARY_BASE64]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->Y.bytesLen));
					if (errn == 0) {
						errn = encodeBytes(stream, exiFrag->Y.bytes, exiFrag->Y.bytesLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->amount_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amount) */
			errn = encodeNBitUnsignedInteger(stream, 8, 233);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->amount);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->amountMultiplier_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}amountMultiplier) */
			errn = encodeNBitUnsignedInteger(stream, 8, 234);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 3, (uint32_t)(exiFrag->amountMultiplier + 3));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->boolValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}boolValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 235);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[BOOLEAN]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeBoolean(stream, exiFrag->boolValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->byteValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}byteValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 236);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[NBIT_UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 8, (uint32_t)(exiFrag->byteValue + 128));
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->costKind_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}costKind) */
			errn = encodeNBitUnsignedInteger(stream, 8, 237);
			if(errn == 0) {
				/* FirstStartTag[CHARACTERS[ENUMERATION]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeNBitUnsignedInteger(stream, 2, exiFrag->costKind);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->duration_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}duration) */
			errn = encodeNBitUnsignedInteger(stream, 8, 238);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->duration);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->intValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}intValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 239);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger32(stream, exiFrag->intValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->physicalValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}physicalValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 240);
			if(errn == 0) {
				errn = encode_dinPhysicalValueType(stream, &exiFrag->physicalValue );
			}
		} else if ( exiFrag->shortValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}shortValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 241);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeInteger16(stream, exiFrag->shortValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->start_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}start) */
			errn = encodeNBitUnsignedInteger(stream, 8, 242);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->start);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->startValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}startValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 243);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[UNSIGNED_INTEGER]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					errn = encodeUnsignedInteger32(stream, exiFrag->startValue);
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else if ( exiFrag->stringValue_isUsed == 1u ) { 
			/* START_ELEMENT({urn:iso:15118:2:2010:MsgDataTypes}stringValue) */
			errn = encodeNBitUnsignedInteger(stream, 8, 244);
			if(errn == 0) {
				/* First(xsi:type)StartTag[CHARACTERS[STRING]] */
				errn = encodeNBitUnsignedInteger(stream, 1, 0);
				if(errn == 0) {
					/* encode string as string table miss (+2 len)*/
					errn = encodeUnsignedInteger16(stream, (uint16_t)(exiFrag->stringValue.charactersLen + 2));
					if (errn == 0) {
						errn = encodeCharacters(stream, exiFrag->stringValue.characters, exiFrag->stringValue.charactersLen);
					}
					/* valid EE */
					errn = encodeNBitUnsignedInteger(stream, 1, 0);
				}
			}
		} else {
			errn = EXI_ERROR_UNKOWN_EVENT;
		}
	}
	if(errn == 0) {
		/* EndDocument */
		errn = encodeNBitUnsignedInteger(stream, 8, 246);
	}


	if(errn == 0) {
		/* flush any pending bits */
		errn = encodeFinish(stream);
	}

	return errn;
}
#endif /* DEPLOY_DIN_CODEC_FRAGMENT */


#endif /* DEPLOY_DIN_CODEC */

#endif

