Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.its.tool.testingtech;
import org.etsi.tool.testingtech.TTWBCodecSupport;
import org.etsi.ttcn.tci.TciCDProvided;
import org.etsi.ttcn.tci.TciCDRequired;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tri.TriMessage;
import org.etsi.ttcn.codec.CodecFactory;
import org.etsi.ttcn.codec.MainCodec;
import com.testingtech.ttcn.extension.CodecProvider;
import com.testingtech.util.plugin.PluginInitException;
import de.tu_berlin.cs.uebb.muttcn.runtime.RB;
/** This is the main entry point for Its codec
*/
public class Its_CodecProvider implements CodecProvider {
/**
* This method provides the codec associated to the specified encoding identifier
*
* @param rb TTwb Runtime reference
* @param encodingName The name of the encoding, specified by the TTCN-3 key words 'with/encode'
* @return The codec associated to the specified encoding identifier
*/
@Override
public TciCDProvided getCodec(RB rb, String encodingName) throws PluginInitException {
cdReq = rb.getTciCDRequired();
// Register External codecs
CodecFactory cf = CodecFactory.getInstance();
TTWBCodecSupport cs = new TTWBCodecSupport(rb);
cf.setExternalCodec("LibItsCam_asn1", cs.getCodec("LibItsCam_asn1"));
cf.setExternalCodec("LibItsDenm_asn1", cs.getCodec("LibItsDenm_asn1"));
//TODO: add V2G external codecs (xsd)
//TODO: Yann add CALM external codecs (ASN.1)
return new Codec();
}
private class Codec implements TciCDProvided {
@Override
public Value decode(TriMessage message, Type decodingHypothesis) {
MainCodec codec = new MainCodec(cdReq);
Value v = null;
try {
v = codec.triDecode(message, decodingHypothesis);
}
catch(Exception e) {
e.printStackTrace();
}
return v;
}
@Override
public TriMessage encode(Value value) {
MainCodec codec = new MainCodec(cdReq);
TriMessage m = null;
try {
m = codec.triEncode(value);
}
catch(Exception e) {
e.printStackTrace();
}
return m;
}
}
private TciCDRequired cdReq;
}