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); log("Encoded message: ", bit2oct(v_encMsg)); // 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))); 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