Newer
Older
* @desc Module containing functions for DENM
*
*/
// LibCommon
import from LibCommon_Sync all;
import from LibCommon_VerdictControl all;
import from LibCommon_Time {
modulepar PX_TNOAC;
function f_sleep
};
import from LibItsCommon_TypesAndValues all;
import from LibItsDenm_TypesAndValues all;
import from LibItsDenm_Templates all;
import from DENM_PDU_Descriptions language "ASN.1:1997" all;
group utFuntions {
/**
* @desc Requests to bring the IUT in an initial state
* @param p_init The initialisation to trigger.
*/
function f_utInitializeIut(template (value) UtInitialize p_init) runs on ItsDenm {
utPort.send(p_init);
tc_wait.start;
alt {
[] tc_wait.timeout {
log("*** " & __SCOPE__ & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
[else] { // Shortcut defaults
repeat;
}
}
* @desc Triggers an event from the application layer
function f_utTriggerEvent(template (value) UtDenmTrigger p_event) runs on ItsDenm return ActionID {
[] utPort.receive(UtDenmTriggerResult:?) -> value v_result {
}
[] utPort.receive {
tc_wait.stop;
f_selfOrClientSyncAndVerdict("DENM Trigger failed", e_timeout);
[] tc_wait.timeout {
log("*** " & __SCOPE__ & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
[else] { // Shortcut defaults
repeat;
}
* @desc Updates an event at the application layer
* @param p_event The event to update.
function f_utUpdateEvent(template (value) UtDenmUpdate p_event) runs on ItsDenm return ActionID {
[] utPort.receive(UtDenmUpdateResult:?) -> value v_result {
[] tc_wait.timeout {
log("*** " & __SCOPE__ & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
[else] { // Shortcut defaults
repeat;
}
}
return v_actionId;
}
/**
* @desc Terminates an event at the application layer
* @param p_event The event to terminate.
*/
function f_utTerminateEvent(template (value) UtDenmTermination p_event) runs on ItsDenm {
[] utPort.receive(UtDenmTerminationResult:?) {
[] tc_wait.timeout {
log("*** " & __SCOPE__ & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
[else] { // Shortcut defaults
repeat;
}
/**
* @desc Changes the position of the IUT
* @param p_latitude
* @param p_longitude
* @param p_elevation
*/
function f_utChangePosition(template (value) UtChangePosition p_position) runs on ItsDenm {
utPort.send(p_position);
alt {
[] utPort.receive(UtChangePositionResult:?) {
tc_wait.stop;
}
[] tc_wait.timeout {
log("*** " & __SCOPE__ & ": INFO: Could not receive expected UT message from IUT in time ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
}
[else] { // Shortcut defaults
repeat;
}
/**
* @desc Setups default configuration
*/
map(self:utPort, system:utPort);
map(self:denmPort, system:denmPort);
f_connect4SelfOrClientSync();
} // end f_cfUp
/**
* @desc Deletes default configuration
*/
f_disconnect4SelfOrClientSync();
} // end f_cfDown
group altsteps {
/**
* @desc The base default.
*/
[] denmPort.receive(mw_denmInd(mw_denmPdu(mw_anyDenm))) {
log("*** " & __SCOPE__ & ": INFO: DENM message received in default ***");
log("*** " & __SCOPE__ & ": ERROR: Received an unexpected message ***");
log("*** " & __SCOPE__ & ": INCONC: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
log("*** " & __SCOPE__ & ": INCONC: Timeout while awaiting the reception of a message ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
[] a_shutdown() {
f_poDefault();
f_cfDown();
log("*** " & __SCOPE__ & ": INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
* @desc The default for handling upper tester messages.
var UtDenmEventInd v_event;
[] utPort.receive(UtDenmEventInd:?) -> value v_event {
vc_utEvents[lengthof(vc_utEvents)] := v_event;
repeat;
}
[] utPort.receive {
tc_wait.stop;
log("*** " & __SCOPE__ & ": INFO: Received unexpected UT message from IUT ***");
f_selfOrClientSyncAndVerdict("error", e_error);
}
}
} // end group altsteps
group preambles {
/**
* @desc The default preamble.
*/
function f_prInitialState() runs on ItsDenm return FncRetCode {
return v_ret;
}
} // end group preambles
group postambles {
/**
* @desc The default postamble.
*/
var FncRetCode v_ret := e_success;
//empty
}
/**
* @desc Postamble including cancellation of an event.
berge
committed
* @param p_trigger Indicates if the cancellation have to be raised by the test system(e_ets)
* or at the application layer of the IUT(e_iut).
* @param p_actionId The action ID of the event to be cancelled
function f_poCancelEvent(template (value) Trigger p_trigger, template (value) ActionID p_actionId)
f_utTerminateEvent(m_utEventCancellation(p_actionId));
}
f_poDefault();
}
} // end group postambles
group sendFunctions {
/**
* @desc Sends a DEN message
* @param p_sendMsg The DEN message to send.
*/
function f_sendDenMessage(template (value) DecentralizedEnvironmentalNotificationMessage p_denm) runs on ItsDenm return ActionID {
p_denm.management.actionID.sequenceNumber := vc_sequenceNo;
denmPort.send(
m_denmReq(
m_denmPdu(
p_denm
)
)
);
}
} // end sendFunctions
group receiveFunctions {
/**
* @param p_rcvMsg The expected message to be received.
* @param p_rcvdMsg The received message - OUT.
*/
function f_awaitDenMessage(in template (present) DenmInd p_rcvMsg, out DenmInd p_rcvdMsg) runs on ItsDenm {
log("*** " & __SCOPE__ & ": INFO: Timeout while awaiting the reception of a message ***");
f_selfOrClientSyncAndVerdict("error", e_timeout);
/**
* @desc Increases the sequence number and handles the special case where the
* sequence number reaches the limit of 65535 and will be reset to 0.
* @param p_sequenceNumber The sequence number to increase.
* @return The increased sequence number.
*/
function f_increaseSequenceNumber(in SequenceNumber p_sequenceNumber) return SequenceNumber {
// if maximum number of 65535 reached, reset it to 0
return ((p_sequenceNumber + 1) mod 65536);
}
} // end group miscellaneousFunctions