Commit 6ec3bb99 authored by garciay's avatar garciay
Browse files

Add external function to compute TimeMark

parent dcd8c821
...@@ -28,6 +28,15 @@ public interface IItsExternalFunctionsProvider { ...@@ -28,6 +28,15 @@ public interface IItsExternalFunctionsProvider {
*/ */
public IntegerValue fx_getCurrentTime(); public IntegerValue fx_getCurrentTime();
/**
* This external function gets the current time
* @return The current time in tenths of a second in the current or next hour in units of 1/10th second from UTC time
*
* TTCN-3 signature:
* external function fx_getCurrentTimeMark() return TimeMark;
*/
public IntegerValue fx_getCurrentTimeMark();
/** /**
* This external function gets the current time * This external function gets the current time
* @param p_latitudeA Latitude of node A * @param p_latitudeA Latitude of node A
......
...@@ -13,6 +13,8 @@ import java.net.UnknownHostException; ...@@ -13,6 +13,8 @@ import java.net.UnknownHostException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -134,6 +136,18 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid ...@@ -134,6 +136,18 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
return now; return now;
} // End of method fx_getCurrentTime } // End of method fx_getCurrentTime
@Override
public IntegerValue fx_getCurrentTimeMark() {
IntegerValue now = null;
//_logger.entering("ItsExternalFunctionsProvider", "fx_getCurrentTimeMark");
ZonedDateTime t = ZonedDateTime.now(ZoneOffset.UTC);
now = _tcicdWrapper.setInteger(new Integer((t.getMinute() * 60 + t.getSecond()) * 10));
//_logger.exiting("ItsExternalFunctionsProvider", "fx_getCurrentTimeMark", String.format("%4d", _tcicdWrapper.getBigInteger(now)));
return now;
}
/** /**
* This external function gets the current time * This external function gets the current time
* *
......
...@@ -32,6 +32,10 @@ public class LibItsContainer_asn1 extends LibIts_asn1 { ...@@ -32,6 +32,10 @@ public class LibItsContainer_asn1 extends LibIts_asn1 {
TriMessage msg = TriProvider.getInstance().getTriFactory().createMessage(); TriMessage msg = TriProvider.getInstance().getTriFactory().createMessage();
msg.setEncodedMessage(ByteHelper.longToByteArray(lval, 6)); msg.setEncodedMessage(ByteHelper.longToByteArray(lval, 6));
value = super.decode(msg, decodingHypothesis); value = super.decode(msg, decodingHypothesis);
} else if (decodingHypothesis.getName().equals("TimeMark")) {
TriMessage msg1 = TriProvider.getInstance().getTriFactory().createMessage();
msg1.setEncodedMessage(message.getEncodedMessage());
value = super.decode(msg1, decodingHypothesis);
} else { } else {
value = super.decode(message, decodingHypothesis); value = super.decode(message, decodingHypothesis);
} }
......
...@@ -248,7 +248,7 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT ...@@ -248,7 +248,7 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
} }
public TriStatus triExternalFunction(TriFunctionId functionId, TriParameterList parameterList, TriParameter returnValue) { public TriStatus triExternalFunction(TriFunctionId functionId, TriParameterList parameterList, TriParameter returnValue) {
_logger.entering("PluginAdapter", "triExternalFunction", functionId.getFunctionName()); // + " - " + parameterList + " - " + returnValue.getParameterName() + " - " + returnValue.getParameterPassingMode()); //TERFactory.getInstance().logDebug(">>> PluginAdapter.triExternalFunction: " + functionId.getFunctionName()); // + " - " + parameterList + " - " + returnValue.getParameterName() + " - " + returnValue.getParameterPassingMode());
TriStatus result = m_triOK; TriStatus result = m_triOK;
if ( if (
...@@ -275,6 +275,9 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT ...@@ -275,6 +275,9 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
} else if (functionId.getFunctionName().endsWith("fx_getCurrentTime")) { } else if (functionId.getFunctionName().endsWith("fx_getCurrentTime")) {
// Gets the current time // Gets the current time
exec_getCurrentTime(returnValue); exec_getCurrentTime(returnValue);
} else if (functionId.getFunctionName().endsWith("fx_getCurrentTimeMark")) {
// Gets the current time
exec_getCurrentTimeMark(returnValue);
} else if (functionId.getFunctionName().endsWith("xf_parseIpv6Address")) { } else if (functionId.getFunctionName().endsWith("xf_parseIpv6Address")) {
exec_parseIpv6Address(parameterList, returnValue); exec_parseIpv6Address(parameterList, returnValue);
} else if (functionId.getFunctionName().endsWith("fx_hashWithSha256") && (parameterList.size() == 1)) { } else if (functionId.getFunctionName().endsWith("fx_hashWithSha256") && (parameterList.size() == 1)) {
...@@ -315,7 +318,7 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT ...@@ -315,7 +318,7 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
_logger.severe("Unprocessed external function"); _logger.severe("Unprocessed external function");
result = m_triKO; result = m_triKO;
} }
_logger.exiting("PluginAdapter", "triExternalFunction", ByteHelper.byteArrayToString(returnValue.getEncodedParameter())); //TERFactory.getInstance().logDebug("<<< PluginAdapter.triExternalFunction: " + ByteHelper.byteArrayToString(returnValue.getEncodedParameter()));
return result; return result;
} }
...@@ -645,6 +648,23 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT ...@@ -645,6 +648,23 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
_logger.exiting("PluginAdapter", "exec_getCurrentTime", ByteHelper.byteArrayToString(returnValue.getEncodedParameter())); _logger.exiting("PluginAdapter", "exec_getCurrentTime", ByteHelper.byteArrayToString(returnValue.getEncodedParameter()));
} // End of method exec_getCurrentTime } // End of method exec_getCurrentTime
private void exec_getCurrentTimeMark(TriParameter returnValue) {
//_logger.entering("PluginAdapter", "exec_getCurrentTimeMark");
// Execute the function
IntegerValue time = _extfuncsImpl.fx_getCurrentTimeMark();
//_logger.info(String.format("exec_getCurrentTimeMark returns %d", ((IntegerValueEx)time).getInt64()));
returnValue.setParameterPassingMode(TriParameterPassingMode.TRI_OUT);
returnValue.setNumberOfBits(Long.SIZE);
returnValue.setEncodedParameter(
ByteHelper.longToByteArray(
((IntegerValueEx)time).getInt64(),
4/*Integer.SIZE / Byte.SIZE*/ // Encoding on 32 bits
));
//_logger.exiting("PluginAdapter", "exec_getCurrentTimeMark: ", ByteHelper.byteArrayToString(returnValue.getEncodedParameter()));
} // End of method exec_getCurrentTimeMark
private void exec_generateKeyPair(TriParameterList parameterList, TriParameter returnValue) { private void exec_generateKeyPair(TriParameterList parameterList, TriParameter returnValue) {
_logger.entering("PluginAdapter", "exec_generateKeyPair"); _logger.entering("PluginAdapter", "exec_generateKeyPair");
......
...@@ -5,16 +5,21 @@ camPort=BTP/GN/ETH ...@@ -5,16 +5,21 @@ camPort=BTP/GN/ETH
#camPort=BTP/GN/CSG #camPort=BTP/GN/CSG
# Define the port/layer configuration for DENM # Define the port/layer configuration for DENM
denmPort=BTP/GN/ETH denmPort=BTP/GN/ETH
#denmPort=BTP/GN/CSG
# Define the port/layer configuration for MAPEM-SPATEM # Define the port/layer configuration for MAPEM-SPATEM
mapemSpatemPort=BTP/GN/ETH mapemSpatemPort=BTP/GN/ETH
#mapemSpatemPort=BTP/GN/CSG
# Define the port/layer configuration for IVIM # Define the port/layer configuration for IVIM
ivimPort=BTP/GN/ETH ivimPort=BTP/GN/ETH
#ivimPort=BTP/GN/CSG
# Define the port/layer configuration for SREM-SSEM # Define the port/layer configuration for SREM-SSEM
sremSsemPort=BTP/GN/ETH sremSsemPort=BTP/GN/ETH
#sremSsemPort=BTP/GN/CSG
# Define the port/layer configuration for BTP # Define the port/layer configuration for BTP
btpPort=GN/ETH btpPort=GN/ETH
# Define the port/layer configuration for GeoNetworking # Define the port/layer configuration for GeoNetworking
geoNetworkingPort=ETH #geoNetworkingPort=ETH
geoNetworkingPort=CSG
# Define the port/layer configuration for GeoNetworking over IPv6 # Define the port/layer configuration for GeoNetworking over IPv6
ipv6OverGeoNetworkingPort=Debug ipv6OverGeoNetworkingPort=Debug
# Define the port/layer configuration for CALM FNTP # Define the port/layer configuration for CALM FNTP
...@@ -42,7 +47,9 @@ ConfigTesterSettings=172.17.15.39:12346 ...@@ -42,7 +47,9 @@ ConfigTesterSettings=172.17.15.39:12346
LocalEthernetMAC=00E08F008855 LocalEthernetMAC=00E08F008855
# Post-mortem ATS execution mode # Post-mortem ATS execution mode
OfflineMode=false OfflineMode=false
PcapFile= PcapFile=pcap/vendor/uc1.pcappng
OffsetTime=30 # Start at +30 seconds
OffsetFrame=
# Define the Ethernet type value used by the IUT # Define the Ethernet type value used by the IUT
IutEthernetTypeValue=0x8947 IutEthernetTypeValue=0x8947
# Node Ethernet addresses # Node Ethernet addresses
......
...@@ -114,6 +114,18 @@ public class ExternalFunctionsPluginProvider implements ExternalFunctionsProvide ...@@ -114,6 +114,18 @@ public class ExternalFunctionsPluginProvider implements ExternalFunctionsProvide
return _externalFunctionsPluginProvider.fx_getCurrentTime(); return _externalFunctionsPluginProvider.fx_getCurrentTime();
} }
/**
* This external function gets the current time
* @return The current time in tenths of a second in the current or next hour in units of 1/10th second from UTC time
*
* TTCN-3 signature:
* external function fx_getCurrentTimeMark() return TimeMark;
*/
@Override
public IntegerValue fx_getCurrentTimeMark() {
return _externalFunctionsPluginProvider.fx_getCurrentTimeMark();
}
/** /**
* External function to compute timestamp based on current time * External function to compute timestamp based on current time
* @return Unix-Epoch-Time mod 2^32 * @return Unix-Epoch-Time mod 2^32
......
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