Commit a7a4a8f9 authored by predusi's avatar predusi
Browse files

-- changed the name of the components, ports, timer etc from obu to rsu and from rsu to obu.

-- changed the verdict from fail to inconc when an unexpected message is received.
-- ignore the pass verdict of the obu component so that the verdict message is always the same
parent 96e1b05d
Loading
Loading
Loading
Loading
+58 −56
Original line number Diff line number Diff line
module MainModule {
    import from TraceParserSystem all;

    function f_obuBehaviour(inout integer p_tranDuration) runs on ObuType {
    function f_rsuBehaviour(inout integer p_tranDuration) runs on RsuType {
        var address v_ts := 0;
        var integer v_startTS := 0;
        var template (present) LinkId v_linkId := ?;
@@ -10,28 +10,28 @@ module MainModule {
        var PayloadStructure v_receivedMsg;
        

        transactionOBUTimer.start;
        transactionRSUTimer.start;
        alt {
            [v_startTS==0] obuPort.receive(mw_obuBroadCastMsg) -> sender v_ts value v_receivedMsg{ 
            [v_startTS==0] rsuPort.receive(mw_rsuBroadCastMsg) -> sender v_ts value v_receivedMsg{ 
                // when the first broadcast message is received then take it's time stamp
                transactionOBUTimer.stop;
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                v_startTS := v_ts;
                transactionOBUTimer.start;
                transactionRSUTimer.start;
                repeat; 
            }
            [] compPort.receive(v_linkId) -> value v_linkId{
                transactionOBUTimer.stop;
                transactionRSUTimer.stop;
                v_receivedLinkId := true;
                transactionOBUTimer.start;
                transactionRSUTimer.start;
                repeat;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_releaseMsg(v_linkId)) -> sender v_ts value v_receivedMsg{ 
            [v_startTS!=0 and v_receivedLinkId == true] rsuPort.receive(mw_releaseMsg(v_linkId)) -> sender v_ts value v_receivedMsg{ 
                // when the release message was received take it's time stamp and calculate the transaction time
                // inform the rsu component 
                transactionOBUTimer.stop;
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
@@ -41,11 +41,11 @@ module MainModule {
                    [] compPort.receive(NrOfEmptyMsg :?) -> value v_nrOfEmptyMsg;
                    
                    [] compPort.receive {
                        transactionOBUTimer.stop;
                        setverdict(fail, "Unexpected message received");
                        transactionRSUTimer.stop;
                        setverdict(inconc, "Unexpected message received");
                        stop;
                    }
                    [] transactionOBUTimer.timeout {
                    [] transactionRSUTimer.timeout {
                        setverdict (inconc, "No NrOfEmptyMsg was received from RSU");
                        stop;
                    }                    
@@ -57,52 +57,52 @@ module MainModule {
                    setverdict (pass, "Transaction finished in " & int2str(p_tranDuration) & " micro s"  & " The Number of empty messages received is : " & int2str(v_nrOfEmptyMsg));
                }
                else {
                    setverdict (fail, "Transaction finished in more than 100ms (" & int2str(p_tranDuration) & ")");
                    setverdict (fail, "Transaction finished in more than 100ms (" & int2str(p_tranDuration) & " micro s "  &")");
                }
                stop;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_msg_withLinkId(v_linkId))-> value v_receivedMsg{
                transactionOBUTimer.stop;
            [v_startTS!=0 and v_receivedLinkId == true] rsuPort.receive(mw_msg_withLinkId(v_linkId))-> value v_receivedMsg{
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                transactionOBUTimer.start;
                transactionRSUTimer.start;
                repeat;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_obuBroadCastMsg) -> value v_receivedMsg{ 
            [v_startTS!=0 and v_receivedLinkId == true] rsuPort.receive(mw_rsuBroadCastMsg) -> value v_receivedMsg{ 
                //If another broadcast is received than ignore
                transactionOBUTimer.stop;
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                transactionOBUTimer.start;
                transactionRSUTimer.start;
                repeat;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive {
                transactionOBUTimer.stop;
                setverdict(fail, "Unexpected message received");
            [v_startTS!=0 and v_receivedLinkId == true] rsuPort.receive {
                transactionRSUTimer.stop;
                setverdict(inconc, "Unexpected message received");
                compPort.send(m_stop);
                stop;                
            }
            [] transactionOBUTimer.timeout {
                setverdict (inconc, "No OBU message was received");
            [] transactionRSUTimer.timeout {
                setverdict (inconc, "No RSU message was received");
                compPort.send(m_stop);
                stop;
            }
        }
    }
    
    function f_rsuBehaviour() runs on RsuType {
    function f_obuBehaviour() runs on ObuType {
        var boolean v_sentLinkId := false;
        var PayloadStructure v_msg;
        var NrOfEmptyMsg v_cntEmpty := 0;
        var template (present) LinkId v_linkId := ?;
        timer t_rsuTimer := 2.0;
        timer t_obuTimer := 2.0;
        
        t_rsuTimer.start;
        t_obuTimer.start;
        alt{
            []rsuPort.receive(mw_msg_withLinkId(v_linkId)) -> value v_msg{
                t_rsuTimer.stop;
            []obuPort.receive(mw_msg_withLinkId(v_linkId)) -> value v_msg{
                t_obuTimer.stop;
                //---
                 commmunOBURSUPort.send(v_msg);
                //---
@@ -111,27 +111,29 @@ module MainModule {
                       compPort.send(valueof(v_linkId));
                }
                v_sentLinkId := true;
                t_rsuTimer.start;
                t_obuTimer.start;
                repeat;
            }
            []rsuPort.receive(mw_msg_empty) ->value v_msg{
                t_rsuTimer.stop;
            []obuPort.receive(mw_msg_empty) ->value v_msg{
                t_obuTimer.stop;
                //---
                 commmunOBURSUPort.send(v_msg);
                //---
                v_cntEmpty := v_cntEmpty +1;
                t_rsuTimer.start;
                t_obuTimer.start;
                repeat;
            }
            []rsuPort.receive{
                t_rsuTimer.stop;
                setverdict (fail, "Unexpected message received.");
            []obuPort.receive{
                t_obuTimer.stop;
                setverdict (inconc, "Unexpected message received.");
                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));
                    // do nothing so that the last verdict would be taken from the RSU component
                    // only in case of fail (to many received empty frames) is the verdict from OBU component used
                    //setverdict (pass, "Number of received empty frames : " & int2str(v_cntEmpty));      
                }
                else {
                    setverdict (fail, "Maximum number of received empty frames exceeded! (" 
@@ -139,8 +141,8 @@ module MainModule {
                }
                stop;
            }
            []t_rsuTimer.timeout{
                setverdict(inconc, "No RSU messaged received");
            []t_obuTimer.timeout{
                setverdict(inconc, "No OBU messaged received");
                stop;
            }
        }
@@ -192,17 +194,17 @@ module MainModule {
     * @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
        var RsuType rsuComponent := RsuType.create("RSU"); //DL
        var ObuType obuComponent := ObuType.create("OBU"); //UL
        
        map(mtc:controlPort, system:controlPort);
        map(obuComponent:obuPort, system:msgPort);
        map(rsuComponent:rsuPort, system:msgPort);
        connect(obuComponent:compPort, rsuComponent:compPort);
        connect(obuComponent:commmunOBURSUPort, rsuComponent:commmunOBURSUPort);
        map(obuComponent:obuPort, system:msgPort);
        connect(rsuComponent:compPort, obuComponent:compPort);
        connect(rsuComponent:commmunOBURSUPort, obuComponent:commmunOBURSUPort);
        
        obuComponent.start(f_obuBehaviour(p_tranDuration));
        rsuComponent.start(f_rsuBehaviour());
        rsuComponent.start(f_rsuBehaviour(p_tranDuration));
        obuComponent.start(f_obuBehaviour());
        
        log ("Starting analysis of trace: " & int2str(p_traceIndex));