Commit 12dd8798 authored by garciay's avatar garciay

Add UT codec for IS

parent c1323615
......@@ -37,7 +37,7 @@ public class Plugin {
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtMapemEventInd", UtEventInd.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtSpatemEventInd", UtEventInd.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtMapemSpatemTrigger", UtMapemSpatemTrigger.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtMapemSpatemTriggerResult", UtMapemSpatemTriggerResult.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtMapemSpatemTriggerResult", UtBoolean.class);
// IVIM
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtIvimTrigger", UtIvimTrigger.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtIvimUpdate", UtIvimUpdate.class);
......@@ -46,7 +46,10 @@ public class Plugin {
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtIvimTriggerResult", UtIvimTermination.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtIvimUpdateResult", UtIvimTermination.class);
// SREM/SSEM
// TODO
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtSremEventInd", UtEventInd.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtSsemEventInd", UtEventInd.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtSremTrigger", UtSremTrigger.class);
cf.setCodec(TciTypeClass.RECORD, "UpperTester", "UtSremTriggerResult", UtBoolean.class);
}
}
\ No newline at end of file
......@@ -4,9 +4,13 @@ import org.etsi.ttcn.codec.MainCodec;
public class UtIvimTermination extends UtRecord {
public UtIvimTermination(MainCodec mainCodec) {
super(mainCodec);
// TODO Auto-generated constructor stub
}
public UtIvimTermination(MainCodec mainCodec) {
super(mainCodec);
setLengths();
}
private void setLengths() {
mainCodec.setHint("IviIdentificationNumberLen", "16");
}
}
package org.etsi.ttcn.codec.its.uppertester;
import java.util.HashMap;
import java.util.Map;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class UtIvimTrigger extends UtRecord implements IMarkerCallback {
private byte flags = 0x00;
public UtIvimTrigger(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
setLengths();
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
setLengths();
CodecBuffer buf = super.preEncode(value);
CodecBuffer bufFlags = new CodecBuffer();
bufFlags.setMarker("flags", 0, this);
buf.append(bufFlags);
return buf;
}
private void setLengths() {
mainCodec.setHint("TimestampItsLen", "48");
}
public class UtIvimTrigger extends UtRecord {
@Override
public CodecBuffer encode(Value value) {
RecordValue rv = (RecordValue)value;
String[] fields = rv.getFieldNames();
CodecBuffer buf = new CodecBuffer();
public UtIvimTrigger(MainCodec mainCodec) {
super(mainCodec);
// TODO Auto-generated constructor stub
}
for(int i=0; i < fields.length; i++) {
Value fieldValue = rv.getField(fields[i]);
if(!fieldValue.notPresent()) {
CodecBuffer fieldBuf = mainCodec.encode(fieldValue);
postEncodeField(fields[i], fieldBuf);
buf.append(fieldBuf);
flags = (byte) (flags | (PresenceFlag.value(fields[i])).byteValue());
}
else {
String hint = mainCodec.getHint(fieldValue.getType().getName() + "Len");
if(hint != null) {
int lengthInBits = java.lang.Integer.parseInt(hint);
int lengthInBytes = lengthInBits / 8 + (((lengthInBits % 8) > 0)?1:0);
for(int j=0; j < lengthInBytes; j++) {
buf.appendBytes(new byte[]{0x00});
}
}
}
}
return buf;
}
@Override
public void run(String markerName, CodecBuffer leftBuf, CodecBuffer rightBuf) {
CodecBuffer bufFlags = new CodecBuffer(new byte[] {flags});
bufFlags.append(rightBuf);
rightBuf.setBytes(bufFlags.getBytes());
}
private enum PresenceFlag {
/* DenmTrigger*/
validFrom(0x80),
validTo(0x40),
repetitionInterval(0x20),
/* Reserved */
reserved(0x00);
private byte value;
private static final Map<String, Byte> PresenceFlags = new HashMap<String, Byte>();
private PresenceFlag(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
Byte res = PresenceFlags.get(name);
if(res == null) {
return value("reserved");
}
return res;
}
static {
for (PresenceFlag item : PresenceFlag.values()) {
PresenceFlags.put(item.name(), new Byte(item.value));
}
}
}
}
package org.etsi.ttcn.codec.its.uppertester;
import java.util.HashMap;
import java.util.Map;
import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.IMarkerCallback;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.tci.RecordValue;
import org.etsi.ttcn.tci.Type;
import org.etsi.ttcn.tci.Value;
public class UtIvimUpdate extends UtRecord implements IMarkerCallback {
private byte flags = 0x00;
public UtIvimUpdate(MainCodec mainCodec) {
super(mainCodec);
}
@Override
public Value decode(CodecBuffer buf, Type decodingHypothesis) {
setLengths();
return super.decode(buf, decodingHypothesis);
}
@Override
public CodecBuffer preEncode(Value value) {
setLengths();
CodecBuffer buf = super.preEncode(value);
CodecBuffer bufFlags = new CodecBuffer();
bufFlags.setMarker("flags", 0, this);
buf.append(bufFlags);
return buf;
}
private void setLengths() {
mainCodec.setHint("TimestampItsLen", "48");
}
public class UtIvimUpdate extends UtRecord {
@Override
public CodecBuffer encode(Value value) {
RecordValue rv = (RecordValue)value;
String[] fields = rv.getFieldNames();
CodecBuffer buf = new CodecBuffer();
public UtIvimUpdate(MainCodec mainCodec) {
super(mainCodec);
// TODO Auto-generated constructor stub
}
for(int i=0; i < fields.length; i++) {
Value fieldValue = rv.getField(fields[i]);
if(!fieldValue.notPresent()) {
CodecBuffer fieldBuf = mainCodec.encode(fieldValue);
postEncodeField(fields[i], fieldBuf);
buf.append(fieldBuf);
flags = (byte) (flags | (PresenceFlag.value(fields[i])).byteValue());
}
else {
String hint = mainCodec.getHint(fieldValue.getType().getName() + "Len");
if(hint != null) {
int lengthInBits = java.lang.Integer.parseInt(hint);
int lengthInBytes = lengthInBits / 8 + (((lengthInBits % 8) > 0)?1:0);
for(int j=0; j < lengthInBytes; j++) {
buf.appendBytes(new byte[]{0x00});
}
}
}
}
return buf;
}
@Override
public void run(String markerName, CodecBuffer leftBuf, CodecBuffer rightBuf) {
CodecBuffer bufFlags = new CodecBuffer(new byte[] {flags});
bufFlags.append(rightBuf);
rightBuf.setBytes(bufFlags.getBytes());
}
private enum PresenceFlag {
/* IvimUpdate */
validFrom(0x80),
validTo(0x40),
repetitionInterval(0x20),
/* Reserved */
reserved(0x00);
private byte value;
private static final Map<String, Byte> PresenceFlags = new HashMap<String, Byte>();
private PresenceFlag(int value) {
this.value = (byte)value;
}
public static Byte value(String name) {
Byte res = PresenceFlags.get(name);
if(res == null) {
return value("reserved");
}
return res;
}
static {
for (PresenceFlag item : PresenceFlag.values()) {
PresenceFlags.put(item.name(), new Byte(item.value));
}
}
}
}
package org.etsi.ttcn.codec.its.uppertester;
import org.etsi.ttcn.codec.MainCodec;
public class UtMapemSpatemTriggerResult extends UtRecord {
public UtMapemSpatemTriggerResult(MainCodec mainCodec) {
super(mainCodec);
// TODO Auto-generated constructor stub
}
}
......@@ -87,12 +87,26 @@ public enum UtPduId {
UtSec_setCertificate(0x93),
UtSec_setPrivateKey(0x94),
UtSec_setTrustPoint(0x95),
/* From LibItsMapSpat_TypesAndValues */
UtMapSpatTrigger(0xA0),
UtMapSpatTriggerResult(0xA1),
UtMapEventInd(0xA2),
UtSpatEventInd(0xA3),
/* IS */
/* From LibItsMapemSpatem_TypesAndValues */
UtMapemSpatemTrigger(0xA0),
UtMapemSpatemTriggerResult(0xA1),
UtMapemEventInd(0xA2),
UtSpatemEventInd(0xA3),
/* From LibItsIvim_TypesAndValues */
UtIvimTrigger(0xA4),
UtIvimTriggerResult(0xA5),
UtIvimUpdate(0xA6),
UtIvimUpdateResult(0xA7),
UtIvimTermination(0xA8),
UtIvimTerminationResult(0xA9),
UtIvimEventInd(0xAA),
/* From LibItsSremSsem_TypesAndValues */
UtSremTrigger(0xAB),
UtSremTriggerResult(0xAC),
UtSremEventInd(0xAD),
UtSsemEventInd(0xAE),
/* Reserved */
reserved(0xFF);
......
package org.etsi.ttcn.codec.its.uppertester;
import org.etsi.ttcn.codec.MainCodec;
public class UtSremTrigger extends UtRecord {
public UtSremTrigger(MainCodec mainCodec) {
super(mainCodec);
setLengths();
}
private void setLengths() {
mainCodec.setHint("BasicVehicleRole", "8");
mainCodec.setHint("RequestImportanceLevel", "8");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment