Commit 2b12b4a7 authored by predusi's avatar predusi
Browse files

implemented the exchange of the messages between obu and rsu component. and...

implemented the exchange of the messages between obu and rsu component. and implement the parsing of the trace file named as discussed.
parent 1a973ca8
Loading
Loading
Loading
Loading
+51 −26
Original line number Diff line number Diff line
@@ -7,13 +7,17 @@ module MainModule {
        var template (present) LinkId v_linkId := ?;
        var boolean v_receivedLinkId := false;
        var NrOfEmptyMsg v_nrOfEmptyMsg := 0;
        var PayloadStructure v_receivedMsg;
        

        transactionOBUTimer.start;
        alt {
            [v_startTS==0] obuPort.receive(mw_obuBroadCastMsg) -> sender v_ts { 
            [v_startTS==0] obuPort.receive(mw_obuBroadCastMsg) -> sender v_ts value v_receivedMsg{ 
                // when the first broadcast message is received then take it's time stamp
                transactionOBUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                v_startTS := v_ts;
                transactionOBUTimer.start;
                repeat; 
@@ -24,10 +28,13 @@ module MainModule {
                transactionOBUTimer.start;
                repeat;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_releaseMsg(v_linkId)) -> sender v_ts { 
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.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;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                compPort.send(m_stop);
                
                alt{
@@ -54,14 +61,20 @@ module MainModule {
                }
                stop;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_msg_withLinkId(v_linkId)){
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_msg_withLinkId(v_linkId))-> value v_receivedMsg{
                transactionOBUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                transactionOBUTimer.start;
                repeat;
            }
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_obuBroadCastMsg){ 
            [v_startTS!=0 and v_receivedLinkId == true] obuPort.receive(mw_obuBroadCastMsg) -> value v_receivedMsg{ 
                //If another broadcast is received than ignore
                transactionOBUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                //---
                transactionOBUTimer.start;
                repeat;
            }
@@ -79,7 +92,6 @@ module MainModule {
        }
    }
    
    
    function f_rsuBehaviour() runs on RsuType {
        var boolean v_sentLinkId := false;
        var PayloadStructure v_msg;
@@ -95,12 +107,18 @@ module MainModule {
                       v_linkId := valueof(v_msg.linkMsg.linkId);
                       compPort.send(valueof(v_linkId));
                }
                //---
                 commmunOBURSUPort.send(v_msg);
                //---
                v_sentLinkId := true;
                t_rsuTimer.start;
                repeat;
            }
            []rsuPort.receive(mw_msg_empty){
            []rsuPort.receive(mw_msg_empty) ->value v_msg{
                t_rsuTimer.stop;
                //---
                 commmunOBURSUPort.send(v_msg);
                //---
                v_cntEmpty := v_cntEmpty +1;
                t_rsuTimer.start;
                repeat;
@@ -128,6 +146,7 @@ module MainModule {
        }
    }
    

    /**
     * @desc This test case is seting the trace file and counts the number of transaction 
     */
@@ -135,9 +154,14 @@ module MainModule {
        
        map(mtc:controlPort, system:controlPort);
        
        parseFileName(PX_TRACE_PATH, v_PowerLevel, v_OBUName, v_DutyCycle, v_RepNo);
        
        controlPort.call(setTraceFile:{PX_TRACE_PATH}, 5.0) {
            [] controlPort.getreply(setTraceFile:{-} value true) {
                setverdict (pass);
                setverdict (pass, "PowerLevel = " & v_PowerLevel&
                                  " OBUName = " & v_OBUName & 
                                  " DutyCycle = " & v_DutyCycle &
                                  "  RepNo = " &  v_RepNo );
            }
            [] controlPort.getreply {
                setverdict (fail, "Could not set trace file");
@@ -162,7 +186,6 @@ module MainModule {
                stop;
            }
        };
        
    }
    
    /**
@@ -176,6 +199,7 @@ module MainModule {
        map(obuComponent:obuPort, system:msgPort);
        map(rsuComponent:rsuPort, system:msgPort);
        connect(obuComponent:compPort, rsuComponent:compPort);
        connect(obuComponent:commmunOBURSUPort, rsuComponent:commmunOBURSUPort);
        
        obuComponent.start(f_obuBehaviour(p_tranDuration));
        rsuComponent.start(f_rsuBehaviour());
@@ -204,11 +228,12 @@ module MainModule {
                                 inout integer p_shortestTransIndex,
                                 inout integer p_longestTransDuration,
                                 inout integer p_longestTransIndex) runs on MtcType system SystemType {
        setverdict(pass, "The average transaction duration is: " & int2str(p_averageTranDuration) & "µs" & 
                                     
        setverdict(pass, "The average transaction duration is: " & int2str(p_averageTranDuration) & "micro s" & 
                         " The shortest transaction was transaction: " & int2str(p_shortestTransIndex) & 
        				 " and took " & int2str(p_shortestTransDuration) & "µs"  & 
                         " and took " & int2str(p_shortestTransDuration) & "micro s"  & 
                         " The longest transaction was transaction: " & int2str(p_longestTransIndex) & 
        				 " and took " & int2str(p_longestTransDuration)& "µs") ;
                         " and took " & int2str(p_longestTransDuration)& "micro s") ;
    } 
    
    control {