Rev

Rev 2230 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | Bug Tracker

Rev 2230 Rev 2398
Line 2... Line 2...
2
 * @authorSTF 424_ITS_Test_Platform
2
 * @authorSTF 424_ITS_Test_Platform
3
 * @version    $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/extfunc/org/etsi/its/extfunc/ItsExternalFunctionsProvider.java $
3
 * @version    $URL: file:///D:/RepositoriesNew/ITS/trunk/javasrc/extfunc/org/etsi/its/extfunc/ItsExternalFunctionsProvider.java $
4
 *             $Id: ItsExternalFunctionsProvider.java 2230 2015-06-03 09:11:02Z mullers $
4
 *             $Id: ItsExternalFunctionsProvider.java 2398 2016-07-01 09:24:55Z filatov $
5
 */
5
 */
6
package org.etsi.its.extfunc;
6
package org.etsi.its.extfunc;
7
7
8
import java.io.ByteArrayOutputStream;
8
import java.io.ByteArrayOutputStream;
9
import java.io.IOException;
9
import java.io.IOException;
Line 14... Line 14...
14
import java.text.ParseException;
14
import java.text.ParseException;
15
import java.text.SimpleDateFormat;
15
import java.text.SimpleDateFormat;
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.logging.Logger;
17
import java.util.logging.Logger;
18
18
-
 
19
import org.etsi.adapter.GnssSupportFactory;
-
 
20
import org.etsi.adapter.IGnssSupport;
-
 
21
import org.etsi.adapter.TERFactory;
19
import org.etsi.certificates.CertificatesIOFactory;
22
import org.etsi.certificates.CertificatesIOFactory;
20
import org.etsi.certificates.io.ICertificatesIO;
23
import org.etsi.certificates.io.ICertificatesIO;
21
import org.etsi.codec.ITciCDWrapper;
24
import org.etsi.codec.ITciCDWrapper;
22
import org.etsi.codec.TciCDWrapperFactory;
25
import org.etsi.codec.TciCDWrapperFactory;
23
import org.etsi.common.ByteHelper;
26
import org.etsi.common.ByteHelper;
Line 64... Line 67...
64
     */
67
     */
65
    private static final double earthRadius = 6378137;
68
    private static final double earthRadius = 6378137;
66
    private static final double rbis = earthRadius * Math.PI / 180;
69
    private static final double rbis = earthRadius * Math.PI / 180;
67
70
68
    private static final long ITS_REF_TIME = 1072915200000L;
71
    private static final long ITS_REF_TIME = 1072915200000L;
-
 
72
-
 
73
    private static final String GNSS_SCENARIO_SUPPORT = "GnssScenarioSupport";
-
 
74
    private IGnssSupport GNSS;
-
 
75
    private boolean gnssScenarioSupport;
69
76
   
70
    /**
77
    /**
71
     * Reference to the ePassport files manager
78
     * Reference to the ePassport files manager
72
     */
79
     */
73
    private ICertificatesIO _certCache = CertificatesIOFactory.getInstance();
80
    private ICertificatesIO _certCache = CertificatesIOFactory.getInstance();
Line 78... Line 85...
78
    public ItsExternalFunctionsProvider() {
85
    public ItsExternalFunctionsProvider() {
79
        _logger.entering("ItsExternalFunctionsProvider", "Constructor",
86
        _logger.entering("ItsExternalFunctionsProvider", "Constructor",
80
                String.format("version:%s", Version));
87
                String.format("version:%s", Version));
81
88
82
        _tcicdWrapper = TciCDWrapperFactory.getTciCDInstance();
89
        _tcicdWrapper = TciCDWrapperFactory.getTciCDInstance();
-
 
90
       
-
 
91
        try {
-
 
92
            gnssScenarioSupport = ((BooleanValue) TERFactory.getInstance().getTaParameter(GNSS_SCENARIO_SUPPORT)).getBoolean();
-
 
93
        }
-
 
94
        catch (Throwable th) {
-
 
95
            gnssScenarioSupport = false;
-
 
96
        }
-
 
97
        if (gnssScenarioSupport) {
-
 
98
            GNSS = GnssSupportFactory.getInstance();
-
 
99
        }
83
    }
100
    }
84
101
85
    /**
102
    /**
86
     * This external function gets the current time
103
     * This external function gets the current time
87
     *
104
     *
Line 90... Line 107...
90
     *         TTCN-3 signature: external function fx_getCurrentTime() return
107
     *         TTCN-3 signature: external function fx_getCurrentTime() return
91
     *         TimestampIts;
108
     *         TimestampIts;
92
     */
109
     */
93
    @Override
110
    @Override
94
    public synchronized IntegerValue fx_getCurrentTime() {
111
    public synchronized IntegerValue fx_getCurrentTime() {
-
 
112
        IntegerValue now = null;
95
        _logger.entering("ItsExternalFunctionsProvider", "fx_getCurrentTime");
113
        _logger.entering("ItsExternalFunctionsProvider", "fx_getCurrentTime");
96
       
114
       
-
 
115
        if (gnssScenarioSupport) {
-
 
116
            now = _tcicdWrapper.setInteger(GNSS.getGpsTime());
-
 
117
        }
-
 
118
        else {
97
        String datestr="01/01/2004 00:00:00 +0000";
119
        String datestr="01/01/2004 00:00:00 +0000";
98
        DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss Z");
120
        DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss Z");
99
        IntegerValue now = null;
-
 
100
        try {
121
        try {
101
//            System.out.println("ItsExternalFunctionsProvider.fx_getCurrentTime: " + ((java.util.Date)formatter.parse(datestr)).getTime());
122
//            System.out.println("ItsExternalFunctionsProvider.fx_getCurrentTime: " + ((java.util.Date)formatter.parse(datestr)).getTime());
102
            now = _tcicdWrapper.setInteger(
123
            now = _tcicdWrapper.setInteger(
103
                new BigInteger(
124
                new BigInteger(
104
                    1,
125
                    1,
Line 108... Line 129...
108
        } catch (ParseException e) {
129
        } catch (ParseException e) {
109
            now = _tcicdWrapper.setInteger(0);
130
            now = _tcicdWrapper.setInteger(0);
110
        }
131
        }
111
       
132
       
112
        _logger.exiting("ItsExternalFunctionsProvider", "fx_getCurrentTime", String.format("%10d", _tcicdWrapper.getBigInteger(now)));
133
        _logger.exiting("ItsExternalFunctionsProvider", "fx_getCurrentTime", String.format("%10d", _tcicdWrapper.getBigInteger(now)));
-
 
134
        }
113
        return now;
135
        return now;
114
    } // End of method fx_getCurrentTime
136
    } // End of method fx_getCurrentTime
115
137
116
    /**
138
    /**
117
     * This external function gets the current time
139
     * This external function gets the current time
Line 182... Line 204...
182
     *            p_orientation, out UInt32 p_latitude, out UInt32 p_longitude);
204
     *            p_orientation, out UInt32 p_latitude, out UInt32 p_longitude);
183
     */
205
     */
184
    @Override
206
    @Override
185
    public synchronized void fx_computePositionUsingDistance(
207
    public synchronized void fx_computePositionUsingDistance(
186
            final IntegerValue p_refLatitude,
208
            final IntegerValue p_refLatitude,
187
            final IntegerValue p_refLongitude, final IntegerValue p_distance,
209
            final IntegerValue p_refLongitude, final FloatValue p_distance,
188
            final IntegerValue p_orientation, IntegerValue p_latitude,
210
            final IntegerValue p_orientation, IntegerValue p_latitude,
189
            IntegerValue p_longitude) {
211
            IntegerValue p_longitude) {
190
//        _logger.entering(
212
//        _logger.entering(
191
//                "ItsExternalFunctionsProvider",
213
//                "ItsExternalFunctionsProvider",
192
//                "fx_computePositionUsingDistance",
214
//                "fx_computePositionUsingDistance",
193
//                String.format("%d, %d", p_distance.getInteger(),
215
//                String.format("%d, %d", p_distance.getInteger(),
194
//                        p_orientation.getInteger()));
216
//                        p_orientation.getInteger()));
195
217
-
 
218
        FloatValue v_distance = _tcicdWrapper.getFloat();
-
 
219
        v_distance.setFloat(p_distance.getFloat());
196
        double angularD = new Double(_tcicdWrapper.getInteger(p_distance)) / earthRadius;
220
        double angularD = new Double(v_distance.getFloat()) / earthRadius;
197
        double radHeading = new Double(_tcicdWrapper.getInteger(p_orientation)) * Math.PI / 180;
221
        double radHeading = new Double(_tcicdWrapper.getInteger(p_orientation)) * Math.PI / 180;
198
222
199
        // Convert to rad
223
        // Convert to rad
200
        double lat1 = (new Double(_tcicdWrapper.getInteger(p_refLatitude)) / 10000000) * Math.PI / 180;
224
        double lat1 = (new Double(_tcicdWrapper.getInteger(p_refLatitude)) / 10000000) * Math.PI / 180;
201
        double long1 = (new Double(_tcicdWrapper.getInteger(p_refLongitude)) / 10000000) * Math.PI / 180;
225
        double long1 = (new Double(_tcicdWrapper.getInteger(p_refLongitude)) / 10000000) * Math.PI / 180;