ItsDenm_TestCases.ttcn 222 KB
Newer Older
filatov's avatar
filatov committed
/**
 *    @author   ETSI / STF484
filatov's avatar
filatov committed
 *    @version  $URL$
 *              $Id$
 *    @desc     DENM Testcases (TS 102 869-2 V<2.1.1> (<2012-09>))
 *
 */
module ItsDenm_TestCases {
    
    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    import from LibCommon_BasicTypesAndValues all;  
filatov's avatar
filatov committed
    
    // LibIts
    import from LibItsCommon_Functions all;
    import from LibItsCommon_TypesAndValues all;
    import from LibItsDenm_TestSystem all;
    import from LibItsDenm_Functions all;
    import from LibItsDenm_Templates all;
    import from LibItsDenm_TypesAndValues all;
    import from DENM_PDU_Descriptions language "ASN.1:1997" all;
    import from ITS_Container language "ASN.1:1997" all;
    
    // 5.2.1
    group denMessageTransmission {
        
      // 5.2.1.1
      group denMessageFormat {
          
          /**
           * @desc    Check that protocolVersion is set to 1 and messageID is set to 1
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_Trigger request from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing ITS PDU header,
           *                  containing protocolVersion
           *                      indicating value 1
           *                  and containing messageID
           *                      indicating value 1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSGF/BV-01, ETSI EN 302 637-3, Annex B.1
           */
          testcase TC_DEN_MSGF_BV_01() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm,
                              mw_anyStationId, 
                              c_protocolVersionDenm, 
                              c_messageId
                          )
                      ) 
                  ) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received a DENM with incorrect header information. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_MSGF_BV_01
          
          /**
           * @desc    Check that sent DENM contains at least one 'trace' DE
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_Trigger request from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing location container
           *                  containing at least one 'trace'
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSGF/BV-02, ETSI EN 302 637-3, clause  6.1.3.2
           */
          testcase TC_DEN_MSGF_BV_02() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_anyDenmMgmtCon,
                                  -,
                                  mw_denmLocationWithTrace({ ?, * })
                              )
                          )
                      ) 
                  ) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received a DENM with incorrect location container information. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_MSGF_BV_02
          
      } // end denMessageFormat
      
      // 5.2.1.2
      group denEventGeneration {
        
          /**
           * @desc    Check that DEN Basic Service generates a new DENM on reception of a valid AppDENM_Trigger request
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_Trigger request from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-01, ETSI EN 302 637-3, clause 6.1.2.1
           */
          testcase TC_DEN_EVGN_BV_01() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (mw_anyDenmMgmtCon)
                          )
                      ) 
                  ) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received a DENM with incorrect header and management information. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_01
          
          /**
           * @desc    Check that a new ActionID value is assigned for each newly generated DENM
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating an unused value
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-02, ETSI EN 302 637-3, clause 6.1.1.1
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVGN_BV_02() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainerList v_situations := {
                  m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable),
                  m_situation(c_causeAccident, c_subCauseCode_Unavailable),
                  m_situation(c_causeRoadworks, c_subCauseCode_Unavailable),
                  m_situation(c_causeSlowVehicle, c_subCauseCode_Unavailable)
              };
              var boolean v_success := true;
              var ActionIDList v_actionIds;
              var DenmInd v_denmInd;
              var integer i;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              for (i := 0; i < lengthof(v_situations) - 1; i:=i + 1) {
                  f_utTriggerEvent(m_utTriggerEvent(v_situations[i], m_denmLocation_zeroDelta));
                  f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
                  v_actionIds[i] := v_denmInd.msgIn.denm.management.actionID;
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTriggerEvent(m_utTriggerEvent(v_situations[lengthof(v_situations) - 1], m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_actionIds[lengthof(v_actionIds) - 1] := v_denmInd.msgIn.denm.management.actionID;
              
              //check the action id
              for (i := 0; i < lengthof(v_actionIds) - 1; i:=i + 1) {
                  if (v_actionIds[lengthof(v_actionIds) - 1].sequenceNumber == v_actionIds[i].sequenceNumber) {
                      v_success := false;
                  }
              }
              if (v_success==true) {
                  log("*** " & testcasename() & ": PASS: actionID field indicating unused value. ***");
                  f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
              }
              else {
                  log("*** " & testcasename() & ": FAIL: actionID field indicating used value. ***");
                  f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
              }
              
              // Postamble
              for (i := 0; i < lengthof(v_actionIds); i:=i + 1) {
                  f_poCancelEvent(e_iut, v_actionIds[i]);
              }
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_02
          
          /**
           * @desc    Check that a newly created ActionID contains the StationID of the originating ITS-S that detected the event
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      containing originatingStationID
filatov's avatar
filatov committed
           *                          indicating its own StationID
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-03, ETSI EN 302 637-3, clause 6.1.1.1
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVGN_BV_03() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_denmMgmtConWithActionID(
                                      mw_actionId(f_getIutStationId())
                                  )
                              )
                          )
                      )
                  ) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_03
          
          /**
           * @desc    Check that Cause and subcause values included in DENM as provided by application
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_trigger request from the application layer
           *              containing situation container
           *                  containing eventType
           *                      containing causeCode
           *                          indicating Value1
           *                      containing subCauseCode
           *                          indicating Value2
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing situation container
           *                  containing eventType
           *                      containing causeCode
           *                          indicating Value1
           *                      containing subCauseCode
           *                          indicating Value2
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-04, ETSI EN 302 637-3, clause 7.1.3
           */
          testcase TC_DEN_EVGN_BV_04() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_anyDenmMgmtCon,
                                  v_situation
                              )
                          )
                      )
                  ) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_04
          
          /**
           * @desc    Check that referenceTime is set to to the current time when generating a DENM for a new event
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing referenceTime
           *                      indicating CLT
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-05, ETSI EN 302 637-3, clause 8.2.1.3
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVGN_BV_05() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainerList v_situations := {
                  m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable),
                  m_situation(c_causeAccident, c_subCauseCode_Unavailable),
                  m_situation(c_causeRoadworks, c_subCauseCode_Unavailable),
                  m_situation(c_causeSlowVehicle, c_subCauseCode_Unavailable)
              };
              var ActionIDList v_actionIds;
              var DenmInd v_denmInd;
              var integer i;
              var TimestampIts v_timestampIts;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              v_timestampIts := f_getCurrentTime();
              for (i := 0; i < lengthof(v_situations) - 1; i:=i + 1) {
                  f_utTriggerEvent(m_utTriggerEvent(v_situations[i], m_denmLocation_zeroDelta));
                  f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
                  v_actionIds[i] := v_denmInd.msgIn.denm.management.actionID;
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTriggerEvent(m_utTriggerEvent(v_situations[lengthof(v_situations) - 1], m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_denmMgmtConWithReferenceTime(
                                      mw_timestampIts_withDelta(v_timestampIts)
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      v_actionIds[lengthof(v_actionIds)] := v_denmInd.msgIn.denm.management.actionID;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              for (i := 0; i < lengthof(v_actionIds); i:=i + 1) {
                  f_poCancelEvent(e_iut, v_actionIds[i]);
              }
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_05
          
          /**
           * @desc    Check that sequenceNumber is set to a next unused value each time an event is detected
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *      and the IUT having generated its last DENM
           *          containing management container
           *              containing actionID
           *                  containing sequenceNumber
           *                      indicating SEQ1
           *      and no active event being associated with sequenceNumber SEQ1 + 1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      containing sequenceNumber
           *                          indicating SEQ1 + 1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-07, ETSI EN 302 637-3, clauses 6.1.1.1, 8.2.1.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVGN_BV_07() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainerList v_situations := {
                  m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable),
                  m_situation(c_causeAccident, c_subCauseCode_Unavailable),
                  m_situation(c_causeRoadworks, c_subCauseCode_Unavailable),
                  m_situation(c_causeSlowVehicle, c_subCauseCode_Unavailable)
              };
              var SequenceNumber v_sequenceNumber;
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var integer i;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              for (i := 0; i < lengthof(v_situations) - 1; i:=i + 1) {
                  f_utTriggerEvent(m_utTriggerEvent(v_situations[i], m_denmLocation_zeroDelta));
                  f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
                  f_poCancelEvent(e_iut, v_denmInd.msgIn.denm.management.actionID);
              }
              //save the last sequence number
              v_sequenceNumber := v_denmInd.msgIn.denm.management.actionID.sequenceNumber;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTriggerEvent(m_utTriggerEvent(v_situations[lengthof(v_situations) - 1], m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_denmMgmtConWithActionID(
                                      mw_actionId(-, f_increaseSequenceNumber(v_sequenceNumber))
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      v_actionId := v_denmInd.msgIn.denm.management.actionID;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_07
          
          /**
           * @desc    Check that sequenceNumber is set to a next unused value each time an event is detected (Sequence number wrap around)
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *      and the IUT having generated its last DENM
           *          containing management container
           *              containing actionID
           *                  containing sequenceNumber
           *                      indicating SEQ1
           *      and an active event being associated with sequenceNumber SEQ1 + 1
           *      and no active event being associated with sequenceNumber SEQ1 + 2
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      containing sequenceNumber
           *                          indicating SEQ1 + 2
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-08, ETSI EN 302 637-3, clauses 6.1.1.1, 8.2.1.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVGN_BV_08() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var SequenceNumber v_firstSequenceNumber;
              var DenmInd v_denmInd;
              var integer i;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_firstSequenceNumber := v_denmInd.msgIn.denm.management.actionID.sequenceNumber;
              for (i := 1; i < 65535; i := i + 1) {
                  f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
                  f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
                  f_poCancelEvent(e_iut, v_denmInd.msgIn.denm.management.actionID);
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm(
                                  mw_denmMgmtConWithActionID(
                                      mw_actionId(-, f_increaseSequenceNumber(v_firstSequenceNumber))
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, m_actionId(v_firstSequenceNumber));
              f_poCancelEvent(e_iut, m_actionId(f_increaseSequenceNumber(v_firstSequenceNumber)));
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_08
          
          /**
           * @desc    Check that actionID are generated using newly assigned stationID when a pseudonym change occurs
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *          containing management container
           *              containing actionID
           *                  containing originatingStationID
           *                      indicating STATION_ID_1
           *      and the IUT having changed its StationID
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to generate a new event
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      containing originatingStationID
           *                          indicating its new StationID
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVGN/BV-10, ETSI EN 302 637-3, clauses 6.1.1.2
          testcase TC_DEN_EVGN_BV_10() runs on ItsDenm system ItsDenmSystem {
filatov's avatar
filatov committed
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var StationID v_stationId;
filatov's avatar
filatov committed
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_stationId := f_getIutStationId ( );
              f_utChangePseudonym ( m_utChangePseudonym );
filatov's avatar
filatov committed
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive ( mw_denmInd ( mw_denmPdu ( mw_denm ( mw_anyDenmMgmtCon ) ) ) ) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      if ( v_denmInd.msgIn.denm.management.actionID.originatingStationID != v_stationId ) {
                      	log("*** " & testcasename() & ": PASS: Successfully received expected DENM - Pseudonym changed. ***");
                      	f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                  }
                      else {
                      	log("*** " & testcasename() & ": FAIL: received expected DENM - Pseudonym not changed. ***");
                      	f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                      }
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVGN_BV_10
filatov's avatar
filatov committed
          
      } // end denEventGeneration
      
      // 5.2.1.3
      group denEventUpdate {
          
          /**
           * @desc    Check that DEN Basic Service generates an update DENM on reception of a valid AppDENM_update request
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_update request from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVUP/BV-01, ETSI EN 302 637-3, clause 6.1.2.2
           */
          testcase TC_DEN_EVUP_BV_01() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              f_utUpdateEvent(m_utUpdateEvent(v_actionId, v_situation));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (mw_anyDenmMgmtCon)
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVUP_BV_01
          
          /**
           * @desc    Check that the actionID is not changed by DENM update, as long as the stationID of the originating ITS-S remains unchanged
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           * 	  and the IUT not having changed its stationID
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_update request associated with ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVUP/BV-02, ETSI EN 302 637-3, clauses 6.1.2.2, 8.1.1.1
           */
          testcase TC_DEN_EVUP_BV_02() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              f_utUpdateEvent(m_utUpdateEvent(v_actionId, v_situation));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (
                                  mw_denmMgmtConWithActionID(
                                      v_actionId
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVUP_BV_02
          
          /**
           * @desc    Check that referenceTime is set to the current time when generating a DENM for an updated eventCheck 
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              containing referenceTime
           *                  indicating REFERENCETIME1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_update request associated with ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing referenceTime
           *                      indicating CLT > REFERENCETIME1
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVUP/BV-03, ETSI EN 302 637-3, clause 6.1.2.2
           */
          testcase TC_DEN_EVUP_BV_03() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var TimestampIts v_referenceTime1 , v_timestampIts , v_msgtimestamp;
              var Int16 v_diff;
filatov's avatar
filatov committed
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_referenceTime1 := v_denmInd.msgIn.denm.management.referenceTime;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              f_utUpdateEvent(m_utUpdateEvent(v_actionId, v_situation));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (
                                  mw_denmMgmtCon(
                                      v_actionId
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      v_timestampIts := f_getCurrentTime();
                      v_msgtimestamp := v_denmInd.msgIn.denm.management.referenceTime;
                      if ( ( ( v_timestampIts + v_diff ) > v_msgtimestamp ) and ( v_msgtimestamp > v_referenceTime1 ) ) {
filatov's avatar
filatov committed
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                      }
                      else {
                          log("*** " & testcasename() & ": FAIL: ReferenceTime not updated correctly ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVUP_BV_03
          
          /**
           * @desc    Check that DEN Basic Service does not send any update DENM if actionID is not in originating ITS-S message table
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *      and the IUT not having sent an event being associated with actionID ACTION_ID1
filatov's avatar
filatov committed
           *          containing originatorStationID
           *              indicating its own stationID
           *          and containing sequenceNumber
           *              indicating SEQ1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to update an event associated to ACTION_ID1
           *      }
           *      then {
           *          the IUT does not send send any DENM for this event
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVUP/BV-05, ETSI EN 302 637-3, clause 8.1.2
           */
          testcase TC_DEN_EVUP_BV_04() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              f_utUpdateEvent(m_utUpdateEvent(m_actionId(f_increaseSequenceNumber(v_actionId.sequenceNumber), f_getIutStationId()), v_situation));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (
                                  mw_denmMgmtCon(
                                      m_actionId(
                                          f_increaseSequenceNumber(v_actionId.sequenceNumber),
                                          f_getIutStationId()
                                      )
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received updated DENM for the actionId which is not in originator ITS-S message table. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": PASS: No DENM was sent. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVUP_BV_05
          
      } // end denEventUpdate
      
      // 5.2.1.4
      group denEventTermination {
          
          /**
           * @desc    Check that DEN Basic Service generates a cancellation DENM when application indicates the 
           *          premature termination of an event for which it is the originator
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              and containing validityDuration
           *                  indicating DURATION_1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated to ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing termination
           *                     indicating value isCancellation
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-01, ETSI EN 302 637-3, clauses 6.1.2.4, 8.2.1.3
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_01() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta, c_duration_10sec));
              f_awaitDenMessage(
                  mw_denmInd(
                      mw_denmPdu(
                          mw_denm(
                              mw_denmMgmtCon(
                                  mw_anyActionId, -, -, -,
                                  c_duration_2sec
                              )
                          )
                      )
                  ), 
                  v_denmInd
              );
filatov's avatar
filatov committed
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent(m_utEventCancellation(v_actionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive ( mw_denmInd ( mw_denmPdu (
                  										mw_denm ( m_denmMgmtConTermination ( v_actionId, -, -, -, -, -, isCancellation ))))) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_01
          
          /**
           * @desc    Check that DEN Basic Service generates a negation DENM when application indicates the 
           *          premature termination of an event for which it is not the originator
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *                      containing originatorStationID
           *                          indicating stationID different from its own stationID
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated to ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing termination
           *                      indicating value isNegation
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-02, ETSI EN 302 637-3, clause 6.1.2.4
           */
          testcase TC_DEN_EVTR_BV_02() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              v_actionId := f_sendDenMessage ( m_denm ( m_denmMgmtCon ( m_tsActionId ), v_situation, m_denmLocation_zeroDelta ) );
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent(m_utEventCancellation(v_actionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive ( mw_denmInd ( mw_denmPdu (
                  										mw_denm ( m_denmMgmtConTermination ( v_actionId, -, -, -, -, -, isNegation ))))) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_02
          
          /**
           * @desc   Check that referenceTime is set to the latest value received for this event in negation DENM
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *                      containing originatorStationID
           *                          indicating stationID different from its own stationID
           *              and containing referenceTime
           *                  indicating REFERENCETIME1
           *      and the IUT having received an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              and containing referenceTime
           *                  indicating REFERENCETIME2 > REFERENCETIME1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated to ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing referenceTime
           *                      indicating value REFERENCETIME2
           *                  and containing termination
           *                      indicating value isNegation
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-03, ETSI EN 302 637-3, clauses 6.1.2.4, 8.2.1.3
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_03() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var TimestampIts v_referenceTime1 := f_getCurrentTime();
              var TimestampIts v_referenceTime2;
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              v_actionId := f_sendDenMessage(
                  m_denm(
                      m_denmMgmtCon(
                          m_tsActionId, 
                          -, 
                          -, 
                          -, 
                          v_referenceTime1
                      ),
                      v_situation,
                      m_denmLocation_zeroDelta
                  )
              );
filatov's avatar
filatov committed
              
              v_referenceTime2 := f_getCurrentTime();
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              v_actionId := f_sendDenMessage(
                  m_denm(
                      m_denmMgmtCon(
                          m_tsActionId, 
                          -, 
                          -, 
                          -, 
                          v_referenceTime2
                      ),
                      v_situation,
                      m_denmLocation_zeroDelta
                  )
              );
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent(m_utEventCancellation(v_actionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                              mw_denm (
                                  m_denmMgmtConTermination(
                                      v_actionId, 
                                      -, 
                                      -, 
                                      -, 
                                      -, 
                                      v_referenceTime2, 
                                      isNegation
                                  )
                              )
                          )
                      )
                  ) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_03
          
          /**
           * @desc    Check that situation container, location container  and alacarte container are not present in a cancellation DENM
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated to ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing termination
           *                      indicating value isCancellation
filatov's avatar
filatov committed
           *              and not containing situation container
           *              and not containing location container
           *              and not containing alacarte container
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-04, ETSI EN 302 637-3, clause 7.1.1
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_04() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta, c_duration_10sec));
              f_awaitDenMessage(
                  mw_denmInd(
                      mw_denmPdu(
                          mw_denm(
                              mw_denmMgmtCon(
                                  mw_anyActionId
                              )
                          )
                      )
                  ), 
                  v_denmInd
              );
filatov's avatar
filatov committed
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent(m_utEventCancellation(v_actionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                  				mw_denm ( m_denmMgmtConTermination ( v_actionId, -, -, -, -, -, isCancellation ), omit, omit, omit ) ) ) ) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_04
          
          /**
           * @desc    Check that situation container, location container and alacarte container are not present in a negation DENM
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *                      containing originatorStationID
           *                          indicating stationID different from its own stationID
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated to ACTION_ID1 from the application layer
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
           *                  and containing termination
           *                      indicating value isNegation
filatov's avatar
filatov committed
           *              and not containing situation container
           *              and not containing location container
           *              and not containing alacarte container
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-05, ETSI EN 302 637-3, clause 7.1.1
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_05() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              v_actionId := f_sendDenMessage ( m_denm ( m_denmMgmtCon ( m_tsActionId ), v_situation, m_denmLocation_zeroDelta ) );
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent(m_utEventCancellation(v_actionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_denmPdu(
                  				mw_denm ( m_denmMgmtConTermination ( v_actionId, -, -, -, -, -, isNegation ), omit, omit, omit ) ) ) ) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_05
          
          /**
           * @desc    Check that DEN Basic Service does not send any termination DENM if actionID is not in 
           *          originating ITS-S message table or receiving ITS-S message table (own stationID)
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated several events
           *      and the IUT not having send event being associated with ACTION_ID1
           *          containing originatingStationID
filatov's avatar
filatov committed
           *              indicating its own stationID
           *          and containing sequenceNumber
           *              indicating SEQ1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to terminate an event associated to ACTION_ID1
           *              containing originatingStationID
filatov's avatar
filatov committed
           *                  indicating its own stationID
           *              and containing sequenceNumber
           *                  indicating SEQ1
           *      }
           *      then {
           *          the IUT does not send send any termination DENM for this event
           *      }
           *  }
           *  NOTE: Event associated to ACTION_ID1 cannot be present in receiving ITS-S message 
filatov's avatar
filatov committed
           *        table as its stationID is IUT’s stationID (see TP/DEN/EVTR/BV-07)
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-06, ETSI EN 302 637-3, clauses 8.2.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_06() runs on ItsDenm system ItsDenmSystem {
              
              // Local variables
              var template (value) SituationContainerList v_situations := {
                  m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable),
                  m_situation(c_causeAccident, c_subCauseCode_Unavailable),
                  m_situation(c_causeRoadworks, c_subCauseCode_Unavailable),
                  m_situation(c_causeSlowVehicle, c_subCauseCode_Unavailable)
              };
              var ActionID v_unknownActionId;
              var ActionIDList v_actionIds;
filatov's avatar
filatov committed
              var DenmInd v_denmInd;
              var integer i;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              for (i := 0; i < lengthof(v_situations); i:=i + 1) {
                  f_utTriggerEvent(m_utTriggerEvent(v_situations[i], m_denmLocation_zeroDelta));
                  f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
                  v_actionIds[i] := v_denmInd.msgIn.denm.management.actionID;
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_unknownActionId := valueof(m_actionId(
filatov's avatar
filatov committed
                                        f_increaseSequenceNumber(
                                            v_actionIds[lengthof(v_actionIds)].sequenceNumber
                                        ),
                                        f_getIutStationId()
filatov's avatar
filatov committed
              f_utTerminateEvent(m_utEventCancellation(v_unknownActionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive(
                      mw_denmInd(
                          mw_anyDenmPdu(
                              mw_itsPduHeader,
                              mw_denm (
                                  mw_denmMgmtCon(v_unknownActionId)
                              )
                          )
                      )
                  ) -> value v_denmInd {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received termination DENM for the unknown actionId. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": PASS: No termination DENM was sent. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              for (i := 0; i < lengthof(v_situations); i:=i + 1) {
                  f_poCancelEvent(e_iut, v_actionIds[i]);
              }
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_06
          
          /**
           * @desc    Check that DEN Basic Service does not send any termination DENM if actionID is not in 
           *          originating ITS-S message table or receiving ITS-S message table (other stationID)
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received several events
           *      and the IUT not having received event being associated with ACTION_ID1
           *          containing originatingStationID
filatov's avatar
filatov committed
           *              indicating STATION_ID1 different from its own stationID
           *          and containing sequenceNumber
           *              indicating SEQ1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is requested to terminate an event associated to ACTION_ID1
           *              containing originatingStationID
filatov's avatar
filatov committed
           *                  indicating STATION_ID1
           *              and containing sequenceNumber
           *                  indicating SEQ1
           *      }
           *      then {
           *          the IUT does not send send any termination DENM for this event
           *      }
           *  }
           *  NOTE: Event associated to ACTION_ID1 cannot be present in originating ITS-S message table as its 
filatov's avatar
filatov committed
           *        stationID is not IUT’s stationID (see TP/DEN/EVTR/BV-06)
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-07, ETSI EN 302 637-3, clauses 8.2.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVTR_BV_07() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const SequenceNumber v_initialSequenceNumber := 0;
              // Local variables
              var template (value) SituationContainerList v_situations := {
                  m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable),
                  m_situation(c_causeAccident, c_subCauseCode_Unavailable),
                  m_situation(c_causeRoadworks, c_subCauseCode_Unavailable),
                  m_situation(c_causeSlowVehicle, c_subCauseCode_Unavailable)
              };
              var SequenceNumber v_sequenceNumber := v_initialSequenceNumber;
              var ActionID v_unknownActionId;
              var ActionIDList v_actionIds; 
filatov's avatar
filatov committed
              var DenmInd v_denmInd;
              var integer i;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              for (i := 0; i < lengthof(v_situations); i:=i + 1) {
                  v_sequenceNumber := f_increaseSequenceNumber(v_sequenceNumber);
                  v_actionIds[i] := f_sendDenMessage( m_denm( m_denmMgmtCon( m_tsActionId(v_sequenceNumber) ), v_situations[i], m_denmLocation_zeroDelta ) );
filatov's avatar
filatov committed
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              v_unknownActionId := valueof(m_actionId(
filatov's avatar
filatov committed
                                        f_increaseSequenceNumber(
                                            v_actionIds[lengthof(v_actionIds)].sequenceNumber
                                        ),
                                        f_getTsStationId()
filatov's avatar
filatov committed
              f_utTerminateEvent(m_utEventCancellation(v_unknownActionId));
              
              tc_ac.start;
              alt {
                  [] denmPort.receive( mw_denmInd( mw_anyDenmPdu( mw_itsPduHeader, mw_denm ( mw_denmMgmtCon(v_unknownActionId) ) ) ) ) -> value v_denmInd {
filatov's avatar
filatov committed
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received termination DENM for the unknown actionId. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": PASS: No termination DENM was sent. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              for (i := 0; i < lengthof(v_situations); i:=i + 1) {
                  f_poCancelEvent(e_ets, v_actionIds[i]);
              }
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_07
          
          /**
           * @desc    Check that referenceTime is set to to the current time when generating a cancellation DENM
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having generated an event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
		   *	          and containing validityDuration
		   * 		          indicating DURATION_1
           *              and containing referenceTime
           *                  indicating REFERENCETIME1
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT receives an AppDENM_termination request associated with ACTION_ID1 from the application layer
filatov's avatar
filatov committed
           *      }
           *      then {
           *          the IUT sends a valid DENM
           *              containing management container
           *                  containing actionID
           *                      indicating ACTION_ID1
		   *	              and containing termination
		   *		              indicating value isCancellation
           *                  and containing referenceTime
           *                      indicating CLT
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVTR/BV-08, ETSI EN 302 637-3, clause 8.2.1.3
          testcase TC_DEN_EVTR_BV_08() runs on ItsDenm system ItsDenmSystem {
filatov's avatar
filatov committed
              
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var TimestampIts v_referenceTime1 , v_timestampIts , v_msgtimestamp;
              var Int16 v_diff;
filatov's avatar
filatov committed
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
              f_awaitDenMessage(mw_denmInd(mw_anyDenmPdu), v_denmInd);
              v_timestampIts := f_getCurrentTime();
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_referenceTime1 := v_denmInd.msgIn.denm.management.referenceTime;
              v_diff := v_referenceTime1 - v_timestampIts;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              f_utTerminateEvent ( m_utEventCancellation ( v_actionId ) );
              
              tc_ac.start;
              alt {
                  [] denmPort.receive ( 
                  		mw_denmInd ( mw_denmPdu ( mw_denm ( m_denmMgmtConTermination ( v_actionId, -, -, -, -, -, isCancellation ) ) ) ) ) -> value v_denmInd {
                      tc_ac.stop;
                      v_timestampIts := f_getCurrentTime();
                      v_msgtimestamp := v_denmInd.msgIn.denm.management.referenceTime;
                      if ( ( ( v_timestampIts + v_diff ) > v_msgtimestamp ) and ( v_msgtimestamp > v_referenceTime1 ) ) {
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                          log("*** " & testcasename() & ": FAIL: ReferenceTime not updated correctly ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVTR_BV_08
          
      } // end denEventTermination
      
      // 5.2.1.5
      group denMessageRepetition {
          
          /**
           * @desc    Check that DEN Basic Sercive repeats DENM transmission according to repetitionInterval parameter provided by application
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from the application layer
           *          containing repetitionInterval
           *              indicating INTERVAL_1
           *          and containing repetitionDuration
           *              indicating DURATION_1
           *          and containing validityDuration
           *              indicating DURATION_2 > DURATION_1
           *      and the IUT having generated an the corresponding event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              and containing validityDuration
           *                  indicating DURATION_1
           *              and containing transmissionInterval
           *                  indicating INTERVAL_1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with INTERVAL_1
           *      }
           *      then {
           *          the IUT repeats the transmission of the valid DENM associated with ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-01, ETSI EN 302 637-3, clause 6.1.2.3 and 8.2.2
           */
          testcase TC_DEN_EVRP_BV_01() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const TransmissionInterval    c_repetitionInterval    := c_interval_1sec;        // INTERVAL_1
              const ValidityDuration        c_validityDuration        := c_duration_10sec;        // DURATION_2
              const ValidityDuration        c_repetitionDuration    := c_validityDuration;                // DURATION_1
              const float c_lowerRepetitionInterval := int2float(c_repetitionInterval)*0.95;
              const float c_upperRepetitionInterval := int2float(c_repetitionInterval)*1.05;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
                                                                                  c_validityDuration
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              // Local timers
              timer t_repetition;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent ( m_utTriggerEvent ( v_situation, m_denmLocation_zeroDelta, c_validityDuration, c_repetitionDuration, c_repetitionInterval ) );
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_repetition.start(2.0 * int2float(c_repetitionInterval/1000));
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
filatov's avatar
filatov committed
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      if (match(t_repetition.read*1000.0, (c_lowerRepetitionInterval..c_upperRepetitionInterval))) {
filatov's avatar
filatov committed
                          t_repetition.stop;
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM in the expected interval. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                      }
                      else {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": FAIL: Received expected DENM, interval was not correct. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] t_repetition.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_01
          
          /**
           * @desc    Check that the repeated DENM is always the most up-to-date message
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from the application layer
           *          containing repetitionInterval
           *              indicating INTERVAL_1
           *          and containing repetitionDuration
           *              indicating DURATION_1
           *          and containing validityDuration
           *              indicating DURATION_2 > DURATION_1
           *      and the IUT having generated an the corresponding event
filatov's avatar
filatov committed
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *      and the IUT having generated an update of the event associated with ACTION_ID1 modifying partly the event
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with INTERVAL_1
           *      }
           *      then {
           *          the IUT repeats the transmission of the valid DENM associated with ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-02, ETSI EN 302 637-3, clause 6.1.2.3 and 8.2.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVRP_BV_02() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const ValidityDuration c_validityDuration := c_duration_10sec;
              const TransmissionInterval c_repetitionInterval := c_interval_5sec;
filatov's avatar
filatov committed
              const ValidityDuration c_repetitionDuration := c_validityDuration;
              const float c_lowerRepetitionInterval := int2float(c_repetitionInterval)*0.95;
              const float c_upperRepetitionInterval := int2float(c_repetitionInterval)*1.05;
filatov's avatar
filatov committed
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
                                                                                  c_validityDuration
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
filatov's avatar
filatov committed
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              // Local timers
              timer t_repetition;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(
                  m_utTriggerEvent(
                      v_situation, 
                      m_denmLocation_zeroDelta, 
                      c_validityDuration, 
                      c_repetitionDuration, 
                      c_repetitionInterval
                  )
              );
filatov's avatar
filatov committed
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              //update event after 1 second
              tc_noac.start(1.0);
              tc_noac.timeout;
              v_situation.eventType.subCauseCode := c_vehicleBreakDownSubCauseCode_engineProblem;
              f_utUpdateEvent(m_utUpdateEvent(v_actionId, v_situation));
              v_expectedDenmInd.msgIn.denm.situation := v_situation;
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_repetition.start(2.0 * int2float(c_repetitionInterval/1000));
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      if (match(t_repetition.read*1000.0, (c_lowerRepetitionInterval..c_upperRepetitionInterval))) {
filatov's avatar
filatov committed
                          t_repetition.stop;
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM in the expected interval. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
filatov's avatar
filatov committed
                      }
                      else {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": FAIL: Received expected DENM, interval was not correct. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] t_repetition.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_02
          
          /**
           * @desc    Check that DEN Basic Service stops retransmitting DENM after event’s validityDuration 
           *          expiration
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *          containing repetitionInterval
           *              indicating INTERVAL_1
           *          and containing repetitionDuration
           *              indicating DURATION_1
           *          and containing validityDuration
           *              indicating DURATION_2 > DURATION_1
           *      and the IUT having generated the corresponding event
filatov's avatar
filatov committed
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              and containing validityDuration
           *                  indicating DURATION_1
           *      and the IUT having repeated (one or more times) the transmission of the valid DENM associated with ACTION_ID1
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with DURATION_2
filatov's avatar
filatov committed
           *      }
           *      then {
           *          the IUT stops the retransmission of the DENM associated with ACTION_ID1
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-03, ETSI EN 302 637-3, clauses 6.1.2.4 and 8.2.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVRP_BV_03() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const ValidityDuration c_validityDuration := c_duration_10sec;
              const TransmissionInterval c_repetitionInterval := c_interval_4sec;
filatov's avatar
filatov committed
              const ValidityDuration c_repetitionDuration := c_validityDuration;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
                                                                                  c_validityDuration
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
filatov's avatar
filatov committed
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var integer i;
              // Local timers
              timer t_validity;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent( v_situation,  m_denmLocation_zeroDelta, c_validityDuration, c_repetitionDuration, c_repetitionInterval ));
filatov's avatar
filatov committed
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_validity.start(1.5 * int2float(c_validityDuration));
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              //await retransmitted DENM message based on the repetition interval in between the validity duration
              for (i:=0; i<(c_validityDuration/(c_repetitionInterval/1000)); i:=i+1) {
filatov's avatar
filatov committed
                  f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] t_validity.timeout {
                      log("*** " & testcasename() & ": PASS: Retransmission of DENM stopped successfully. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                  }
                  [] denmPort.receive(v_expectedDenmInd) {
filatov's avatar
filatov committed
                      t_validity.stop;
                      log("*** " & testcasename() & ": FAIL: Retransmission of DENM was not stopped. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_validity.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_03
          
          /**
           * @desc    Check that DEN Basic Service stops retransmitting DENM after event’s repetitionDuration 
           *          expiration
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *          containing repetitionInterval
           *              indicating INTERVAL_1
           *          and containing repetitionDuration
           *              indicating DURATION_1
           *          and containing validityDuration
           *              indicating DURATION_2 > DURATION_1
           *      and the IUT having generated the corresponding event
filatov's avatar
filatov committed
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *              and containing validityDuration
           *                  indicating DURATION_2
           *      and the IUT having repeated (one or more times) the transmission of the valid DENM associated with ACTION_ID1
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with DURATION_2
           *      }
           *      then {
           *          the IUT stops the retransmission of the most up-to-date valid DENM associated with ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-04, ETSI EN 302 637-3, clause 8.2.2
filatov's avatar
filatov committed
           */
          testcase TC_DEN_EVRP_BV_04() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const ValidityDuration c_validityDuration := c_duration_10sec;
              const TransmissionInterval c_repetitionInterval := c_interval_2sec;
              const ValidityDuration c_repetitionDuration := c_duration_5sec;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
                                                                                  c_validityDuration
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var integer i;
              // Local timers
              timer t_repetition;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta, c_validityDuration, c_repetitionDuration, c_repetitionInterval ));
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_repetition.start(1.5 * int2float(c_repetitionDuration));
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              //await retransmitted DENM message based on the repetition interval in between the repetition duration
              for (i:=0; i<(c_repetitionDuration/(c_repetitionInterval/1000)); i:=i+1) {
                  f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              }
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] t_repetition.timeout {
                      log("*** " & testcasename() & ": PASS: Retransmission of DENM stopped successfully. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                  }
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": FAIL: Retransmission of DENM was not stopped. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_04
          
          /**
           * @desc    Check that DEN Basic Service does not repeat transmission of DENM if repetitionInterval is 
           *          not provided by application
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *          not containing repetitionInterval
           *      and the IUT having generated an the corresponding event
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT has detected that repetitionInterval is not provided for the event associated with ACTION_ID1
           *      }
           *      then {
           *          the IUT does not repeat the transmission of the valid DENM associated with ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-05, ETSI EN 302 637-3, clause 8.1.2
           */
          testcase TC_DEN_EVRP_BV_05() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const ValidityDuration c_validityDuration := c_duration_10sec;
              const ValidityDuration c_repetitionDuration := c_validityDuration;
filatov's avatar
filatov committed
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
                                                                                  -,
filatov's avatar
filatov committed
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var integer i;
              // Local timers
filatov's avatar
filatov committed
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent(
                  m_utTriggerEvent(
                      v_situation, 
                      m_denmLocation_zeroDelta, 
                      c_validityDuration, 
              		  c_repetitionDuration,
                      omit //no repetitionInterval
filatov's avatar
filatov committed
                  )
              );
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_validity.start(1.5 * int2float(c_validityDuration));
filatov's avatar
filatov committed
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] t_validity.timeout {
                      log("*** " & testcasename() & ": PASS: No retransmission of DENM occured as expected. ***");
filatov's avatar
filatov committed
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                  }
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      t_validity.stop;
                      log("*** " & testcasename() & ": FAIL: Unexpected retransmission of DENM occured. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
filatov's avatar
filatov committed
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_05
           * @desc    Check that DEN Basic Service does not repeat transmission of DENM if repetitionDuration is 
filatov's avatar
filatov committed
           *          not provided by application
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *          not containing repetitionDuration
           *      and the IUT having generated an the corresponding event
filatov's avatar
filatov committed
           *          containing management container
           *              containing actionID
           *                  indicating ACTION_ID1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT has detected that repetitionDuration is not provided for the event associated with ACTION_ID1
filatov's avatar
filatov committed
           *      }
           *      then {
           *          the IUT does not repeat the transmission of the valid DENM associated with ACTION_ID1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-06, ETSI EN 302 637-3, clause 8.1.2
          testcase TC_DEN_EVRP_BV_06() runs on ItsDenm system ItsDenmSystem {
filatov's avatar
filatov committed
              
              // Local constants
              const ValidityDuration c_validityDuration := c_duration_10sec;
              const TransmissionInterval c_repetitionInterval := c_interval_2sec;
filatov's avatar
filatov committed
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd := mw_denmInd(
                                                                      mw_denmPdu(
                                                                          mw_denm(
                                                                              mw_denmMgmtCon(
                                                                                  mw_actionId,
                                                                                  -,
                                                                                  -,
filatov's avatar
filatov committed
                                                                              )
                                                                          )
                                                                      )
                                                                  ); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var integer i;
              // Local timers
              timer t_validity;
              
              // Test control
              
              // Test component configuration
              f_cfUp();
              
              // Test adapter configuration
              
              // Preamble
              f_prInitialState();
2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994
              f_utTriggerEvent(
                  m_utTriggerEvent(
                      v_situation, 
                      m_denmLocation_zeroDelta, 
                      c_validityDuration, 
                      omit, //no repetitionDuration 
                      c_repetitionInterval                      
                  )
              );
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              t_validity.start(1.5 * int2float(c_validityDuration));
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] t_validity.timeout {
                      log("*** " & testcasename() & ": PASS: No retransmission of DENM occured as expected. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                  }
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      t_validity.stop;
                      log("*** " & testcasename() & ": FAIL: Unexpected retransmission of DENM occured. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_validity.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
             
          } // end TC_DEN_EVRP_BV_06
          
          /**
           * @desc    Check that existing actionID in originating ITS-S are updated when stationID is modified
           *
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *      	containing repetitionInterval
           *      		indicating INTERVAL_1
           *      	and containing repetitionDuration
           *      		indicating DURATION_1
           *      	and containing validityDuration
           *      		indicating DURATION_2 > DURATION_1
           *      and the IUT having generated the corresponding event
           *      	containing management container
           *      		containing actionID
           *      			containing originatororiginatingStationID
           *      				indicating STATION_ID_1
           *      		and containing validityDuration
           *      			indicating DURATION_1
           *     and the IUT having changed its StationID
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT changes its StationID and is alerted of expiration of the time associated with INTERVAL_1
           *      }
           *      then {
           *      		the IUT repeats the transmission of the valid DENM
           *      			containing management container
           *      				containing actionID
           *      					containing originatingStationID
           *      						indicating its new StationID
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-08, ETSI EN 302 637-3, clause 6.1.1.2
           */
          testcase TC_DEN_EVRP_BV_08() runs on ItsDenm system ItsDenmSystem {
              
              // Local constants
              const ValidityDuration c_duration1 := 3 * c_duration_2sec;
              const ValidityDuration c_duration2 := c_duration_10sec;
              const TransmissionInterval c_interval1 := c_interval_1sec;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation ( c_causeVehicleBreakdown, c_subCauseCode_Unavailable );
              var template (present) DenmInd v_expectedDenmInd :=
              									mw_denmInd ( mw_denmPdu ( mw_denm ( mw_denmMgmtCon ( mw_actionId, -, -, c_duration2 ) ) ) ); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent ( m_utTriggerEvent ( v_situation, m_denmLocation_zeroDelta, c_duration2, c_duration1, c_interval1 ) );
              f_awaitDenMessage ( v_expectedDenmInd, v_denmInd );
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);

              // Test Body
              f_utChangePseudonym ( m_utChangePseudonym );
              
              tc_ac.start;
              alt {
                  [] denmPort.receive ( v_expectedDenmInd ) -> value v_denmInd {
                      tc_ac.stop;
                      if ( v_denmInd.msgIn.denm.management.actionID.originatingStationID != v_actionId.originatingStationID ) {
                      	log("*** " & testcasename() & ": PASS: Successfully received expected DENM - Pseudonym changed. ***");
                      	f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                      	log("*** " & testcasename() & ": FAIL: received expected DENM - Pseudonym not changed. ***");
                      	f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      tc_ac.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] tc_ac.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();

          } // end TC_DEN_EVRP_BV_08
           
          /**
           * @desc		Check that actionID is not modified in repetitions of DENM if stationID is not modified
           *
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *      	containing repetitionInterval
           *      		indicating INTERVAL_1
           *      	and containing repetitionDuration
           *      		indicating DURATION_1
           *      	and containing validityDuration
           *      		indicating DURATION_2 > DURATION_1
           *      and the IUT having generated the corresponding event
           *      	containing management container
           *      		containing actionID
           *      			indicating ACTION_ID_1
           *      		and containing validityDuration
           *      			indicating DURATION_1
           *     and the IUT not having changed its StationID
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with INTERVAL_1
           *      }
           *      then {
           *      		the IUT repeats the transmission of the valid DENM
           *      			containing management container
           *      				containing actionID
           *      					indicating its ACTION_ID_1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-09, ETSI EN 302 637-3, clause 8.2.1.2
           */
          testcase TC_DEN_EVRP_BV_09() runs on ItsDenm system ItsDenmSystem {
              // Local constants
              const ValidityDuration c_duration1 := 3 * c_duration_2sec;
              const ValidityDuration c_duration2 := c_duration_10sec;
              const TransmissionInterval c_interval1 := c_interval_1sec;
              const float c_lowerTransmissionInterval := int2float(c_interval1)*0.95;
              const float c_upperTransmissionInterval := int2float(c_interval1)*1.05;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expectedDenmInd :=
              									mw_denmInd(mw_denmPdu(mw_denm( mw_denmMgmtCon( mw_actionId, -, -, c_duration2)))); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              // Local timers
              timer t_repetition;
              
              // Test component configuration
              f_cfUp();
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent( m_utTriggerEvent( v_situation, m_denmLocation_zeroDelta, c_duration2, c_duration1, c_interval1 ) );
              f_awaitDenMessage(v_expectedDenmInd, v_denmInd);
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expectedDenmInd.msgIn.denm.management.actionID := v_actionId;
              t_repetition.start(2.0 * int2float(c_interval1/1000));
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt { //FIXME rewrite TC
                  [] denmPort.receive(v_expectedDenmInd) -> value v_denmInd {
                      if (match(t_repetition.read*1000.0, (c_lowerTransmissionInterval..c_upperTransmissionInterval))) {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM in the expected interval. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": FAIL: Received expected DENM, interval was not correct. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                      }
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] t_repetition.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();

          } // end TC_DEN_EVRP_BV_09
           
          /**
           * @desc		Check that actionID is not modified in repetitions of DENM if stationID is not modified
           *
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *      	containing repetitionInterval
           *      		indicating INTERVAL_1
           *      	and containing repetitionDuration
           *      		indicating DURATION_1
           *      	and containing validityDuration
           *      		indicating DURATION_2 > DURATION_1
           *      and the IUT having generated the corresponding event
           *      	containing management container
           *      		containing actionID
           *      			indicating ACTION_ID_1
           *      		and containing validityDuration
           *      			indicating DURATION_2
           *      		and containing referenceTime
           *      			indicating REFERENCE_TIME_1
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when { 
           *          the IUT is alerted of expiration of the time associated with INTERVAL_1
           *      }
           *      then {
           *      		the IUT repeats the transmission of the valid DENM
           *      			containing management container
           *      				containing actionID
           *      					indicating its ACTION_ID_1
           *      				and containing referenceTime
           *      					indicating REFERENCE_TIME_1
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-10, ETSI EN 302 637-3, clause 8.2.1.2
           */
          testcase TC_DEN_EVRP_BV_10() runs on ItsDenm system ItsDenmSystem {
              // Local constants
              const ValidityDuration c_duration1 := 3 * c_duration_2sec;
              const ValidityDuration c_duration2 := c_duration_10sec;
              const TransmissionInterval c_interval1 := c_interval_1sec;
              const float c_lowerTransmissionInterval := int2float(c_interval1)*0.95;
              const float c_upperTransmissionInterval := int2float(c_interval1)*1.05;
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expected := mw_denmInd(mw_denmPdu(mw_denm( mw_denmMgmtCon( mw_actionId, -, -, c_duration2 )))); 
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var TimestampIts v_referenceTime;
              // Local timers
              timer t_repetition;
              
              // Test component configuration
              f_cfUp();
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent( m_utTriggerEvent( v_situation, m_denmLocation_zeroDelta, c_duration2, c_duration1, c_interval1 ) );
              f_awaitDenMessage ( v_expected, v_denmInd );
              t_repetition.start(2.0 * int2float(c_interval1/1000));
filatov's avatar
filatov committed
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_referenceTime := v_denmInd.msgIn.denm.management.referenceTime;
              v_expected.msgIn.denm.management.actionID := v_actionId;
              v_expected.msgIn.denm.management.referenceTime := v_referenceTime;
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt { //FIXME rewrite TC
                  [] denmPort.receive ( v_expected ) -> value v_denmInd {
                      if (match(t_repetition.read*1000.0, (c_lowerTransmissionInterval..c_upperTransmissionInterval))) {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": PASS: Successfully received expected DENM in the expected interval. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                          t_repetition.stop;
                          log("*** " & testcasename() & ": FAIL: Received expected DENM, interval was not correct. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                      }
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
filatov's avatar
filatov committed
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] t_repetition.timeout {
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
           * @desc		Check that DEN Basic Service stops retransmitting DENM after event's validityDuration expiration
           *
filatov's avatar
filatov committed
           * <pre>        
           * PICS Selection: none 
           * Initial conditions:
           *  with {
           *      the IUT being in the "initial state"
           *      and the IUT having received an AppDENM_trigger request from application layer
           *      	containing repetitionInterval
           *      		indicating INTERVAL_1
           *      	and containing repetitionDuration
           *      		indicating DURATION_1 > defaultValidityDuration
           *      	and not containing validityDuration
           *      and the IUT having generated the corresponding event
           *      	containing management container
           *      		containing actionID
           *      			indicating ACTION_ID_1
filatov's avatar
filatov committed
           *  }
           * Expected behaviour:
           *  ensure that {
           *      when {
           *          the IUT is alerted of expiration of the defaultValidityDuration
filatov's avatar
filatov committed
           *      }
           *      then {
           *      		the IUT stops the retransmission of the DENM associated with ACTION_ID1
filatov's avatar
filatov committed
           *      }
           *  }
           * </pre>
           * 
           * @version 1.2.1
           * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/EVRP/BV-11, ETSI EN 302 637-3, clause 8.2.1.5
          testcase TC_DEN_EVRP_BV_11() runs on ItsDenm system ItsDenmSystem {
filatov's avatar
filatov committed
              // Local constants
              const ValidityDuration c_duration1 := c_defaultValidity + 100;
              const ValidityDuration c_duration2 := c_defaultValidity;
              const TransmissionInterval c_interval1 := c_interval_10sec;
              const float c_diffValidity := int2float ( ( c_duration1 - c_duration2 ) );
filatov's avatar
filatov committed
              // Local variables
              var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
              var template (present) DenmInd v_expected := mw_denmInd(mw_denmPdu(mw_denm( mw_denmMgmtCon( mw_actionId, -, -, c_duration2)))); 
filatov's avatar
filatov committed
              var ActionID v_actionId;
              var DenmInd v_denmInd;
              var TimestampIts v_referenceTime;
filatov's avatar
filatov committed
              // Local timers
              timer t_repetition;
              timer t_default;
filatov's avatar
filatov committed
              
              // Test component configuration
              f_cfUp();
              
              // Preamble
              f_prInitialState();
              f_utTriggerEvent( m_utTriggerEvent( v_situation, m_denmLocation_zeroDelta, omit, c_duration1, c_interval1 ) );
              f_awaitDenMessage ( v_expected, v_denmInd );
              t_repetition.start(2.0 * int2float(c_interval1/1000));
              t_default.start ( int2float( c_duration1/1000 ) );
filatov's avatar
filatov committed
              v_actionId := v_denmInd.msgIn.denm.management.actionID;
              v_expected.msgIn.denm.management.actionID := v_actionId;
filatov's avatar
filatov committed
              f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
              
              // Test Body
              alt {
                  [] denmPort.receive ( v_expected ) -> value v_denmInd {
                      t_repetition.stop;
                      if ( t_default.read*1000.0 < c_diffValidity ) {
                          log("*** " & testcasename() & ": FAIL: DENM received after validity duration. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                          log("*** " & testcasename() & ": INFO: DENM retransmission. ***");
              			  t_repetition.start(2.0 * int2float(c_interval1/1000));
              			  repeat;
                      }
filatov's avatar
filatov committed
                  }
                  [] denmPort.receive(mw_denmInd(mw_anyDenmPdu)) {
filatov's avatar
filatov committed
                      log("*** " & testcasename() & ": FAIL: Received an unexpected DENM. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
                  }
                  [] t_repetition.timeout {
                      if ( t_default.read*1000.0 < c_diffValidity ) {
                          t_default.stop;
                          log("*** " & testcasename() & ": PASS: Retransmission of DENM stopped. ***");
                          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                      }
                      else {
                          t_default.stop;
                      	  log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      	  f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                      }
                  }
                  [] t_default.timeout {
                      t_repetition.stop;
                      log("*** " & testcasename() & ": INCONC: Timeout while awaiting the reception of a message. ***");
                      f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
filatov's avatar
filatov committed
                  }
              }
              
              // Postamble
              f_poCancelEvent(e_iut, v_actionId);
              f_cfDown();
filatov's avatar
filatov committed
          
      } // end denMessageRepetition
      
    } // end denMessageTransmission
    
    // 5.2.2
    group denMessageReception {
        
        /**
         * @desc    Check that receiving ITS-S transmits DENM to application if it concerns an unknown ActionID and if it is not a termination DENM
         *         
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT not having received DENM
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM that is not a termination
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *      }
         *      then {
         *          the IUT transmits the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-01, ETSI EN 302 637-3, clause 8.4.2
filatov's avatar
filatov committed
         */
        testcase TC_DEN_MSRV_BV_01() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(PX_TAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_01
        
        /**
         * @desc    Check that receiving ITS-S transmits DENM to application if it concerns a known ActionID 
filatov's avatar
filatov committed
         *          and referenceTime is greater than highest value received for this ActionID
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received DENM
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing referenceTime
         *                  indicating  REFERENCETIME_1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *                  and containing referenceTime
         *                      indicating REFERENCETIME_2 greater than REFERENCETIME_1

         *      }
         *      then {
         *          the IUT transmits the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-02, ETSI EN 302 637-3, clause 8.4.2
filatov's avatar
filatov committed
         */
        testcase TC_DEN_MSRV_BV_02() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation1 := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var template (value) SituationContainer v_situation2 := m_situation(c_causeVehicleBreakdown, c_vehicleBreakDownSubCauseCode_engineProblem);
            var TimestampIts v_referenceTime2;
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId
                    ),
                    v_situation1,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(1.0);
            v_referenceTime2 := f_getCurrentTime();
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        v_actionId,
                        -, -, -, 
                        v_referenceTime2
filatov's avatar
filatov committed
                    ),
                    v_situation2,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(PX_TAC);
            for(i:=0; i < lengthof(vc_utEvents) 
                      and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID)
                      and vc_utEvents[i].denMsg.denm.management.referenceTime != v_referenceTime2; i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_02
                
        /**
         * @desc    Check that receiving ITS-S discards termination DENM if it concerns an unknown ActionID (own actionID)
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received several events
         *      and the IUT not having received DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a termination DENM
         *              containing actionID
         *                  indicating ACTION_ID1
         *      }
         *      then {
         *          the IUT discards the DENM
         *          and the IUT does not forward the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-03, ETSI EN 302 637-3, clause 8.3.2
         */
        testcase TC_DEN_MSRV_BV_03() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
filatov's avatar
filatov committed
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": FAIL: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            else {
                log("*** " & testcasename() & ": PASS: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_03
        
        /**
         * @desc    Check that receiving ITS-S discards termination DENM if it concerns an unknown ActionID (other actionID)
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: none 
         * Initial conditions:
         *  with {
         *      and the IUT having received several events
         *      and the IUT not having received DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a termination DENM
         *              containing actionID
         *                  indicating ACTION_ID1
         *      }
         *      then {
         *          the IUT discards the DENM
         *          and the IUT does not forward the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-04, ETSI EN 302 637-3, clause 8.3.2
         */
        testcase TC_DEN_MSRV_BV_04() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId, v_actionIdIut;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            v_actionId := f_utTriggerEvent(m_utTriggerEvent(v_situation, m_denmLocation_zeroDelta));
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionIdIut := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_actionId(
                            f_increaseSequenceNumber(v_actionId.sequenceNumber)
filatov's avatar
filatov committed
                        ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID); i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": FAIL: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            else {
                log("*** " & testcasename() & ": PASS: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            
            // Postamble
            f_poCancelEvent(e_iut, v_actionIdIut);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_04
        
        /**
         * @desc    Check that receiving ITS-S discards DENM if referenceTime is lower than highest value received for this ActionID
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received DENM
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing referenceTime
         *                  indicating REFERENCETIME_1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *                  and containing referenceTime
         *                      indicating REFERENCETIME_2 lower than REFERENCETIME_1
         *      }
         *      then {
         *          the IUT discards the DENM
         *          and the IUT does not forward the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-05, ETSI EN 302 637-3, clause 8.3.2
         */
        testcase TC_DEN_MSRV_BV_05() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation1 := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var template (value) SituationContainer v_situation2 := m_situation(c_causeVehicleBreakdown, c_vehicleBreakDownSubCauseCode_engineProblem);
            var TimestampIts v_referenceTime1 := f_getCurrentTime();
            var TimestampIts v_referenceTime2 := v_referenceTime1 - 1000;
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -, -, -, v_referenceTime1
filatov's avatar
filatov committed
                    ),
                    v_situation1,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(1.0);
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        v_actionId,
                        -, -, -, 
                        v_referenceTime2
                    ),
                    v_situation2,
                    m_denmLocation_zeroDelta
                )
            );
filatov's avatar
filatov committed
            
            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) 
                      and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID)
                      and vc_utEvents[i].denMsg.denm.management.referenceTime != v_referenceTime2; i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": FAIL: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            else {
                log("*** " & testcasename() & ": PASS: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_05
        
        /**
         * @desc    Check that receiving ITS-S discards DENM if detectionTime is smaller than highest value received for this ActionID
         *          
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received DENM
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing referenceTime
         *                  indicating REFERENCETIME_1
         *              and containing detectionTime
         *                  indicating TIME_1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *                  and containing referenceTime
         *                      indicating REFERENCETIME_1
         *                  and containing detectionTime
         *                      indicating TIME_2 not more recent than TIME_1
         *      }
         *      then {
         *          the IUT discards the DENM
         *          and the IUT does not forward the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-06, ETSI EN 302 637-3, clause 8.3.2
         */
        testcase TC_DEN_MSRV_BV_06() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation1 := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var template (value) SituationContainer v_situation2 := m_situation(c_causeVehicleBreakdown, c_vehicleBreakDownSubCauseCode_engineProblem);
            var template (value) DecentralizedEnvironmentalNotificationMessage v_denm;
            var TimestampIts v_detectionTime1 := f_getCurrentTime();
            var TimestampIts v_detectionTime2 := v_detectionTime1 - 1000;
            var TimestampIts v_referenceTime1 := v_detectionTime1;
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_denm := m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
filatov's avatar
filatov committed
                        v_detectionTime1,
                        v_referenceTime1
                    ),
                    v_situation1,
                    m_denmLocation_zeroDelta
                );
            v_actionId := f_sendDenMessage(v_denm);
            
            f_sleep(1.0);
            v_detectionTime2 := valueof(v_denm.management.detectionTime) - 1000;
filatov's avatar
filatov committed
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        v_actionId,
                        -, - ,-, 
                        v_detectionTime2, 
                        v_referenceTime1
                    ),
                    v_situation2,
                    m_denmLocation_zeroDelta
                )
            );
            
filatov's avatar
filatov committed
            f_sleep(PX_TNOAC);
            for(i:=0; i < lengthof(vc_utEvents) 
                      and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID)
                      and vc_utEvents[i].denMsg.denm.management.detectionTime != v_detectionTime2; i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": FAIL: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            else {
                log("*** " & testcasename() & ": PASS: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_06
        
        /**
         * @desc    Check that receiving ITS-S transmits DENM to application if it concerns a known ActionID and referenceTime 
filatov's avatar
filatov committed
         *          is equal to highest received value and detectionTime is more recent
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received DENM
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing referenceTime
         *                  indicating REFERENCETIME_1
         *              and containing detectionTime
         *                  indicating TIME_1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *                  and containing referenceTime
         *                      indicating REFERENCETIME_1
         *                  and containing detectionTime
         *                      indicating TIME_2 more recent than TIME_1
         *      }
         *      then {
         *          the IUT transmits the DENM content to upper layer
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-07, ETSI EN 302 637-3, clause 8.3.2
         */
        testcase TC_DEN_MSRV_BV_07() runs on ItsDenm system ItsDenmSystem {
            
            // Local variables
            var template (value) SituationContainer v_situation1 := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var template (value) SituationContainer v_situation2 := m_situation(c_causeVehicleBreakdown, c_vehicleBreakDownSubCauseCode_engineProblem);
            var template (value) DecentralizedEnvironmentalNotificationMessage v_denm;
            var TimestampIts v_detectionTime2 := f_getCurrentTime();
            var TimestampIts v_detectionTime1 :=v_detectionTime2 - 1000;
            var TimestampIts v_referenceTime1 := v_detectionTime2;
            var ActionID v_actionId;
            var integer i;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_denm := m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
filatov's avatar
filatov committed
                        v_detectionTime1,
                        v_referenceTime1
                    ),
                    v_situation1,
                    m_denmLocation_zeroDelta
                );            
            v_actionId := f_sendDenMessage(v_denm);
            
            f_sleep(1.0);
            v_detectionTime2 := valueof(v_denm.management.detectionTime) + 1000;
filatov's avatar
filatov committed
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        v_actionId,
filatov's avatar
filatov committed
                        v_detectionTime2,
                        v_referenceTime1
                    ),
                    v_situation2,
                    m_denmLocation_zeroDelta
                )
            );
            
            f_sleep(PX_TAC);
            for(i:=0; i < lengthof(vc_utEvents) 
                      and not match(v_actionId, vc_utEvents[i].denMsg.denm.management.actionID)
                      and vc_utEvents[i].denMsg.denm.management.detectionTime != v_detectionTime2; i:=i+1) {
                // empty on purpose 
            }
            if(i < lengthof(vc_utEvents)) {
                log("*** " & testcasename() & ": PASS: DENM was transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_success);
            }
            else {
                log("*** " & testcasename() & ": FAIL: DENM was not transmitted to upper layer ***");
                f_clientSyncAndVerdict(c_tbDone, e_error);
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_MSRV_BV_07
        
        /**
         * @desc    Check that receiving ITS-S replies to requestResponseIndication
         *          
         * <pre>
         * PICS Selection: none
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT receives a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *              and containing alacarte container
         *                  containing ImpactReductionContainer
         *                  	containing requestResponseIndication
         *                      	indicating request(0)
         *      }
         *      then {
         *          the IUT sends a DENM
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID2
         *              and containing alacarte container
         *                  containing ImpactReductionContainer
         *                  	containing requestResponseIndication
         *                      	indicating response(1)
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/MSRV/BV-10, ETSI EN 302 637-3, clause B.40
         */
        testcase TC_DEN_MSRV_BV_10() runs on ItsDenm system ItsDenmSystem {

            //Local constants

            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test component configuration
            f_cfUp();
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage (
                m_denm ( m_denmMgmtCon ( m_tsActionId), v_situation, m_denmLocation_zeroDelta, m_alacarteConImpactReduction ) );
            
            tc_ac.start;
            alt {
                [] denmPort.receive ( mw_denmInd ( mw_denmPdu ( mw_denm ( mw_denmMgmtCon ( mw_actionId ( f_getTsStationId() ) ), v_situation, mw_anyDenmLocation, 
                																						 mw_alacarteConImpactReduction ) ) ) ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM with correct alacarte container ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive ( mw_denmInd ( mw_denmPdu ( mw_denm ( mw_denmMgmtCon ( mw_actionId ( f_getTsStationId() ) ) ) ) ) ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM with incorrect containers ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM not rreceived ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();

        } // end TC_DEN_MSRV_BV_10
        
filatov's avatar
filatov committed
    } // end denMessageReception
    
    // 5.2.3
    group denKeepAliveForwarding {

        /**
         * @desc    Check that forwarding ITS-S forwards DENM if no DENM with same ActionId has been received during forwarding delay
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *          and the IUT having received a DENM
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing transmissionInterval
         *                  indicating TRANS_INTERVAL1
         *              and containing validityDuration
         *                  indicating value more than 3 times greater than TRANS_INTERVAL1
         *          and the IUT having starting timer T_Forwarding for this DENM
         *          and the IUT not having received further DENM 
         *              containing actionID
         *                  indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-01, ETSI EN 302 637-3, clause 8.2.2
         */
        testcase TC_DEN_KAFW_BV_01() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            // Local timers
            timer t_forwarding := 2.0 * int2float(c_transmissionInterval) / 1000.0;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            t_forwarding.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    if(t_forwarding.running) {
                        t_forwarding.stop;
                        log("*** " & testcasename() & ": FAIL: IUT re-forwarded the packet too early ***");
                        f_clientSyncAndVerdict(c_tbDone, e_error);
                    }
                    else {
                        tc_ac.stop;
                        log("*** " & testcasename() & ": PASS: DENM re-forwarded ***");
                        f_clientSyncAndVerdict(c_tbDone, e_success);
                    }
                }
                [] t_forwarding.timeout {
                    tc_ac.start;
                    log("*** " & testcasename() & ": INFO: Ready for receiving re-forwarded DENM ***");
                    repeat;
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": FAIL: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_01
        
        /**
         * @desc    Check that forwarding ITS-S forwards DENM if no DENM with same ActionId and referenceTime greater 
filatov's avatar
filatov committed
         *          or equal to the last received DENM has been received during forwarding delay
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing referenceTime
         *              indicating REFERENCETIME_1
         *          and containing validityDuration
         *              indicating value more than 3 times greater than TRANS_INTERVAL1
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT having received DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing referenceTime
         *              indicating value REFERENCETIME_2 < REFERENCETIME_1
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing referenceTime
         *              indicating value REFERENCETIME_3 > REFERENCETIME_1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-02, ETSI EN 302 637-3, clause 8.2.2
         */
        testcase TC_DEN_KAFW_BV_02() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var TimestampIts v_referenceTime1 := f_getCurrentTime();
            var TimestampIts v_referenceTime2 := v_referenceTime1 - 1000;
            var ActionID v_actionId;
            // Local timers
            timer t_forwarding := 2.0 * int2float(c_transmissionInterval) /1000.0;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval,
                        v_referenceTime1
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            t_forwarding.start;
            f_sleep(5.0);
            
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval,
                        v_referenceTime2
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId, v_referenceTime1)
                            )
                        )
                    ) 
                ) {
                    if(t_forwarding.running) {
                        t_forwarding.stop;
                        log("*** TC_DEN_KAFW_BV_02: INFO: IUT re-forwarded the packet too early ***");
                    }
                    else {
                        tc_ac.stop;
                        log("*** TC_DEN_KAFW_BV_02: PASS: DENM re-forwarded ***");
                    }  
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    t_forwarding.stop;
                    log("*** " & testcasename() & ": FAIL: IUT re-forwarded wrong version of DENM ***");
                }
                [] t_forwarding.timeout {
                    tc_ac.start;
                    log("*** " & testcasename() & ": INFO: Ready for receiving re-forwarded DENM ***");
                    repeat;
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": FAIL: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);  
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_02
                
        /**
         * @desc    Check that forwarding delay is set to min(2*transmissionInterval + rnd(0, 150ms), validityDuration)
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing validityDuration
         *              indicating value DURATION_1 more than 3 times greater than TRANS_INTERVAL1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1 at a point of time corresponding to
         *          min ( 2*transmissionInterval + rnd ( 0, 150ms ), validityDuration )
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-03, ETSI EN 302 637-3, clause 8.2.1.4
         */
        testcase TC_DEN_KAFW_BV_03() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            // Local timers
            timer t_forwardingMin := 2.0 * int2float(c_transmissionInterval) / 1000.0;
            timer t_forwardingMax := 2.0 * int2float(c_transmissionInterval) / 1000.0 + 0.15;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            t_forwardingMin.start;
            t_forwardingMax.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) { 
                    t_forwardingMax.stop;
                    if(t_forwardingMin.running) {
                        t_forwardingMin.stop;
                        log("*** " & testcasename() & ": FAIL: IUT re-forwarded the packet too early ***");
                        f_clientSyncAndVerdict(c_tbDone, e_error);
                    }
                    else {
                        log("*** " & testcasename() & ": PASS: DENM re-forwarded correctly ***");
                        f_clientSyncAndVerdict(c_tbDone, e_success);
                    }  
                }
                [] t_forwardingMin.timeout {
                    log("*** " & testcasename() & ": INFO: Ready for receiving re-forwarded DENM ***");
                    repeat;   
                }
                [] t_forwardingMax.timeout {
                    log("*** " & testcasename() & ": FAIL: DENM was not forwarded on time ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);  
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_03

        /**
         * @desc    Check that Forwarding ITS-S replaces the ITS PDU header of forwarded DENMs
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing validityDuration
         *              indicating value more than 3 times greater than TRANS_INTERVAL1
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *              containing ITS PDU header
         *                  containing StationID
         *                      indicating its own stationID
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-04, ETSI EN 302 637-3, clause 8.2.1.6
         */
        testcase TC_DEN_KAFW_BV_04() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            ),
                            f_getIutStationId()
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM re-forwarded with correct stationID ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            ),
                            mw_anyStationId
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect stationID ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_04

        /**
         * @desc    Check that forwarding ITS-S does not change actionID
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing validityDuration
         *              indicating value more than 3 times greater than TRANS_INTERVAL1
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM 
         *              containing management container
         *                  containing actionID
         *                      indicating ACTION_ID1
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-05, ETSI EN 302 637-3, clause 8.2.1.1
         */
        testcase TC_DEN_KAFW_BV_05() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM re-forwarded with correct actionID ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(mw_anyActionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect actionID ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_05
        
        /**
         * @desc    Check that forwarding ITS-S does not change referenceTime
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing validityDuration
         *              indicating value DURATION_1 more than 3 times greater than TRANS_INTERVAL1
         *          and containing referenceTime
         *              indicating REFERENCETIME_1
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *              containing management container
         *                  containing referenceTime
         *                      indicating REFERENCETIME_1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-06, ETSI EN 302 637-3, clause 8.2.1.2
         */
        testcase TC_DEN_KAFW_BV_06() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var TimestampIts v_referenceTime1 := f_getCurrentTime();
            var ActionID v_actionId;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval,
                        v_referenceTime1
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId, v_referenceTime1)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM re-forwarded with correct referenceTime ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect referenceTime ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_06

        /**
         * @desc    Check that forwarding ITS-S does not change termination
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing actionID
         *              indicating ACTION_ID1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
         *          and containing validityDuration
         *              indicating value DURATION_1 more than 3 times greater than TRANS_INTERVAL1
         *          and containing termination
         *              indicating isNegation
filatov's avatar
filatov committed
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *              containing management container
         *                  containing termination
         *                      indicating isNegation
filatov's avatar
filatov committed
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-07, ETSI EN 302 637-3, clause 8.2.1.3
         */
        testcase TC_DEN_KAFW_BV_07() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(
                                    v_actionId
filatov's avatar
filatov committed
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM re-forwarded with correct isNegation ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(
                                    v_actionId
filatov's avatar
filatov committed
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect isNegation ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_07

        /**
         * @desc    Check that Forwarding ITS-S does not modify management, situation, location and alacarte containers 
filatov's avatar
filatov committed
         *          when forwarding a DENM
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received a DENM
         *          containing management container
         *              indicating MANACEMENTCONTAINER_1
         *          and containing situation container
         *              indicating SITUATION_1
         *          and containing location container
         *              indicating LOCATION_1
         *          and containing alacarte container
         *              indicating ALACARTE_1
         *          and containing transmissionInterval
         *              indicating TRANS_INTERVAL1
filatov's avatar
filatov committed
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the timer T_Forwarding expires
         *      }
         *      then {
         *          the IUT reconstructs and sends the DENM associated to ACTION_ID1
         *              containing management container
         *                  indicating MANACEMENTCONTAINER_1
         *              and containing situation container
         *                  indicating SITUATION_1
         *              and containing location container
         *                  indicating LOCATION_1
         *              and containing alacarte container
         *                  indicating ALACARTE_1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-08, ETSI EN 302 637-3, clause 8.2.1.6
         */
        testcase TC_DEN_KAFW_BV_08() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta,
                    m_alacarteConLaneCount
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId),
                                v_situation,
                                m_denmLocation_zeroDelta,
                                m_alacarteConLaneCount
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": PASS: DENM re-forwarded with correct containers ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect containers ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                [] tc_ac.timeout {
                    log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                    f_clientSyncAndVerdict(c_tbDone, e_timeout);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_08

        /**
         * @desc    Check that forwarding ITS-S stops forwarding DENM after validity expiration
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received an event
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *              and containing validityDuration
         *                  indicating DURATION_1
         *          	and containing transmissionInterval
         *              	indicating TRANS_INTERVAL1
filatov's avatar
filatov committed
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT is alerted of expiration of the time associated with DURATION_1
         *      }
         *      then {
         *          the IUT stops to reconstruct and to send the DENM associated with ACTION_ID1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-09, ETSI EN 302 637-3, clause 8.2.2
         */
        testcase TC_DEN_KAFW_BV_09() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            // Local timers
            timer t_validity := int2float(c_transmissionInterval * 3) / 1000.0;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 3,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            t_validity.start;
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    if(t_validity.running) {
                        log("*** " & testcasename() & ": INFO: DENM re-forwarded during validity period ***");
                        tc_ac.start;
                        repeat;
                    }
                    else {
                        log("*** " & testcasename() & ": FAIL: DENM re-forwarded after validity expiration ***");
                        f_clientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                [] tc_ac.timeout {
                    if(t_validity.running) {
                        log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                        f_clientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                    else {
                        log("*** " & testcasename() & ": PASS: DENM not reforwarded after validity expiration ***");
                        f_clientSyncAndVerdict(c_tbDone, e_success);
                    }
                }
                
                [] t_validity.timeout {
                    log("*** " & testcasename() & ": INFO: End of validity period ***");
                    repeat;
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_09
                                  
        /**
         * @desc    Check that forwarding ITS-S stops forwarding DENM if it is outside relevance area
filatov's avatar
filatov committed
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *      and the IUT having received an event
         *          containing management container
         *              containing actionID
         *                  indicating ACTION_ID1
         *          	and containing transmissionInterval
         *              	indicating TRANS_INTERVAL1
filatov's avatar
filatov committed
         *      and the IUT having starting timer T_Forwarding for this DENM
         *      and the IUT not having received further DENM 
         *          containing actionID
         *              indicating ACTION_ID1
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when { 
         *          the IUT is alerted that its position is now outside of the relevance area associated with ACTION_ID1
         *      }
         *      then {
         *          the IUT stops to reconstruct and to send the DENM associated with ACTION_ID1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-10, ETSI EN 302 637-3, clause 8.2.2
         */
        testcase TC_DEN_KAFW_BV_10() runs on ItsDenm system ItsDenmSystem {
            
            //Local constants
            const TransmissionInterval c_transmissionInterval := c_interval_10sec;
filatov's avatar
filatov committed
            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            var boolean v_positionChanged := false;
            
            // Test control
            
            // Test component configuration
            f_cfUp();
            
            // Test adapter configuration
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage(
                m_denm(
                    m_denmMgmtCon(
                        m_tsActionId,
                        -,
                        c_transmissionInterval * 5,
                        c_transmissionInterval
                    ),
                    v_situation,
                    m_denmLocation_zeroDelta
                )
            );
            
            tc_ac.start;
            alt {
                [] denmPort.receive(
                    mw_denmInd(
                        mw_denmPdu(
                            mw_denm(
                                mw_denmMgmtCon(v_actionId)
                            )
                        )
                    ) 
                ) {
                    tc_ac.stop;
                    if(v_positionChanged == false) {
                        log("*** " & testcasename() & ": INFO: DENM re-forwarded. Changing position ***");
                        f_utChangePosition(m_utChangePosition(1000, 0));
                        v_positionChanged := true;
                        tc_ac.start;
                        repeat;
                    }
                    else {
                        log("*** " & testcasename() & ": FAIL: DENM re-forwarded with incorrect containers ***");
                        f_clientSyncAndVerdict(c_tbDone, e_error);
                    }
                }
                [] tc_ac.timeout {
                    if(v_positionChanged == false) {
                        log("*** " & testcasename() & ": INCONC: DENM was not forwarded ***");
                        f_clientSyncAndVerdict(c_tbDone, e_timeout);
                    }
                    else {
                        log("*** " & testcasename() & ": PASS: DENM stopped re-forwarding DENM ***");
                        f_clientSyncAndVerdict(c_tbDone, e_success);
                    }
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();
            
        } // end TC_DEN_KAFW_BV_10
        
        /**
         * @desc    Check that forwarding ITS-S does not forward DENM is transmissionInterval is not present
         * <pre>
         * PICS Selection: PICS_KAF 
         * Initial conditions:
         *  with {
         *      the IUT being in the "initial state"
         *  }
         * Expected behaviour:
         *  ensure that {
         *      when {
         *          the IUT receives a DENM
         *          	containing actionID
         *          		indicating ACTION_ID1
         *          	and not containing transmissionInterval
         *      }
         *      then {
         *          the IUT does not reconstruct and send the DENM associated with ACTION_ID1
         *      }
         *  }
         * </pre>
         * 
         * @version 1.2.1
         * @see     ETSI TS 102 869-2 v1.2.1 TP/DEN/KAFW/BV-10, ETSI EN 302 637-3, clause 8.2.2
         */
        testcase TC_DEN_KAFW_BV_11() runs on ItsDenm system ItsDenmSystem {

            // Local variables
            var template (value) SituationContainer v_situation := m_situation(c_causeVehicleBreakdown, c_subCauseCode_Unavailable);
            var ActionID v_actionId;
            
            // Test component configuration
            f_cfUp();
            
            // Preamble
            f_prInitialState();
            f_selfOrClientSyncAndVerdictPreamble(c_prDone, e_success);
            
            // Test Body
            v_actionId := f_sendDenMessage( m_denm ( m_denmMgmtCon ( m_tsActionId ), v_situation, m_denmLocation_zeroDelta ) );
            
            tc_ac.start;
            alt {
                []  denmPort.receive ( mw_denmInd ( mw_denmPdu ( mw_denm ( mw_denmMgmtCon ( v_actionId ) ) ) ) ) {
                    tc_ac.stop;
                    log("*** " & testcasename() & ": FAIL: IUT reconstructs and sends the DENM associated with ACTION_ID ***");
                    f_clientSyncAndVerdict(c_tbDone, e_error);
                }
                []  tc_ac.timeout {
                    log("*** " & testcasename() & ": PASS: IUT does not reconstruct and send the DENM associated with ACTION_ID1 ***");
                    f_clientSyncAndVerdict(c_tbDone, e_success);
                }
            }
            
            // Postamble
            f_poCancelEvent(e_ets, v_actionId);
            f_cfDown();

        } // end TC_DEN_KAFW_BV_11
        
filatov's avatar
filatov committed
    } // end denKeepAliveForwarding
    
} // end ItsDenm_TestCases