Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
module TestCodec_CAM {
// LibIts
import from ITS_Container language "ASN.1:1997" all;
import from CAM_PDU_Descriptions language "ASN.1:1997"all;
// LibItsCommon
import from LibItsCommon_Functions all;
import from LibItsCommon_ASN1_NamedNumbers all;
// LibItsCam
import from LibItsCam_TestSystem all;
import from LibItsCam_Templates all;
// TestCodec
import from TestCodec_TestAndSystem all;
group LibItsCam_testCases {
group camTemplates {
template (value) CAM m_camMsg(
StationID p_stationId,
GenerationDeltaTime p_generationTime
) := {
header := {
protocolVersion := ItsPduHeader_protocolVersion_currentVersion_,
messageID := ItsPduHeader_messageID_cam_,
stationID := p_stationId
},
cam := {
generationDeltaTime := p_generationTime,
camParameters := {
basicContainer := {
stationType := StationType_passengerCar_,
referencePosition := {
latitude := f_integer2Latitude(f_getTsLatitude()),
longitude := f_integer2Longitude(f_getTsLongitude()),
positionConfidenceEllipse := {
semiMajorConfidence := SemiAxisLength_oneCentimeter_,
semiMinorConfidence := SemiAxisLength_oneCentimeter_,
semiMajorOrientation := HeadingValue_wgs84North_
},
altitude := {
altitudeValue := AltitudeValue_unavailable_,
altitudeConfidence := unavailable
}
}
},
highFrequencyContainer := {
basicVehicleContainerHighFrequency := {
heading := {
headingValue := HeadingValue_wgs84North_, //0
headingConfidence := 10
},
speed := {
speedValue := 45,
speedConfidence := 5
},
driveDirection := forward,
vehicleLength := {
vehicleLengthValue := 50,
vehicleLengthConfidenceIndication := noTrailerPresent
},
vehicleWidth := 21,
longitudinalAcceleration := {
longitudinalAccelerationValue := LongitudinalAccelerationValue_unavailable_,
longitudinalAccelerationConfidence := AccelerationConfidence_unavailable_
},
curvature := {
curvatureValue := CurvatureValue_straight_,
curvatureConfidence := unavailable
},
curvatureCalculationMode := yawRateUsed,
yawRate := {
yawRateValue := YawRateValue_straight_,
yawRateConfidence := unavailable
},
accelerationControl := omit,
lanePosition := omit,
steeringWheelAngle := omit,
lateralAcceleration := omit,
verticalAcceleration := omit,
performanceClass := omit,
cenDsrcTollingZone := omit
}
},
lowFrequencyContainer := omit,
specialVehicleContainer := omit
}
}
};
} // End of group camTemplates
group testCamPrimitiveMessages {
testcase tc_CamReq() runs on TCType system TCType {
TestCamReq(
m_camReq(
m_camMsg(
f_getTsStationId(),
35000 // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
)
),
true,
oct2bit('01020001B20788B80059F48D95CDEFC8C5E0020020002461A83C000004805A100C4528399D4C387FFF80'O)
);
}
} // End of group testCamPrimitiveMessages
} // End of group LibItsCam_testCases
group encdec_functions {
function TestCamReq(
in template (value) CamReq p_camReq,
in boolean p_decode := true,
in template (omit) bitstring p_expEncMsg := omit
) runs on TCType {
var bitstring v_encMsg;
var template (omit) TestRecord v_tr := { bs := p_expEncMsg };
var CamReq v_decMsg;
var integer v_res := 0;
// Encode template
log("Encode template ", valueof(p_camReq));
v_encMsg := encvalue(p_camReq);
// Check result
if (not isbound(v_encMsg)) {
setverdict(fail, "Encoding failed!");
stop;
}
if (ispresent(v_tr.bs)) {
if (not match(v_encMsg, p_expEncMsg)) {
log("Expected message: ", bit2oct(valueof(p_expEncMsg)));
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
setverdict(fail, "Encoding failed, not the expected result!");
stop;
}
}
setverdict(pass, "Encoding passed.");
// Check decoding
if (p_decode == true) {
v_res := decvalue(v_encMsg, v_decMsg);
log("Decoded message: ", v_decMsg);
select (v_res) {
case (0) {
if(match(v_decMsg, p_camReq)) {
setverdict(pass);
} else {
setverdict(fail);
}
}
case (1) {
setverdict(fail, "Decoding failed.");
}
case (2) {
setverdict(fail, "Not enough bits.");
}
}
}
} // End of function TestCamReq
} // End of group encdec_functions
} // End of module TestCodec_CAM