From bce23619fe58784a83eb18e4d7ec10bb5e586720 Mon Sep 17 00:00:00 2001 From: garciay Date: Wed, 17 Aug 2016 14:24:49 +0000 Subject: [PATCH] Add a workaround on incorrect decodeHypothesis returned value ("per-basic-unaligned:1997") --- .../its/tool/elvior/Its_CodecProvider.java | 8 +++++- .../org/etsi/its/tool/elvior/LibIts_asn1.java | 21 ++++++++++++++- .../org/etsi/tool/elvior/TciCDWrapper.java | 26 +++++++++++++++---- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/javasrc/tool/org/etsi/its/tool/elvior/Its_CodecProvider.java b/javasrc/tool/org/etsi/its/tool/elvior/Its_CodecProvider.java index e4778614d..a2e1e9054 100644 --- a/javasrc/tool/org/etsi/its/tool/elvior/Its_CodecProvider.java +++ b/javasrc/tool/org/etsi/its/tool/elvior/Its_CodecProvider.java @@ -87,7 +87,13 @@ public class Its_CodecProvider implements TciCDProvided, ChannelEventHandler, IT } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { e.printStackTrace(); } - } // End of 'foreach' loop + } // End of 'for' loop + + try { + _cf.setExternalCodec("per-basic-unaligned:1997", (TciCDProvided) Class.forName("org.etsi.its.tool.elvior.LibIts_asn1").newInstance()); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + e.printStackTrace(); + } } public void run() { diff --git a/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java b/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java index 504f321eb..8257a2e90 100644 --- a/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java +++ b/javasrc/tool/org/etsi/its/tool/elvior/LibIts_asn1.java @@ -59,7 +59,26 @@ public class LibIts_asn1 implements TciCDProvided { msg.setEncodedMessage(message.getEncodedMessage()); if (_logger.isLoggable(Level.ALL)) ByteHelper.dump("LibIts_asn1.decode: ", msg.getEncodedMessage()); - String type = String.format("%s.%s", _encodingName, decodingHypothesis.getName()); + String type = ""; + if (decodingHypothesis.getTypeEncoding().equals("per-basic-unaligned:1997")) { + if (decodingHypothesis.getName().equals("CAM")) { + type = String.format("%s.%s", "CAM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("DENM")) { + type = String.format("%s.%s", "DENM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("MAPEM")) { + type = String.format("%s.%s", "MAPEM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("SPATEM")) { + type = String.format("%s.%s", "SPATEM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("IVIM")) { + type = String.format("%s.%s", "IVIM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("SREM")) { + type = String.format("%s.%s", "SREM_PDU_Descriptions", decodingHypothesis.getName()); + } else if (decodingHypothesis.getName().equals("SSEM")) { + type = String.format("%s.%s", "SSEM_PDU_Descriptions", decodingHypothesis.getName()); + } + } else { + type = String.format("%s.%s", _encodingName, decodingHypothesis.getName()); + } _logger.info("Type: " + type); Type asnOriginalType = getTypeForName(type); // Check which type class the decoding hypothesis is of diff --git a/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java b/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java index 532b008ab..8954309cb 100644 --- a/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java +++ b/javasrc/tool/org/etsi/tool/elvior/TciCDWrapper.java @@ -104,7 +104,7 @@ public class TciCDWrapper implements ITciCDWrapper { String variantTypeName = decodingHypothesis.getDefiningModule().getModuleName() + "." + decodingHypothesis.getName() + "." + variantName; // TERFactory.getInstance().logDebug("variantTypeName is " + variantTypeName); - Type variantType = _tciFactory.getTypeForName(variantTypeName); + Type variantType = getTypeForName(variantTypeName); if(variantType != null) { Value testVal = variantType.newInstance(); if(testVal != null) { @@ -120,10 +120,26 @@ public class TciCDWrapper implements ITciCDWrapper { @Override public Type getTypeForName(final String type) { -// return TciProvider.getInstance().getTciCDRequired().getTypeForName(type); -// TERFactory.getInstance().logDebug("TciCDWrapper.getTypeForName" + type); - Type originalType = TciProvider.getInstance().getTciCDRequired().getTypeForName(type); -// TERFactory.getInstance().logDebug("TciCDWrapper.getTypeForName" + originalType.getName()); +// TERFactory.getInstance().logDebug("TciCDWrapper.getTypeForName: " + type); + Type originalType; + if (type.indexOf("DecodedBtpPayload") != -1) { + if (type.endsWith("camPacket")) { + originalType = _tciFactory.getTypeForName("CAM_PDU_Descriptions.CAM"); + } else if (type.endsWith("denmPacket")) { + originalType = _tciFactory.getTypeForName("DENM_PDU_Descriptions.DENM"); + } else if (type.endsWith("mapemPacket")) { + originalType = _tciFactory.getTypeForName("MAPEM_PDU_Descriptions.MAPEM"); + } else if (type.endsWith("spatemPacket")) { + originalType = _tciFactory.getTypeForName("MAPEM_PDU_Descriptions.SPATEM"); + } else if (type.endsWith("ivimPacket")) { + originalType = _tciFactory.getTypeForName("IVIM_PDU_Descriptions.IVIM"); + } else { + originalType = _tciFactory.getTypeForName(type); + } + } else { + originalType = _tciFactory.getTypeForName(type); + } +// TERFactory.getInstance().logDebug("TciCDWrapper.getTypeForName: " + originalType.getName()); return originalType; } // End of method getTypeForName -- GitLab