Commit d23f627a authored by garciay's avatar garciay
Browse files

Add rotation external function

parent 9a525caf
/**
* @author STF 424_ITS_Test_Platform
* @version $id$
* @author STF 424_ITS_Test_Platform
* @version $id$
*/
package org.etsi.its.extfunc;
......@@ -19,67 +19,79 @@ import org.etsi.ttcn.tci.RecordValue;
*/
public interface IItsExternalFunctionsProvider {
/**
* This external function gets the current time
* @return The current time in Epoch format
*
* TTCN-3 signature:
* external function fx_getCurrentTime() return TimestampIts;
*/
public IntegerValue fx_getCurrentTime();
/**
* This external function gets the current time
* @return The current time in Epoch format
*
* TTCN-3 signature:
* external function fx_getCurrentTime() return TimestampIts;
*/
public IntegerValue fx_getCurrentTime();
/**
* This external function gets the tenths of a second in the current or next hour in units of 1/10th second from UTC 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 tenths of a second in the current or next hour in units of 1/10th second from UTC 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 minutes of current UTC year
* @return The minutes of current UTC year
*
* TTCN-3 signature:
* external function fx_getMinuteOfTheYear() return MinuteOfTheYear;
*/
public IntegerValue fx_getMinuteOfTheYear();
/**
* This external function gets the minutes of current UTC year
* @return The minutes of current UTC year
*
* TTCN-3 signature:
* external function fx_getMinuteOfTheYear() return MinuteOfTheYear;
*/
public IntegerValue fx_getMinuteOfTheYear();
/**
* This external function gets the current time
* @param p_latitudeA Latitude of node A
* @param p_longitudeA Longitude of node A
* @param p_latitudeB Latitude of node B
* @param p_longitudeB Longitude of node B
* @return The current time in Epoch format
*
* TTCN-3 signature:
* external function fx_computeDistance(in UInt32 p_latitudeA, in UInt32 p_longitudeA, in UInt32 p_latitudeB, in UInt32 p_longitudeB) return float;
*/
public FloatValue fx_computeDistance(final IntegerValue p_latitudeA, final IntegerValue p_longitudeA, final IntegerValue p_latitudeB, final IntegerValue p_longitudeB);
/**
* This external function gets the current time
* @param p_latitudeA Latitude of node A
* @param p_longitudeA Longitude of node A
* @param p_latitudeB Latitude of node B
* @param p_longitudeB Longitude of node B
* @return The current time in Epoch format
*
* TTCN-3 signature:
* external function fx_computeDistance(in UInt32 p_latitudeA, in UInt32 p_longitudeA, in UInt32 p_latitudeB, in UInt32 p_longitudeB) return float;
*/
public FloatValue fx_computeDistance(final IntegerValue p_latitudeA, final IntegerValue p_longitudeA, final IntegerValue p_latitudeB, final IntegerValue p_longitudeB);
/**
* External function to compute a position using a reference position, a distance and an orientation
* @param p_iutLongPosVector Reference position
* @param p_distance Distance to the reference position (in meter)
* @param p_orientation Direction of the computed position (0 to 359; 0 means North)
* @param p_latitude Computed position's latitude
* @param p_longitude Computed position's longitude
*
* TTCN-3 signature:
* external function fx_computePositionUsingDistance(in UInt32 p_refLatitude, in Uint32 p_refLongitude, in integer p_distance, in integer p_orientation, out UInt32 p_latitude, out UInt32 p_longitude);
*/
public void fx_computePositionUsingDistance(final IntegerValue p_refLatitude, final IntegerValue p_refLongitude, final FloatValue p_distance, final IntegerValue p_orientation, IntegerValue p_latitude, IntegerValue p_longitude);
/**
/**
* External function to compute a position using a reference position, a distance and an orientation
* @param p_iutLongPosVector Reference position
* @param p_distance Distance to the reference position (in meter)
* @param p_orientation Direction of the computed position (0 to 359; 0 means North)
* @param p_latitude Computed position's latitude
* @param p_longitude Computed position's longitude
*
* TTCN-3 signature:
* external function fx_computePositionUsingDistance(in UInt32 p_refLatitude, in Uint32 p_refLongitude, in integer p_distance, in integer p_orientation, out UInt32 p_latitude, out UInt32 p_longitude);
*/
public void fx_computePositionUsingDistance(final IntegerValue p_refLatitude, final IntegerValue p_refLongitude, final FloatValue p_distance, final IntegerValue p_orientation, IntegerValue p_latitude, IntegerValue p_longitude);
/**
* External function to compute a position using a reference position, a distance and an orientation
* @param p_iutLongPosVector Reference position
* @param p_rotation Rotation value (in degrees)
* @param p_latitude Computed position's latitude
* @param p_longitude Computed position's longitude
*
* TTCN-3 signature:
* external function fx_computePositionFromRotation(in UInt32 p_refLatitude, in Uint32 p_refLongitude, in Uint32 p_cenLatitude, in Uint32 p_cenLongitude, in float p_rotation, out UInt32 p_latitude, out UInt32 p_longitude);
*/
public void fx_computePositionFromRotation(final IntegerValue p_refLatitude, final IntegerValue p_refLongitude, final IntegerValue p_cenLatitude, final IntegerValue p_cenLongitude, final FloatValue p_rotation, IntegerValue p_latitude, IntegerValue p_longitude);
/**
* External function to compute radius of a given circular area
* @param p_squareMeters Square meters of an circular area
* @return Computed radius in meters
*/
public FloatValue fx_computeRadiusFromCircularArea(final FloatValue p_squareMeters);
/**
/**
* External function to compute timestamp based on current time
* @return Unix-Epoch-Time mod 2^32
*
......
......@@ -272,6 +272,50 @@ public class ItsExternalFunctionsProvider implements IItsExternalFunctionsProvid
} // End of method fx_computePositionUsingDistance
/**
* External function to compute a position using a rotation
*
* @param p_iutLongPosVector
* Reference position
* @param p_rotation
* Rotation value (in degrees)
* @param p_latitude
* Computed position's latitude
* @param p_longitude
* Computed position's longitude
*
* TTCN-3 signature: external function
* fx_computePositionFromRotation(in LongPosVector
* p_iutLongPosVector, in float
* p_rotation, out UInt32 p_latitude, out UInt32 p_longitude);
*/
@Override
public synchronized void fx_computePositionFromRotation(
final IntegerValue p_refLatitude,
final IntegerValue p_refLongitude,
final IntegerValue p_cenLatitude,
final IntegerValue p_cenLongitude,
final FloatValue p_rotation,
IntegerValue p_latitude,
IntegerValue p_longitude) {
// //_logger.entering(
// "ItsExternalFunctionsProvider",
// "fx_computePositionFromRotation",
// String.format("%d", p_rotation.getFloat()));
FloatValue v_rotation = _tcicdWrapper.getFloat();
v_rotation.setFloat(p_rotation.getFloat());
double lat = _tcicdWrapper.getInteger(p_cenLatitude) + Math.cos(v_rotation.getFloat()) * (_tcicdWrapper.getInteger(p_refLatitude) - _tcicdWrapper.getInteger(p_cenLatitude)) - Math.sin(v_rotation.getFloat()) * (_tcicdWrapper.getInteger(p_refLongitude) - _tcicdWrapper.getInteger(p_cenLongitude));
double long_ = _tcicdWrapper.getInteger(p_cenLongitude) + Math.sin(v_rotation.getFloat()) * (_tcicdWrapper.getInteger(p_refLatitude) - _tcicdWrapper.getInteger(p_cenLatitude)) + Math.cos(v_rotation.getFloat()) * (_tcicdWrapper.getInteger(p_refLongitude) - _tcicdWrapper.getInteger(p_cenLongitude));
Long rlat = Math.round(lat);
Long rlong = Math.round(long_);
// The out parameter needs to be set on the object level
_tcicdWrapper.setInteger(p_latitude, rlat.intValue());
_tcicdWrapper.setInteger(p_longitude, rlong.intValue());
} // End of method fx_computePositionFromRotation
@Override
public FloatValue fx_computeRadiusFromCircularArea(FloatValue p_squareMeters) {
......
......@@ -269,6 +269,12 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
) {
// Compute a position using a reference position, a distance and an orientation
exec_computePositionUsingDistance(parameterList, returnValue);
} else if (
functionId.getFunctionName().endsWith("fx_computePositionFromRotation") &&
(parameterList.size() == 7)
) {
// Compute a reference position rotation
exec_computePositionFromRotation(parameterList, returnValue);
} else if (functionId.getFunctionName().endsWith("fx_computeGnTimestamp")) {
// Compute timestamp based on current time
exec_computeGnTimestamp(returnValue);
......@@ -617,6 +623,51 @@ public class PluginAdapter implements TriCommunicationSA, TriCommunicationTE, xT
_logger.exiting("PluginAdapter", "exec_computePositionUsingDistance");
} // End of method exec_computePositionUsingDistance
private void exec_computePositionFromRotation(TriParameterList parameterList, TriParameter returnValue) {
_logger.entering("PluginAdapter", "exec_computePositionUsingDistance");
_logger.info(String.format("Setting parameter %s", parameterList.get(0).getParameterName()));
byte[] value = parameterList.get(0).getEncodedParameter();
IntegerValue refLatitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
refLatitude.setInteger(ByteHelper.byteArrayToInt(value));
_logger.info(String.format("Setting parameter %s", parameterList.get(1).getParameterName()));
value = parameterList.get(1).getEncodedParameter();
IntegerValue refLongitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
refLongitude.setInteger(ByteHelper.byteArrayToInt(value));
_logger.info(String.format("Setting parameter %s", parameterList.get(2).getParameterName()));
value = parameterList.get(2).getEncodedParameter();
IntegerValue cenLatitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
cenLatitude.setInteger(ByteHelper.byteArrayToInt(value));
_logger.info(String.format("Setting parameter %s", parameterList.get(3).getParameterName()));
value = parameterList.get(3).getEncodedParameter();
IntegerValue cenLongitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
cenLongitude.setInteger(ByteHelper.byteArrayToInt(value));
_logger.info(String.format("Setting parameter %s", parameterList.get(4).getParameterName()));
value = parameterList.get(4).getEncodedParameter();
FloatValue rotation = (FloatValue)TciProvider.getInstance().getTciCDRequired().getFloat().newInstance();
rotation.setFloat(ByteHelper.byteArrayToInt(value)); // FIXME Should be byteArrayToFloat???
IntegerValue latitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
IntegerValue longitude = (IntegerValue)TciProvider.getInstance().getTciCDRequired().getInteger().newInstance();
_extfuncsImpl.fx_computePositionFromRotation(refLatitude, refLongitude, cenLatitude, cenLongitude, rotation, latitude, longitude);
TriParameter param = parameterList.get(5);
param.setParameterPassingMode(TriParameterPassingMode.TRI_OUT);
param.setNumberOfBits(Integer.SIZE);
param.setEncodedParameter(ByteHelper.intToByteArray(latitude.getInteger(), Integer.SIZE / Byte.SIZE));
param = parameterList.get(6);
param.setParameterPassingMode(TriParameterPassingMode.TRI_OUT);
param.setNumberOfBits(Integer.SIZE);
param.setEncodedParameter(ByteHelper.intToByteArray(longitude.getInteger(), Integer.SIZE / Byte.SIZE));
_logger.exiting("PluginAdapter", "exec_computePositionUsingDistance");
}
private void exec_computeGnTimestamp(TriParameter returnValue) {
_logger.entering("PluginAdapter", "exec_computeGnTimestamp");
......
......@@ -97,6 +97,26 @@ public class ExternalFunctionsPluginProvider implements ExternalFunctionsProvide
_externalFunctionsPluginProvider.fx_computePositionUsingDistance(p_refLatitude, p_refLongitude, pDistance, pOrientation, pLatitude, pLongitude);
}
/**
* External function to compute a position using a reference position, a distance and an orientation
* @param pIutLongPosVector Reference position
* @param pCenLongPosVector Central reference position
* @param p_rotation Rotation value (in degrees)
* @param pLatitude Computed position's latitude
* @param pLongitude Computed position's longitude
*
* TTCN-3 signature:
* external function fx_computePositionFromRotation(in LongPosVector p_iutLongPosVector, in float p_rotation, out UInt32 p_latitude, out UInt32 p_longitude);
*/
@Override
public void fx_computePositionFromRotation(
IntegerValue p_refLatitude, IntegerValue p_refLongitude,
IntegerValue p_cenLatitude, IntegerValue p_cenLongitude,
FloatValue pRotation,
IntegerValue pLatitude, IntegerValue pLongitude) {
_externalFunctionsPluginProvider.fx_computePositionFromRotation(p_refLatitude, p_refLongitude, pRotation, pLatitude, pLongitude);
}
@Override
public FloatValue fx_computeRadiusFromCircularArea(FloatValue p_squareMeters) {
return _externalFunctionsPluginProvider.fx_computeRadiusFromCircularArea(p_squareMeters);
......
Supports Markdown
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