Commit bac556d6 authored by garciay's avatar garciay

Merge STF455 staff

parent 9920a292
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.adapter;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.common.ByteHelper;
import org.etsi.ttcn.tci.UnionValue;
public class AcFsapPrimitive extends Union {
public AcFsapPrimitive(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preEncode(CodecBuffer buf, UnionValue uv) {
String variant = uv.getPresentVariantName();
int primitiveId = -1;
// Append AcGnPrimitive message id
buf.appendBytes(ByteHelper.intToByteArray(2, 1)); // AdapterControl Primitive identifer for AcFsapPrimitive
// Append primitive command identifier
if(variant.equals("inSapPrimitivesUp")) {
primitiveId = 0;
}
else if(variant.equals("stopTransmission")) {
primitiveId = 1;
}
buf.appendBytes(ByteHelper.intToByteArray(primitiveId, 1));
}
}
...@@ -15,5 +15,6 @@ public class Plugin { ...@@ -15,5 +15,6 @@ public class Plugin {
CodecFactory cf = CodecFactory.getInstance(); CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.UNION, "AdapterControl", "AcGnPrimitive", AcGnPrimitive.class); cf.setCodec(TciTypeClass.UNION, "AdapterControl", "AcGnPrimitive", AcGnPrimitive.class);
cf.setCodec(TciTypeClass.UNION, "AdapterControl", "AcGnResponse", AcGnResponse.class); cf.setCodec(TciTypeClass.UNION, "AdapterControl", "AcGnResponse", AcGnResponse.class);
cf.setCodec(TciTypeClass.UNION, "AdapterControl", "AcFsapPrimitive", AcFsapPrimitive.class);
} }
} }
\ No newline at end of file
package org.etsi.ttcn.codec.its.atsp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class AtspInd extends Record {
public AtspInd(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
System.out.println("FntpInd.preDecodeField: " + fieldName + " - " + decodingHypothesis.getName());
if(fieldName.equals("receptionTime")) {
buf.overwriteWith(receptionTime);
}
}
@Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
int msgLen = buf.getNbBits() - 6/*Time48IAT*/ * Byte.SIZE;
receptionTime = buf.getBuffer(msgLen, 6 * Byte.SIZE);
}
private CodecBuffer receptionTime = null;
} // End of class FntpInd
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.atsp;
import org.etsi.ttcn.tci.TciTypeClass;
import org.etsi.ttcn.codec.CodecFactory;
public class Plugin {
public static void init() {
CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.RECORD, "LibIts_Interface", "AtspInd", AtspInd.class);
}
}
\ No newline at end of file
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Boolean;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class CfBoolean extends Boolean {
public CfBoolean(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
Byte id = CfPduId.value(decodingHypothesis.getName());
if(id != null) {
byte[] readId = buf.readBytes(1);
if(readId[0] != id) {
return null;
}
}
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
Byte id = CfPduId.value(value.getType().getName());
if(id != null) {
return new CodecBuffer(new byte[] {id.byteValue()});
}
return null;
}
}
/**
* @author ETSI / STF462 / STF455
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import java.util.HashMap;
import java.util.Map;
public enum CfPduId {
/* From LibItsCommon_TypesAndValues */
CfResult(0x25),
/* From LibItsFntp_TypesAndValues */
CfInitialize_cfFntpInitialize (0x10),
CfFntpEventInd_mnRequestRequest (0x1a),
/* From LibItsFsap_TypesAndValues */
CfInitialize_cfFsapInitialize (0x20),
CfFsapEventInd_mfRequestRequest (0x2a),
/* From LibItsAtsp_TypesAndValues */
CfInitialize_cfIicpInitialize (0x30),
/* From LibItsAtsp_TypesAndValues */
CfInitialize_cfAtspInitialize (0x40),
/* Reserved */
reserved(0xFF);
private byte value;
private static final Map<String, Byte> UtPduIds = new HashMap<String, Byte>();
private static final Map<Byte, String> UtPduNames = new HashMap<Byte, String>();
private CfPduId(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
return UtPduIds.get(name);
}
public static String name(Byte value) {
return UtPduNames.get(value);
}
static {
for (CfPduId item : CfPduId.values()) {
UtPduIds.put(item.name(), new Byte(item.value));
UtPduNames.put(new Byte(item.value), item.name());
}
}
}
\ No newline at end of file
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class CfRecord extends Record {
public CfRecord(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
System.out.println("CfRecord.decode: " + decodingHypothesis.getName());
Byte id = CfPduId.value(decodingHypothesis.getName());
if(id != null) {
byte[] readId = buf.readBytes(1);
if(readId[0] != id) {
return null;
}
}
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
System.out.println("UtRecord.preEncode: " + value.getType().getName());
Byte id = CfPduId.value(value.getType().getName());
if(id != null) {
return new CodecBuffer(new byte[] {id.byteValue()});
}
return null;
}
}
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.UnionValue;
import org.etsi.ttcn.tci.Value;
public class CfUnion extends Union {
public CfUnion(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
String variant = "";
Byte type = new Byte((byte)(0x00FF & buf.readBytes(1)[0]));
Pattern variantNamePattern = Pattern.compile(decodingHypothesis.getName() + "_(\\S+)");
System.out.println("CfUnion.decode: " + variantNamePattern + " / " + decodingHypothesis.getName());
Matcher matcher = variantNamePattern.matcher(CfPduId.name(type));
if (matcher.find()) {
variant = matcher.group(1);
}
else {
return null;
}
mainCodec.setHint(decodingHypothesis.getName(), variant);
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
UnionValue uv = (UnionValue)value;
System.out.println("CfUnion.preEncode: " + value.getType().getName() + "_" + uv.getPresentVariantName());
Byte id = CfPduId.value(value.getType().getName() + "_" + uv.getPresentVariantName());
if(id != null) {
return new CodecBuffer(new byte[] {id.byteValue()});
}
return null;
}
}
/**
* @author ETSI / STF455 / Yann Garcia
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.configtester;
import org.etsi.ttcn.codec.CodecFactory;
import org.etsi.ttcn.tci.TciTypeClass;
public class Plugin {
public static void init() {
CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.RECORD, "ConfigTester", "", CfRecord.class);
cf.setCodec(TciTypeClass.UNION, "ConfigTester", "", CfUnion.class);
cf.setCodec(TciTypeClass.BOOLEAN, "ConfigTester", "", CfBoolean.class);
}
}
\ No newline at end of file
package org.etsi.ttcn.codec.its.fntp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class FntpInd extends Record {
public FntpInd(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
System.out.println("FntpInd.preDecodeField: " + fieldName + " - " + decodingHypothesis.getName());
if(fieldName.equals("receptionTime")) {
buf.overwriteWith(receptionTime);
}
}
@Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
int msgLen = buf.getNbBits() - 6/*Time48IAT*/ * Byte.SIZE;
receptionTime = buf.getBuffer(msgLen, 6 * Byte.SIZE);
}
private CodecBuffer receptionTime = null;
} // End of class FntpInd
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.fntp;
import org.etsi.ttcn.tci.TciTypeClass;
import org.etsi.ttcn.codec.CodecFactory;
import org.etsi.ttcn.codec.generic.Union;
public class Plugin {
public static void init() {
CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.RECORD, "LibIts_Interface", "FntpInd", FntpInd.class);
cf.setCodec(TciTypeClass.UNION, "LibIts_Interface", "FntpReq", Union.class);
}
}
\ No newline at end of file
package org.etsi.ttcn.codec.its.fsap;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
public class FsapInd extends Record {
public FsapInd(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
System.out.println("FsapInd.preDecodeField: " + fieldName + " - " + decodingHypothesis.getName());
if(fieldName.equals("receptionTime")) {
buf.overwriteWith(receptionTime);
}
}
@Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
int msgLen = buf.getNbBits() - 6/*Time48IAT*/ * Byte.SIZE;
receptionTime = buf.getBuffer(msgLen, 6 * Byte.SIZE);
}
private CodecBuffer receptionTime = null;
} // End of class FsapInd
package org.etsi.ttcn.codec.its.fsap;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class FsapMsg extends Union {
public FsapMsg(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
System.out.println(String.format("FsapMsg.decode: %s - 0x%02x", decodingHypothesis.getName(), buf.getBytes()[0]));
String variant = "";
Byte spRef = buf.getBytes()[0]; // Cf. CALMllsap/INsapPrimitivesDown data structure description
switch (spRef) { // FIXME How to distinguish between the 2 variants of FsapMsg?
case 0x00:
variant = "msgIn_in";
mainCodec.setHint(decodingHypothesis.getName(), variant);
break;
default:
return null;
} // End of 'switch' statement
return super.decode(buf, decodingHypothesis);
}
} // End of class FsapMsg
package org.etsi.ttcn.codec.its.fsap;
import java.util.HashMap;
import java.util.Map;
public enum FsapPduId {
/* From */
IN_UNITDATA_request(0x00),
;
private byte value;
private static final Map<String, Byte> FsapPduIds = new HashMap<String, Byte>();
private static final Map<Byte, String> FsapPduNames = new HashMap<Byte, String>();
private FsapPduId(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
return FsapPduIds.get(name);
}
public static String name(Byte value) {
return FsapPduNames.get(value);
}
static {
for (FsapPduId item : FsapPduId.values()) {
FsapPduIds.put(item.name(), new Byte(item.value));
FsapPduNames.put(new Byte(item.value), item.name());
}
}
} // End of enum FsapPduId
\ No newline at end of file
package org.etsi.ttcn.codec.its.fsap;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
public class FsapReq extends Union {
public FsapReq(MainCodec mainCodec) {
super(mainCodec);
}
} // End of class FsapReq
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.fsap;
import org.etsi.ttcn.tci.TciTypeClass;
import org.etsi.ttcn.codec.CodecFactory;
public class Plugin {
public static void init() {
CodecFactory cf = CodecFactory.getInstance();
cf.setCodec(TciTypeClass.RECORD, "LibIts_Interface", "FsapInd", FsapInd.class);
cf.setCodec(TciTypeClass.UNION, "LibIts_Interface", "FsapMsg", FsapMsg.class);
cf.setCodec(TciTypeClass.UNION, "LibIts_Interface", "FsapReq", FsapReq.class);
}
}
\ No newline at end of file
package org.etsi.ttcn.codec.its.iicp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
public class IicpInd extends Record {
public IicpInd(MainCodec mainCodec) {
super(mainCodec);
}
@Override
protected void preDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
System.out.println("IicpInd.preDecodeField: " + fieldName + " - " + decodingHypothesis.getName());
if(fieldName.equals("receptionTime")) {
buf.overwriteWith(receptionTime);
}
}
@Override
protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
int msgLen = buf.getNbBits() - 6/*Time48IAT*/ * Byte.SIZE;
receptionTime = buf.getBuffer(msgLen, 6 * Byte.SIZE);
}
private CodecBuffer receptionTime = null;
} // End of class IicpInd
package org.etsi.ttcn.codec.its.iicp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Union;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class IicpMsg extends Union {
public IicpMsg(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
System.out.println(String.format("IicpMsg.decode: %s - 0x%02x", decodingHypothesis.getName(), buf.getBytes()[6]));
String variant = "";
Byte spRef = buf.getBytes()[6]; // Cf. IIC-Request/IIC-Response data structure description (RequestID field)
switch (spRef) {
case 0x00: // IIC-Request
variant = "msg_req";
mainCodec.setHint(decodingHypothesis.getName(), variant);
break;
case 0x01: // IIC-Response
variant = "msg_resp";
mainCodec.setHint(decodingHypothesis.getName(), variant);
break;
default:
return null;
} // End of 'switch' statement
return super.decode(buf, decodingHypothesis);
}
} // End of class IicpMsg
package org.etsi.ttcn.codec.its.iicp;
import java.util.HashMap;
import java.util.Map;
public enum IicpPduId {
IicpReq (0xa0),
IicpReq_msgOut (0xa1),
/* Reserved */
reserved(0xFF);
private byte value;
private static final Map<String, Byte> IicpPduIds = new HashMap<String, Byte>();
private static final Map<Byte, String> IicpPduNames = new HashMap<Byte, String>();
private IicpPduId(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
return IicpPduIds.get(name);
}
public static String name(Byte value) {
return IicpPduNames.get(value);
}
static {
for (IicpPduId item : IicpPduId.values()) {
IicpPduIds.put(item.name(), new Byte(item.value));
IicpPduNames.put(new Byte(item.value), item.name());
}
}
}
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.iicp;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class IicpRecord extends Record { // TODO Check to remove it
public IicpRecord(MainCodec mainCodec) {
super(mainCodec);
}
// @Override
// public Value decode(CodecBuffer buf, Type decodingHypothesis) {
//
// System.out.println("UtRecord.decode: " + decodingHypothesis.getName());
// Byte id = IicpPduId.value(decodingHypothesis.getName());
// if(id != null) {
// byte[] readId = buf.readBytes(1);
// if(readId[0] != id) {
// return null;
// }
// }
// return super.decode(buf, decodingHypothesis);
// }
//
// @Override
// public CodecBuffer preEncode(Value value) {
//
// System.out.println("UtRecord.preEncode: " + value.getType().getName());
// Byte id = IicpPduId.value(value.getType().getName());
// if(id != null) {
// return new CodecBuffer(new byte[] {id.byteValue()});
// }
// return null;
// }
}
/**
* @author ETSI / STF462 / Alexandre Berge
* @version $URL$
* $Id$
*/
package org.etsi.ttcn.codec.its.iicp;
import org.etsi.ttcn.codec.CodecFactory;
import org.etsi.ttcn.tci.TciTypeClass;