test_LibItsCam_TypesAndValues.ttcn 22.9 KB
Newer Older
filatov's avatar
filatov committed
module test_LibItsCam_TypesAndValues /*language "TTCN-3:2009 Advanced Parameterization"*/ {
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 130 131 132 133 134 135 136 137 138 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 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
    
    // LibIts
    import from ITS_Container language "ASN.1:1997" all;
    import from CAM_PDU_Descriptions language "ASN.1:1997"all;
    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
    
    // LibItsCommon
    import from LibItsCommon_TypesAndValues all;
    
    // AtsCam
    import from LibItsCam_TestSystem all;
    import from LibItsCam_Templates all;
    import from LibItsCam_TypesAndValues all;
    import from LibItsCam_Functions all;
    import from LibItsCommon_Functions all;
    
    import from test_CommonCodec all;
    
    group LibItsCam_testCases {
        
        group camTemplates {
            
            template (value) CAM m_camMsg(
                StationID p_stationId,
                GenerationDeltaTime p_generationTime
            ) := {
                header := {
                    protocolVersion := 1,
                    messageID := 2,
                    stationID := p_stationId
                },
                cam := {
                    generationDeltaTime := p_generationTime,
                    camParameters := {
                        basicContainer := {
                            stationType := c_stationType_passengerCar,
                            referencePosition := {
                                latitude := f_integer2Latitude(f_getTsLatitude()),
                                longitude := f_integer2Longitude(f_getTsLongitude()),
                                positionConfidenceEllipse := {
                                    semiMajorConfidence   := c_semiAxisLengthOneCentimeter,
                                    semiMinorConfidence   := c_semiAxisLengthOneCentimeter,
                                    semiMajorOrientation  := c_headingValue_wgs84North
                                },
                                altitude := {
                                    altitudeValue := c_altitudeValue_seaLevel,
                                    altitudeConfidence := unavailable
                                }
                            }
                        },
                        highFrequencyContainer := {
                            basicVehicleContainerHighFrequency := {
                                heading := {
                                    headingValue := c_headingValue_wgs84North, //0
                                    headingConfidence := 10
                                },
                                speed := {
                                    speedValue := 45,
                                    speedConfidence := 5
                                },
                                driveDirection := forward,
                                vehicleLength := {
                                    vehicleLengthValue := 50,
                                    vehicleLengthConfidenceIndication := noTrailerPresent
                                },
                                vehicleWidth := 21,
                                longitudinalAcceleration := {
                                    longitudinalAccelerationValue := c_longitudinalAccelerationValue_unavailable,
                                    longitudinalAccelerationConfidence := c_accelerationConfidence_unavailable
                                },
                                curvature := {
                                    curvatureValue := c_curvatureValue_straight,
                                    curvatureConfidence := unavailable
                                },
                                curvatureCalculationMode := yawRateUsed,
                                yawRate := {
                                    yawRateValue := c_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 testUtEvent {
            testcase tc_UtCamInitialize() runs on TCType system TCType {
                test_PDU<UtInitialize>(m_camInitialize, false);
            }
            
            testcase tc_changeHeading() runs on TCType system TCType {
                test_PDU<UtCamTrigger>(m_changeHeading(5), false);
            }
            
            testcase tc_changePosition() runs on TCType system TCType {
                test_PDU<UtCamTrigger>(
                    m_changePosition(
                        UtChangePosition: {
                            latitude := 49845,
                            longitude := 631,
                            elevation := 512
                        }
                ), 
                false);
            }
            
            testcase tc_changeSpeed() runs on TCType system TCType {
                test_PDU<UtCamTrigger>(m_changeSpeed(2), false);
            }
            
    //        testcase tc_setCrashSignal() runs on TCType system TCType {
    //            test_PDU<UtCamTrigger>(m_setCrashSignal(c_activated), false);
    //        }
    //        
    //        testcase tc_setDangerousGoodsStatus() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setDangerousGoodsStatus(8191), false);
    //        }
    //        
    //        testcase tc_setLengthWidthPrecision() runs on TCType system TCType {
    //            test_PDU<UtCamTrigger>(m_setLengthWidthPrecision(c_precisely), false);
    //        }
    //        
    //        testcase tc_setDistanceToStopLine() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setDistanceToStopLine(65535), false);
    //        }
    //        
    //        testcase tc_setTurnAdvice() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setTurnAdvice({ f_bitPositionRandom(7), 65535 }), false);
    //        }
    //        
    //        testcase tc_changeCurvature() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_changeCurvature(-1023), false);
    //        }
    //        
    //        testcase tc_setOccupancy() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setOccupancy(255), false);
    //        }
    //        
    //        testcase tc_setDoorStatus() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setDoorStatus(c_driverDoor), false);
    //        }
    //        
    //        testcase tc_setLightBarStatus() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setLightBarStatus(unavailable), false);
    //        }
    //        
    //        testcase tc_setSireneStatus() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setSireneStatus(engaged), false);
    //        }
    //        
    //        testcase tc_setTrafficLightPriority() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setTrafficLightPriority(7), false);
    //        }
    //        
    //        testcase tc_setScheduleDeviation() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setScheduleDeviation(-900), false);
    //        }
    //        
    //        testcase tc_setPtLineDescription() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setPtLineDescription(PTLineDescription:{"CourseOfJourney", "LineRef", "RouteRef"}), false);
    //        }
    //        
    //        testcase tc_setExteriorLightsStatus() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_setExteriorLightsStatus(c_lowBeamHeadlightsOn), false);
    //        }
    //        
    //        testcase tc_checkLdmBasic() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_checkLdm(m_camMsg_irs (
    //                28147497,
    //                42949,
    //                { true, true, true },
    //                {
    //                    longitude := {hemisphere := east, degree := 0},
    //                    latitude := {hemisphere := north, degree := 0},
    //                    elevation := 0,
    //                    heading := omit,
    //                    streetName := omit,
    //                    positionConfidence := omit,
    //                    elevationConfidence := omit,
    //                    roadSegmentID :=0
    //                }
    //            )), false);
    //        }
    //        testcase tc_checkLdmFull_BasicVehicle() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_checkLdm(m_camMsg_valid_With_Parameters(
    //                28147495,
    //                42946,
    //                { true, true, true },
    //                {
    //                    longitude := {hemisphere := east, degree := 0},
    //                    latitude := {hemisphere := north, degree := 0},
    //                    elevation := 1530,
    //                    heading := 95,
    //                    streetName := "Street name",
    //                    positionConfidence := 15,
    //                    elevationConfidence := 14,
    //                    roadSegmentID :=0
    //                }, // End of ReferencePosition
    //                {
    //                    vehicleType := 3,
    //                    stationLength := 1456,
    //                    stationLengthConfidence := 9,
    //                    stationWidth := 125,
    //                    stationWidthConfidence := 11,
    //                    vehicleSpeed := 55,
    //                    vehicleSpeedConfidence := 13,
    //                    longAcceleration := -500,
    //                    longAccelerationConfidence := 12,
    //                    accelerationControl := '001000'B,
    //                    yawRate := {
    //                        yawDirection := right,
    //                        yawRateValue := 16584
    //                    },
    //                    yawRateConfidence := 11,
    //                    exteriorLights := '00100000'B,
    //                    turnAdvice := {
    //                        direction := '00000100'B,
    //                        distance := 4556
    //                    },
    //                    distanceToStopLine := 150,
    //                    occupancy := 57,
    //                    doorOpen := '0001'B,
    //                    posConfidenceEllipse := {
    //                        semiMajorConfidence := 7,
    //                        semiMinorConfidence := 9,
    //                        semiMajorOrientation := 11
    //                    },
    //                    curvature := -156,
    //                    curvatureChange := 53,
    //                    curvatureConfidence := 10,
    //                    crashStatus := false,
    //                    headingConfidence := 9,
    //                    dangerousGoods := 799
    //                }, // End of VehicleCommonParameters
    //                m_profileParameters_BasicVehicle
    //            )), false);
    //        }
    //
    //        testcase tc_checkLdmFull_PublicVehicle() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_checkLdm(m_camMsg_valid_With_Parameters(
    //                1307531915453, 
    //                111111, 
    //                { true, true, true }, 
    //                { 
    //                    longitude := { 
    //                        hemisphere := east, 
    //                        degree := 0 
    //                    }, 
    //                    latitude := { 
    //                        hemisphere := north, 
    //                        degree := 0 
    //                    }, 
    //                    elevation := 0, 
    //                    heading := 0, 
    //                    streetName := omit, 
    //                    positionConfidence := omit, 
    //                    elevationConfidence := omit, 
    //                    roadSegmentID := omit 
    //                }, // End of ReferencePosition
    //                { 
    //                    vehicleType := 0, 
    //                    stationLength := 0, 
    //                    stationLengthConfidence := 0, 
    //                    stationWidth := 0, 
    //                    stationWidthConfidence := 0, 
    //                    vehicleSpeed := 0, 
    //                    vehicleSpeedConfidence := 0, 
    //                    longAcceleration := 0, 
    //                    longAccelerationConfidence := 0, 
    //                    accelerationControl := '000000'B, 
    //                    yawRate := { 
    //                        yawDirection := right, 
    //                        yawRateValue := 0 
    //                    }, 
    //                    yawRateConfidence := 0, 
    //                    exteriorLights := '00000000'B, 
    //                    turnAdvice := omit, 
    //                    distanceToStopLine := omit, 
    //                    occupancy := omit, 
    //                    doorOpen := omit, 
    //                    posConfidenceEllipse := { 
    //                        semiMajorConfidence := 0, 
    //                        semiMinorConfidence := 0, 
    //                        semiMajorOrientation := 0 
    //                    }, 
    //                    curvature := 0, 
    //                    curvatureChange := omit, 
    //                    curvatureConfidence := 0, 
    //                    crashStatus := omit, 
    //                    headingConfidence := 0, 
    //                    dangerousGoods := omit
    //                }, // End of VehicleCommonParameters
    //                m_profileParameters_BasicVehicle
    //            )), false);
    //        }
    //
    //        testcase tc_checkLdmFull_Paris() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_checkLdm(m_camMsg_irs (
    //                5434534,
    //                5424,
    //                { true, false, true },
    //                {
    //                    longitude := {hemisphere := east, degree := 200000000},
    //                    latitude := {hemisphere := north, degree := 480000000},
    //                    elevation := 910,
    //                    heading := 7200,
    //                    streetName := "Montmartre",
    //                    positionConfidence := 5,
    //                    elevationConfidence := 7,
    //                    roadSegmentID := 1234567
    //                }
    //            )), false);
    //        }
    //
    //        testcase tc_checkLdmFull_LaPaz() runs on TCType system TCType {
    //            test_PDU<UtEvent>(m_checkLdm(m_camMsg_irs (
    //                6546424,
    //                35445334,
    //                { false, false, false },
    //                {
    //                    longitude := {hemisphere := west, degree := 220000000},
    //                    latitude := {hemisphere := south, degree := 270000000},
    //                    elevation := 36600,
    //                    heading := 21600,
    //                    streetName := "El Alto",
    //                    positionConfidence := omit,
    //                    elevationConfidence := omit,
    //                    roadSegmentID := 3546345
    //                }
    //            )), false);
    //        }
    //
    //        template (value) CAM m_camMsg_valid_With_Parameters(
    //            StationID p_stationId,
    //            GenerationDeltaTime p_generationTime,
    //            template (value) ReferencePosition p_referencePosition
    //        ) := {
    //            header := {
    //                protocolVersion := 1,
    //                messageID := 2,
    //                stationID := p_stationId
    //            },
    //            cam := {
    //                generationDeltaTime := p_generationTime,
    //                camParameters := {
    //                    basicContainer := {
    //                        stationType := c_stationType_passengerCar,
    //                        referencePosition := p_referencePosition
    //                    },
    //                    highFrequencyContainer := {
    //                        basicVehicleContainerHighFrequency := {
    //                            heading := {
    //                                headingValue := c_headingValue_wgs84North, //0
    //                                headingConfidence := 10
    //                            },
    //                            speed := {
    //                                speedValue := 45,
    //                                speedConfidence := 5
    //                            },
    //                            driveDirection := forward,
    //                            vehicleLength := {
    //                                vehicleLengthValue := 50,
    //                                vehicleLengthConfidenceIndication := noTrailerPresent
    //                            },
    //                            vehicleWidth := 21,
    //                            longitudinalAcceleration := {
    //                                longitudinalAccelerationValue := c_longitudinalAccelerationValue_unavailable,
    //                                longitudinalAccelerationConfidence := c_accelerationConfidence_unavailable
    //                            },
    //                            curvature := {
    //                                curvatureValue := c_curvatureValue_straight,
    //                                curvatureConfidence := unavailable
    //                            },
    //                            curvatureCalculationMode := yawRateUsed,
    //                            yawRate := {
    //                                yawRateValue := c_yawRateValue_straight,
    //                                yawRateConfidence := unavailable
    //                            },
    //                            accelerationControl := omit,
    //                            steeringWheelAngle := omit,
    //                            lateralAcceleration := omit,
    //                            verticalAcceleration := omit, 
    //                            performanceClass := omit
    //                        }
    //                    },
    //                    lowFrequencyContainer := {
    //                        basicVehicleContainerLowFrequency := {
    //                            vehicleRole := default_,
    //                            exteriorLights := c_exteriorLights_daytimeRunningLightsOn,
    //                            pathHistory := {}
    //                        }
    //                    },
    //                    specialVehicleContainer := omit
    //                }
    //            }
    //        }
    //        
    //        template (value) ProfileParameters m_profileParameters_BasicVehicle := {
    //                    basicVehicle := {
    //                    }
    ////                    emergencyVehicle := {
    ////                        lightBarInUse := 2,
    ////                        sireneInUse := 3,
    ////                        emergencyResponseType := 1
    ////                    }
    ////                    publicTransportVehicle := {
    ////                        publicVehicleType := 3,
    ////                        pTLineDescription := {
    ////                            courseOfJourney := "Course Of Journey",
    ////                            lineRef := 10,
    ////                            routeRef := "Route Ref"
    ////                        },
    ////                        ScheduleDeviation scheduleDeviation optional,
    ////                        TrafficLightPriority trafficLightPriority optional
    ////                    } // End of PublicTransportVehicle
    //        } // End of template m_profileParameters_BasicVehicle
    //
    //        template (value) ProfileParameters m_profileParameters_EmergencyVehicle := {
    //            emergencyVehicle := {
    //                lightBarInUse := enabled,
    //                sireneInUse := engaged,
    //                emergencyResponseType := rightOfWay
    //            }
    //        } // End of template m_profileParameters_EmergencyVehicle
    //
    //        template (value) ProfileParameters m_profileParameters_PublicTransportVehicle := {
    //            publicTransportVehicle := {
    //                publicVehicleType := 3,
    //                pTLineDescription := {
    //                    courseOfJourney := "Course Of Journey",
    //                    lineRef := "Line Ref",
    //                    routeRef := "Route Ref"
    //                },
    //                scheduleDeviation := -200,
    //                trafficLightPriority := 7
    //            }
    //        } // End of template m_profileParameters_PublicTransportVehicle
    //        
        } // End of group testUtEvent
        
        group testCamPrimitiveMessages {
            
            testcase tc_CamReq() runs on TCType system TCType {
                log("v_camReq=", m_camReq(
                    m_camMsg(
                        f_getTsStationId(),
                        35000 // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                    )
                ));
                log("v_camReq=", bit2oct(encvalue(m_camReq(
                    m_camMsg(
                        f_getTsStationId(),
                        35000 // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                    )
                ))));
                test_PDU<CamReq>(
                    m_camReq(
                        m_camMsg(
                            f_getTsStationId(),
                            35000 // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                        )
                    ), 
                    true,
                    oct2bit('01020001B20788B80059F48D95CDEFC8C5E0020020002461A83C000004805A100C4528399D4C387FFF80'O)
                );
            }
            
            testcase tc_encodeCamTemplate() runs on TCType system TCType {
                var template (value) CamReq v_camReq := m_camReq(
                    m_camMsg_vehicle_HF_BV(
                        f_getTsStationId(),
                        f_getCurrentTime() mod 65536, // See ETSI EN 302 637-2 V1.3.0 - Clause B.3 generationDelatTime
                        m_tsPosition
                    )
                );
                log("v_camReq=", v_camReq);
                log("v_camReq=", bit2oct(encvalue(v_camReq)));
                
            }
            
        } // End of group testCamPrimitiveMessages
        
    } // End of group LibItsCam_testCases