Commit df6a7c96 authored by garciay's avatar garciay
Browse files

Merge with latest C2C

parent 5f9025a4
...@@ -93,6 +93,13 @@ public interface IGnssSupport { ...@@ -93,6 +93,13 @@ public interface IGnssSupport {
*/ */
public BigInteger getGpsTime(); public BigInteger getGpsTime();
/**
* Signals when the requested time in the running scenario is reached
* @param time The requested time in msec.
* @return TRUE on success, FALSE otherwise
*/
public boolean awaitTimeInRunningScenario(AdapterPort notifier, int time);
/** /**
* Dispose object * Dispose object
*/ */
......
...@@ -33,7 +33,8 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl ...@@ -33,7 +33,8 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
//private static final byte AcGn6Response = 1; //private static final byte AcGn6Response = 1;
public static final byte AcGnssResponse = 2; public static final byte AcGnssResponse = 2;
public static final byte AcGnssDistanceCovered = 3; public static final byte AcGnssDistanceCovered = 3;
public static final byte AcSecResponse = 4; public static final byte AcGnssTimeReached = 4;
public static final byte AcSecResponse = 5;
/* GN Commands */ /* GN Commands */
private static final byte AcStartBeaconing = 0; private static final byte AcStartBeaconing = 0;
...@@ -55,6 +56,7 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl ...@@ -55,6 +56,7 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
private static final byte AcAwaitDistanceToCover = 0x73; private static final byte AcAwaitDistanceToCover = 0x73;
private static final byte AcChangeSpead = 0x74; private static final byte AcChangeSpead = 0x74;
private static final byte AcChangeHeading = 0x75; private static final byte AcChangeHeading = 0x75;
private static final byte AcAwaitTimeInRunningScenario = 0x76;
/* Set the certificate to be used by the Test Adapter */ /* Set the certificate to be used by the Test Adapter */
private static final byte AcEnableSecurity = 0x7a; private static final byte AcEnableSecurity = 0x7a;
...@@ -171,6 +173,10 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl ...@@ -171,6 +173,10 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
case AcChangeHeading: case AcChangeHeading:
// ChangeHeading(heading); // ChangeHeading(heading);
break; break;
case AcAwaitTimeInRunningScenario:
int time = ByteHelper.byteArrayToInt(data);
AwaitTimeInRunningScenario(time);
break;
} }
} }
else { else {
...@@ -284,6 +290,18 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl ...@@ -284,6 +290,18 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
}).start(); }).start();
} }
private void AwaitTimeInRunningScenario(final int time) {
new Thread(new Runnable() {
@Override
public void run() {
boolean result = GNSS.awaitTimeInRunningScenario(AdapterControlPort.this, time);
byte[] response = {(byte)AcGnssResponse, (byte)(result?AcFalse:AcTrue)};
setChanged();
notifyObservers(new PortEvent(response, getPortName(), getComponentName()));
}
}).start();
}
private void ProcessAcEnableSecurity(final byte[] data) { private void ProcessAcEnableSecurity(final byte[] data) {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
...@@ -310,6 +328,7 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl ...@@ -310,6 +328,7 @@ public class AdapterControlPort extends AdapterPort implements IPort, IObservabl
}).start(); }).start();
} }
@Override @Override
public void dispose() { public void dispose() {
if (gnssScenarioSupport) { if (gnssScenarioSupport) {
......
...@@ -44,6 +44,9 @@ public class AcGnssPrimitive extends Union { ...@@ -44,6 +44,9 @@ public class AcGnssPrimitive extends Union {
case 0x75: case 0x75:
primitive = "changeHeading"; primitive = "changeHeading";
break; break;
case 0x76:
primitive = "timeInRunningScenario";
break;
} }
mainCodec.setHint(decodingHypothesis.getName(), primitive); mainCodec.setHint(decodingHypothesis.getName(), primitive);
...@@ -76,6 +79,10 @@ public class AcGnssPrimitive extends Union { ...@@ -76,6 +79,10 @@ public class AcGnssPrimitive extends Union {
else if(variant.equals("changeHeading")) { else if(variant.equals("changeHeading")) {
primitiveId = 0x75; primitiveId = 0x75;
} }
else if(variant.equals("timeInRunningScenario")) {
primitiveId = 0x76;
mainCodec.setHint("integerLen", "32");
}
buf.appendBytes(ByteHelper.intToByteArray(primitiveId, 1)); buf.appendBytes(ByteHelper.intToByteArray(primitiveId, 1));
} }
} }
...@@ -46,12 +46,17 @@ import javax.xml.parsers.SAXParser; ...@@ -46,12 +46,17 @@ import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.SAXParserFactory;
import org.etsi.adapter.IGnssSupport; import org.etsi.adapter.IGnssSupport;
import org.etsi.adapter.ITERequired;
import org.etsi.adapter.TERFactory; import org.etsi.adapter.TERFactory;
import org.etsi.common.ByteHelper; import org.etsi.common.ByteHelper;
import org.etsi.its.adapter.ports.AdapterControlPort; import org.etsi.its.adapter.ports.AdapterControlPort;
import org.etsi.its.adapter.ports.AdapterPort; import org.etsi.its.adapter.ports.AdapterPort;
import org.etsi.its.adapter.ports.PortEvent; import org.etsi.its.adapter.ports.PortEvent;
import org.etsi.ttcn.tci.CharstringValue; import org.etsi.ttcn.tci.CharstringValue;
import org.etsi.ttcn.tci.Value;
import org.etsi.ttcn.tri.TriAddress;
import org.etsi.ttcn.tri.TriCommunicationTE;
import org.etsi.ttcn.tri.TriMessage;
import org.etsi.ttcn.tri.TriStatus; import org.etsi.ttcn.tri.TriStatus;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
...@@ -90,6 +95,50 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -90,6 +95,50 @@ public class GnssRemoteControl implements IGnssSupport {
} }
public static void main(String[] args) { public static void main(String[] args) {
TERFactory.setImpl(new ITERequired() {
@Override
public void logError(String errorMessage) {
System.out.println(errorMessage);
}
@Override
public void logDebug(String debugMessage) {
System.out.println(debugMessage);
}
@Override
public TriStatus getTriStatus(int statusCode, String message) {
return null;
}
@Override
public TriStatus getTriStatus(int statusCode) {
return null;
}
@Override
public TriMessage getTriMessage(byte[] message) {
return null;
}
@Override
public TriAddress getTriAddress(byte[] message) {
return null;
}
@Override
public Value getTaParameter(String param) {
return null;
}
@Override
public TriCommunicationTE getCommunicationTE() {
return null;
}
});
try { try {
for (int i = 0; i < 1; i++) { for (int i = 0; i < 1; i++) {
GnssRemoteControl grc = GnssRemoteControl.getInstance(); GnssRemoteControl grc = GnssRemoteControl.getInstance();
...@@ -99,6 +148,7 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -99,6 +148,7 @@ public class GnssRemoteControl implements IGnssSupport {
// grc.getScenarioStatus(); // grc.getScenarioStatus();
// grc.getScenarioDuration(); // grc.getScenarioDuration();
grc.startScenario(); grc.startScenario();
grc.awaitTimeInRunningScenario(new AdapterControlPort("test", "TestComp"), 60000);
// grc.awaitDistanceToCover(new AdapterControlPort("test", "TestComp"), 200.0); // grc.awaitDistanceToCover(new AdapterControlPort("test", "TestComp"), 200.0);
grc.getGpsTime(); grc.getGpsTime();
// grc.getScenarioStatus(); // grc.getScenarioStatus();
...@@ -195,7 +245,7 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -195,7 +245,7 @@ public class GnssRemoteControl implements IGnssSupport {
address = ((CharstringValue)TERFactory.getInstance().getTaParameter("TestSystemIpAddress")).getString(); address = ((CharstringValue)TERFactory.getInstance().getTaParameter("TestSystemIpAddress")).getString();
} }
catch (Throwable th) { catch (Throwable th) {
address = "10.73.100.38"; address = "10.73.100.28";
} }
} }
catch (Throwable th) { catch (Throwable th) {
...@@ -241,6 +291,7 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -241,6 +291,7 @@ public class GnssRemoteControl implements IGnssSupport {
} }
public boolean stopScenario() { public boolean stopScenario() {
stopReceiver();
return 2==handleCommand("-,EN,1"); return 2==handleCommand("-,EN,1");
} }
...@@ -338,6 +389,75 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -338,6 +389,75 @@ public class GnssRemoteControl implements IGnssSupport {
return result; return result;
} }
public boolean awaitTimeInRunningScenario(final AdapterPort commPort, final int time) {
boolean result = false;
try {
final DatagramSocket udpReceiverSoc = new DatagramSocket(15660);
udpReceiverSoc.setSoTimeout(100);
synchronized (receiverRunning) {
receiverRunning = true;
}
Thread receiver =
new Thread(new Runnable() {
@Override
public void run() {
boolean result = false;
DatagramPacket packet = new DatagramPacket(new byte[1500], 1500);
while(isReceiverRunning()) {
try {
udpReceiverSoc.receive(packet);
TabularDecoder dec = new TabularDecoder(new BitArrayInputStream(packet.getData(), packet.getLength()<<3));
try {
int type = dec.decodeInteger(false, 32, Endianness.LITTLE_ENDIAN);
if (type==0) {
int version = dec.decodeInteger(false, 32, Endianness.LITTLE_ENDIAN);
int time_into_run = dec.decodeInteger(false, 32, Endianness.LITTLE_ENDIAN);
if (debug) {
TERFactory.getInstance().logDebug("Version : " + version);
TERFactory.getInstance().logDebug("Time(into run) : " + time_into_run);
}
if (time_into_run>=(time*1000)/*in ms*/) {
result = true;
stopReceiver();
}
}
} catch (TabularException e) {
e.printStackTrace();
}
} catch (SocketTimeoutException ste) {
//nothing received, ignore
} catch (IOException e) {
e.printStackTrace();
result = false;
stopReceiver();
}
}
udpReceiverSoc.close();
commPort.setChanged();
byte[] response = {(byte)AdapterControlPort.AcGnssTimeReached, (byte)(result?AdapterControlPort.AcFalse:AdapterControlPort.AcTrue)};
commPort.notifyObservers(new PortEvent(response, commPort.getPortName(), commPort.getComponentName()));
}
}, "AwaitTimeIntoRun");
receiver.start();
// try {
// receiver.join();
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
} catch (SocketException e) {
e.printStackTrace();
result = false;
}
return result;
}
public boolean changeSpeed(double speed) { public boolean changeSpeed(double speed) {
return false; return false;
} }
...@@ -529,12 +649,12 @@ public class GnssRemoteControl implements IGnssSupport { ...@@ -529,12 +649,12 @@ public class GnssRemoteControl implements IGnssSupport {
} }
else if (localName.equals("error")) { else if (localName.equals("error")) {
inError=false; inError=false;
TERFactory.getInstance().logError("error: " + sb.toString()); TERFactory.getInstance().logDebug("error: " + sb.toString());
sb.setLength(0); sb.setLength(0);
} }
else if (localName.equals("fatal")) { else if (localName.equals("fatal")) {
inFatal=false; inFatal=false;
TERFactory.getInstance().logError("fatal: " + sb.toString()); TERFactory.getInstance().logDebug("fatal: " + sb.toString());
sb.setLength(0); sb.setLength(0);
} }
super.endElement(uri, localName, qName); super.endElement(uri, localName, qName);
......
...@@ -77,6 +77,10 @@ public class PluginAdapter implements ISAPlugin, PortPluginProvider, PluginIdent ...@@ -77,6 +77,10 @@ public class PluginAdapter implements ISAPlugin, PortPluginProvider, PluginIdent
return new TriStatusImpl(); return new TriStatusImpl();
} }
public TriStatus reInit() {
return tearDown();
}
@Override @Override
public TriStatus triCall(TriComponentId componentId, TriPortId tsiPortId, public TriStatus triCall(TriComponentId componentId, TriPortId tsiPortId,
TriAddress sutAddress, TriSignatureId signatureId, TriAddress sutAddress, TriSignatureId signatureId,
...@@ -205,10 +209,4 @@ public class PluginAdapter implements ISAPlugin, PortPluginProvider, PluginIdent ...@@ -205,10 +209,4 @@ public class PluginAdapter implements ISAPlugin, PortPluginProvider, PluginIdent
return ta.triUnmapParam(compPortId, tsiPortId, paramList); return ta.triUnmapParam(compPortId, tsiPortId, paramList);
} }
@Override
public TriStatus reInit() {
// TODO Auto-generated method stub
return null;
}
} }
Index: adapter/org/etsi/its/adapter/ports/ProtocolPortFactory.java
===================================================================
--- adapter/org/etsi/its/adapter/ports/ProtocolPortFactory.java (revision 1471)
+++ adapter/org/etsi/its/adapter/ports/ProtocolPortFactory.java (working copy)
@@ -37,7 +37,6 @@
ports.put("btpPort", BtpPort.class);
ports.put("geoNetworkingPort", GnPort.class);
ports.put("ipv6OverGeoNetworkingPort", Gn6Port.class);
- ports.put("v2gPort", V2GPort.class);
}
/**
Index: adapter/org/etsi/its/adapter/ports/V2GPort.java
===================================================================
--- adapter/org/etsi/its/adapter/ports/V2GPort.java (revision 1471)
+++ adapter/org/etsi/its/adapter/ports/V2GPort.java (working copy)
@@ -75,7 +75,7 @@
role = ((CharstringValue)TERFactory.getInstance().getTaParameter("V2gTsRole")).getString();
v2gHost = ((CharstringValue)TERFactory.getInstance().getTaParameter("V2gSeccAddress")).getString();
//v2gPort = Integer.decode(((CharstringValue)TERFactory.getInstance().getTaParameter("V2gSeccPort")).getString());
- v2gPort = ((IntegerValue)TERFactory.getInstance().getTaParameter("V2gSeccPort")).getInt();
+ v2gPort = ((IntegerValue)TERFactory.getInstance().getTaParameter("V2gSeccPort")).getInteger();
try {
sdpPeerAddress = InetAddress.getByName("ff02::1");
} catch (UnknownHostException e1) {
Index: adapter/org/etsi/its/adapter/TestAdapter.java
===================================================================
--- adapter/org/etsi/its/adapter/TestAdapter.java (revision 1471)
+++ adapter/org/etsi/its/adapter/TestAdapter.java (working copy)
@@ -19,7 +19,6 @@
import org.etsi.its.adapter.ports.ProtocolPortFactory;
import org.etsi.its.adapter.ports.UpperTesterPort;
import org.etsi.ttcn.tci.CharstringValue;
-import org.etsi.ttcn.tri.TriActionTemplate;
import org.etsi.ttcn.tri.TriAddress;
import org.etsi.ttcn.tri.TriAddressList;
import org.etsi.ttcn.tri.TriCommunicationSA;
@@ -70,10 +69,14 @@
return required.getTriStatus(TriStatus.TRI_OK);
}
+ @Override
+ public TriStatus triExecuteTestCase(TriTestCaseId tcId, TriPortIdList portList) {
+ return triExecuteTestcase(tcId, portList);
+ }
+
/* (non-Javadoc)
* @see org.etsi.ttcn.tri.TriCommunicationSA#triExecuteTestcase(org.etsi.ttcn.tri.TriTestCaseId, org.etsi.ttcn.tri.TriPortIdList)
*/
- @Override
public TriStatus triExecuteTestcase(final TriTestCaseId tcId, final TriPortIdList portList) {
return required.getTriStatus(TriStatus.TRI_OK);
}
@@ -296,14 +299,14 @@
return required.getTriStatus(TriStatus.TRI_ERROR, "triSutActionInformal not implemented");
}
- /**
- * triSutActionTemplate not implemented
- * @see org.etsi.ttcn.tri.TriCommunicationSA#triSutActionTemplate(org.etsi.ttcn.tri.TriActionTemplate)
- */
- @Override
- public TriStatus triSutActionTemplate(TriActionTemplate templateValue) {
- return required.getTriStatus(TriStatus.TRI_ERROR, "triSutActionTemplate not implemented");
- }
+// /**
+// * triSutActionTemplate not implemented
+// * @see org.etsi.ttcn.tri.TriCommunicationSA#triSutActionTemplate(org.etsi.ttcn.tri.TriActionTemplate)
+// */
+// @Override
+// public TriStatus triSutActionTemplate(TriActionTemplate templateValue) {
+// return required.getTriStatus(TriStatus.TRI_ERROR, "triSutActionTemplate not implemented");
+// }
/**
* triMapParam not implemented
@@ -322,4 +325,21 @@
public TriStatus triUnmapParam(TriPortId compPortId, TriPortId tsiPortId, TriParameterList paramList) {
return required.getTriStatus(TriStatus.TRI_ERROR, "triUnmapParam not implemented");
}
+
+ @Override
+ public TriStatus triGetStreamValue(TriComponentId arg0, TriPortId arg1,
+ TriAddress arg2, TriMessage arg3) {
+ return required.getTriStatus(TriStatus.TRI_ERROR, "triUnmapParam not implemented");
+ }
+
+ @Override
+ public TriStatus triSetStreamValue(TriComponentId arg0, TriPortId arg1,
+ TriAddress arg2, TriMessage arg3) {
+ return required.getTriStatus(TriStatus.TRI_ERROR, "triUnmapParam not implemented");
+ }
+
+ @Override
+ public TriStatus triStaticMap(TriPortId arg0, TriPortId arg1) {
+ return required.getTriStatus(TriStatus.TRI_ERROR, "triUnmapParam not implemented");
+ }
}
Index: codec/org/etsi/codec/ITciCDWrapper.java
===================================================================
--- codec/org/etsi/codec/ITciCDWrapper.java (revision 1471)
+++ codec/org/etsi/codec/ITciCDWrapper.java (working copy)
@@ -27,9 +27,33 @@
* See ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
* @return An instance of Type representing a TTCN-3 integer type
*/
- public IntegerValue getInteger();
+ public IntegerValue setInteger(final Integer value);
/**
+ * Constructs and returns a basic TTCN-3 big integer type
+ *
+ * @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
+ * @return An instance of Type representing a TTCN-3 integer type
+ */
+ public IntegerValue setInteger(final BigInteger value);
+
+ /**
+ * Constructs and returns a basic integer type
+ *
+ * See ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
+ * @return An instance of Type representing a TTCN-3 integer type
+ */
+ public int getInteger(final IntegerValue iv);
+
+ /**
+ * Constructs and returns a basic big integer type
+ *
+ * @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
+ * @return An instance of Type representing a TTCN-3 integer type
+ */
+ public long/*TODO BigInteger*/ getBigInteger(final IntegerValue iv);
+
+ /**
* Constructs and returns a basic TTCN-3 octet string type
*
* See ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getOctetstring
@@ -44,14 +68,6 @@
* @return An instance of Type representing a TTCN-3 float type
*/
public FloatValue getFloat();
-
- /**
- * Constructs and returns a basic TTCN-3 big integer type
- *
- * @see ETSI ES 201 873-6 V4.2.1 - 7.3.2.1.2 getInteger
- * @return An instance of Type representing a TTCN-3 integer type
- */
- IntegerValue getBigInteger(BigInteger bigInt);
/**
* Constructs and returns a basic TTCN-3 float type
Index: codec/org/etsi/ttcn/codec/CodecFactory.java
===================================================================
--- codec/org/etsi/ttcn/codec/CodecFactory.java (revision 1471)
+++ codec/org/etsi/ttcn/codec/CodecFactory.java (working copy)
@@ -61,7 +61,7 @@
org.etsi.ttcn.codec.its.uppertester.Plugin.init();
org.etsi.ttcn.codec.its.geonetworking.Plugin.init();
org.etsi.ttcn.codec.its.btp.Plugin.init();
-
+ org.etsi.ttcn.codec.its.security.Plugin.init();
}
}
Index: codec/org/etsi/ttcn/codec/generic/Integer.java
===================================================================
--- codec/org/etsi/ttcn/codec/generic/Integer.java (revision 1471)
+++ codec/org/etsi/ttcn/codec/generic/Integer.java (working copy)
@@ -46,17 +46,17 @@
try {
Matcher matcher = UNSIGNED_VARIANT.matcher(decodingHypothesis.getTypeEncodingVariant());
if(matcher.find()) {
- // Unsigned integer
- if(lengthInBits >= 32) {
- iv.setBigInt(new BigInteger(1, value)); // /!\ ttwb specific
+ // Unsigned integer
+ if(lengthInBits >= java.lang.Integer.SIZE) {
+ iv = mainCodec.getTciCDRequired().setInteger(new BigInteger(1, value));
}
else {
- iv.setInt(ByteHelper.byteArrayToInt(value));
+ iv = mainCodec.getTciCDRequired().setInteger(ByteHelper.byteArrayToInt(value));
}
}
else {
// Signed integer
- iv.setInt(ByteHelper.byteArrayToSignedInt(value, lengthInBits));
+ iv.setInteger(ByteHelper.byteArrayToSignedInt(value, lengthInBits));
}
}
catch(Exception e) {
@@ -87,10 +87,10 @@
// System.out.println(String.format("Integer.encode: length: %d", lengthInBytes));
if (lengthInBits > java.lang.Integer.SIZE) {
- encoded = ByteHelper.longToByteArray(iv.getBigInt().longValue(), lengthInBytes);
+ encoded = ByteHelper.longToByteArray(mainCodec.getTciCDRequired().getBigInteger(iv), lengthInBytes);
res.setBits(encoded, lengthInBits);
} else {
- encoded = ByteHelper.intToByteArray(iv.getInt(), lengthInBytes);
+ encoded = ByteHelper.intToByteArray(mainCodec.getTciCDRequired().getInteger(iv), lengthInBytes);
res.setBits(encoded, lengthInBits);
}
res.setBits(encoded, lengthInBits);
Index: codec/org/etsi/ttcn/codec/ipv6/Ipv6ExtHdr.java
===================================================================
--- codec/org/etsi/ttcn/codec/ipv6/Ipv6ExtHdr.java (revision 1471)
+++ codec/org/etsi/ttcn/codec/ipv6/Ipv6ExtHdr.java (working copy)
@@ -27,7 +27,7 @@
protected void postDecodeField(String fieldName, CodecBuffer buf, Type decodingHypothesis, RecordValue rv) {
if(fieldName.equals("hdrLen")) {
- int len = ((IntegerValue)(rv.getField(fieldName))).getInt();
+ int len = ((IntegerValue)(rv.getField(fieldName))).getInteger();
mainCodec.setHint("Ipv6ExtHdrLen", Integer.toString(len));
}
}
Index: codec/org/etsi/ttcn/codec/its/geonetworking/CommonHeader.java
===================================================================
--- codec/org/etsi/ttcn/codec/its/geonetworking/CommonHeader.java (revision 1471)
+++ codec/org/etsi/ttcn/codec/its/geonetworking/CommonHeader.java (working copy)
@@ -39,7 +39,7 @@
}
else if(fieldName.equals("plLength")) {
- int pl = ((IntegerValue)(rv.getField(fieldName))).getInt();