Commit 76a82e69 authored by predusi's avatar predusi
Browse files

the RSU component is sending the NrOfEmptyMsg to OBU for the verdict. Added a...

the RSU component is sending the NrOfEmptyMsg to OBU for the verdict. Added a test case which is showing min/max  transaction .
parent 6b70a204
Loading
Loading
Loading
Loading
+63 −13
Original line number Diff line number Diff line
module MainModule {
    import from TraceParserSystem all;

    function f_obuBehaviour() runs on ObuType {
    function f_obuBehaviour(inout integer p_tranDuration) runs on ObuType {
        var address v_ts := 0;
        var integer v_startTS := 0;
        var template (present) LinkId v_linkId := ?;
        var boolean v_receivedLinkId := false;
        var NrOfEmptyMsg v_nrOfEmptyMsg := 0;
        

        transactionOBUTimer.start;
@@ -28,11 +29,28 @@ module MainModule {
                // inform the rsu component 
                transactionOBUTimer.stop;
                compPort.send(m_stop);
                if (v_ts - v_startTS <= 100000) {
                    setverdict (pass, "Transaction finished in " & int2str(v_ts - v_startTS) & "µs");
                
                alt{
                    [] compPort.receive(NrOfEmptyMsg :?) -> value v_nrOfEmptyMsg;
                    
                    [] compPort.receive {
                        transactionOBUTimer.stop;
                        setverdict(fail, "Unexpected message received");
                        stop;
                    }
                    [] transactionOBUTimer.timeout {
                        setverdict (inconc, "No NrOfEmptyMsg was received from RSU");
                        stop;
                    }                    
                }
                
                
                p_tranDuration := v_ts - v_startTS;
                if (p_tranDuration <= 100000) {
                    setverdict (pass, "Transaction finished in " & int2str(p_tranDuration) & " The Number of empty messages received: " & int2str(v_nrOfEmptyMsg));
                }
                else {
                    setverdict (fail, "Transaction finished in more than 100ms! (" & int2str(v_ts - v_startTS) & "µs)");
                    setverdict (fail, "Transaction finished in more than 100ms (" & int2str(p_tranDuration) & ")");
                }
                stop;
            }
@@ -65,7 +83,7 @@ module MainModule {
    function f_rsuBehaviour() runs on RsuType {
        var boolean v_sentLinkId := false;
        var PayloadStructure v_msg;
        var integer v_cntEmpty := 0;
        var NrOfEmptyMsg v_cntEmpty := 0;
        var template (present) LinkId v_linkId := ?;
        timer t_rsuTimer := 5.0;
        
@@ -93,6 +111,7 @@ module MainModule {
                stop;
            }
            []compPort.receive(m_stop) {
                compPort.send(v_cntEmpty);
                if (v_cntEmpty <= PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
                    setverdict (pass, "Number of received empty frames : " & int2str(v_cntEmpty));
                }
@@ -100,6 +119,7 @@ module MainModule {
                    setverdict (fail, "Maximum number of received empty frames exceeded! (" 
                                      & int2str(v_cntEmpty) & " > " & int2str(PX_MAX_NUM_EMPTY_UPLINK_FRAMES) & ")");
                }
                stop;
            }
            []t_rsuTimer.timeout{
                setverdict(inconc, "No RSU messaged received");
@@ -108,6 +128,9 @@ module MainModule {
        }
    }

    /**
     * @desc This test case is seting the trace file and counts the number of transaction 
     */
    testcase TC_Initialization(inout integer p_nrOfTransactions) runs on MtcType system SystemType {
        
        map(mtc:controlPort, system:controlPort);
@@ -142,7 +165,10 @@ module MainModule {
        
    }

    testcase TC_AnalyzesTrace(inout integer p_traceIndex) runs on MtcType system SystemType {
    /**
     * @desc This test case analizes a transaction, it's duration and the number of empty messages received from RSU 
     */
    testcase TC_AnalyzesTrace(inout integer p_traceIndex, inout integer p_tranDuration) runs on MtcType system SystemType {
        var ObuType obuComponent := ObuType.create("OBU"); //DL
        var RsuType rsuComponent := RsuType.create("RSU"); //UL
        
@@ -151,7 +177,7 @@ module MainModule {
        map(rsuComponent:rsuPort, system:msgPort);
        connect(obuComponent:compPort, rsuComponent:compPort);
        
        obuComponent.start(f_obuBehaviour());
        obuComponent.start(f_obuBehaviour(p_tranDuration));
        rsuComponent.start(f_rsuBehaviour());
        
        log ("Starting analysis of trace: " & int2str(p_traceIndex));
@@ -181,13 +207,37 @@ module MainModule {
        
            
    }
    
    testcase TC_LogAnalyzesTrace(inout integer p_shortestTransDuration, inout integer p_shortestTransIndex, inout integer p_longestTransDuration, inout integer p_longestTransIndex) runs on MtcType system SystemType {
        setverdict(pass, "The shortest transaction was transaction: " & int2str(p_shortestTransIndex) & " and took " & int2str(p_shortestTransDuration) & " seconds"  & " The longest transaction was transaction: " & int2str(p_longestTransIndex) & " and took " & int2str(p_longestTransDuration)& " seconds") ;
    } 
    
    control {
        var integer v_nrOfTransactions := 0;
        var integer v_longestTransDuration := 0;
        var integer v_longestTransIndex := -1;
        var integer v_shortestTransDuration := 0;
        var integer v_shortestTransIndex := -1;
        var integer v_tranDuration := 0;
        
        execute(TC_Initialization(v_nrOfTransactions));
        for(var integer i:=0; i<v_nrOfTransactions; i:=i + 1) {
            execute(TC_AnalyzesTrace(i));
            execute(TC_AnalyzesTrace(i, v_tranDuration));
            if (v_shortestTransDuration==0) {
                v_shortestTransDuration := v_tranDuration
            }
            if(v_shortestTransDuration > v_tranDuration){
                log("short v_tranDuration" & int2str(v_tranDuration));
                v_shortestTransDuration := v_tranDuration;
                v_shortestTransIndex := i;
            }else if(v_longestTransDuration < v_tranDuration){
                log(" long v_tranDuration" & int2str(v_tranDuration));
                v_longestTransDuration := v_tranDuration;
                v_longestTransIndex := i;
            }
        }
        execute(TC_Trace_File_Summary(v_nrOfTransactions));
        execute(TC_LogAnalyzesTrace(v_shortestTransDuration, v_shortestTransIndex, v_longestTransDuration, v_longestTransIndex));
    }
    
}
 No newline at end of file