Commit d23f627a authored by garciay's avatar garciay
Browse files

Add rotation external function

parent 9a525caf
Loading
Loading
Loading
Loading
+12 −0
Changes for javasrc/extfunc/org/etsi/its/extfunc/IItsExternalFunctionsProvider.java: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -72,6 +72,18 @@ public interface IItsExternalFunctionsProvider {
     */
    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
+44 −0
Changes for javasrc/extfunc/org/etsi/its/extfunc/ItsExternalFunctionsProvider.java: 44 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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) {

+51 −0
Changes for javasrc/tool/org/etsi/its/tool/elvior/PluginAdapter.java: 51 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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");
        
+20 −0
Changes for javasrc/tool/org/etsi/its/tool/testingtech/ExternalFunctionsPluginProvider.java: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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);