Commit 620a6792 authored by mullers's avatar mullers
Browse files

Madalina's latest TTCN3 files added

parent a2d4c16e
Loading
Loading
Loading
Loading
+439 −281
Original line number Diff line number Diff line
module MainModule {
    import from TraceParserSystem all;

    function f_rsuBehaviour(inout integer p_tranDuration) runs on RsuType {
//    function f_rsuBehaviour(inout integer p_tranDuration, inout integer p_nrOfEmptyMsg, inout verdicttype p_transVerdict) runs on RsuType {
    function f_rsuBehaviour() runs on RsuType {
        var address v_ts := 0;
        var integer v_startTS := 0;
        var template (present) LinkId v_linkId := ?;
        var boolean v_receivedLinkId := false;
        var boolean v_actionAtOBU := false;
        var NrOfEmptyMsg v_nrOfEmptyMsg := 0;
//        var NrOfEmptyMsg v_nrOfEmptyMsg := 0;
        var PayloadStructure v_receivedMsg;
        
        var VerdictStructure v_vs;

        transactionRSUTimer.start;
        alt {
@@ -17,7 +19,7 @@ module MainModule {
                // when the first broadcast message is received then take it's time stamp
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                commonOBURSUPort.send(v_receivedMsg);
                //---
                v_startTS := v_ts;
                transactionRSUTimer.start;
@@ -34,18 +36,18 @@ module MainModule {
                v_actionAtOBU := true;
                repeat;
            }

            [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 
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                commonOBURSUPort.send(v_receivedMsg);
                //---
                compPort.send(m_stop);
                
                alt{
                    [] compPort.receive(NrOfEmptyMsg :?) -> value v_nrOfEmptyMsg;
//                    [] compPort.receive(NrOfEmptyMsg :?) -> value p_nrOfEmptyMsg;
                    [] compPort.receive(NrOfEmptyMsg :?) -> value v_vs.nrOfEmptyMsg;
                    
                    [] compPort.receive {
                        transactionRSUTimer.stop;
@@ -58,20 +60,34 @@ module MainModule {
                    }                    
                }
                
                
                p_tranDuration := v_ts - v_startTS;
                if (p_tranDuration <= 100000) {
                    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) & " micro s "  &")");
//                p_tranDuration := v_ts - v_startTS;
//                if (p_tranDuration <= 100000 and p_nrOfEmptyMsg <= PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
//                    setverdict (pass, "Transaction finished in " & int2str(p_tranDuration) & " microsec." & " The Number of empty messages received is : " & int2str(p_nrOfEmptyMsg));
//                }
//                else if(p_tranDuration > 100000){
//                    setverdict (fail, "Transaction finished in more than 100ms (" & int2str(p_tranDuration) & " micro s "  &")");
//                }else if(p_nrOfEmptyMsg > PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
//                    setverdict (fail, "Maximum number of received empty frames exceeded! (" 
//                                                         & int2str(p_nrOfEmptyMsg) & " > " & int2str(PX_MAX_NUM_EMPTY_UPLINK_FRAMES) & ")");
//                }
//                p_transVerdict := getverdict;
                v_vs.tranDuration := v_ts - v_startTS;
                if (v_vs.tranDuration <= 100000 and v_vs.nrOfEmptyMsg <= PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
                    setverdict (pass, "Transaction finished in " & int2str(v_vs.tranDuration) & " microsec." & " The Number of empty messages received is : " & int2str(v_vs.nrOfEmptyMsg));
                }
                else if(v_vs.tranDuration > 100000){
                    setverdict (fail, "Transaction finished in more than 100ms (" & int2str(v_vs.tranDuration) & " micro s "  &")");
                }else if(v_vs.nrOfEmptyMsg > PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
                    setverdict (fail, "Maximum number of received empty frames exceeded! (" 
                                                         & int2str(v_vs.nrOfEmptyMsg) & " > " & int2str(PX_MAX_NUM_EMPTY_UPLINK_FRAMES) & ")");
                }
                verdictPort.send(m_verdictStructure(getverdict, v_vs.tranDuration, v_vs.nrOfEmptyMsg));
				stop;
            }
            [v_startTS!=0 and v_receivedLinkId == true] rsuPort.receive(mw_msg_withLinkId(v_linkId))-> value v_receivedMsg{
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                commonOBURSUPort.send(v_receivedMsg);
                //---
                transactionRSUTimer.start;
                repeat;
@@ -80,7 +96,7 @@ module MainModule {
                //If another broadcast is received than ignore
                transactionRSUTimer.stop;
                //---
                commmunOBURSUPort.send(v_receivedMsg);
                commonOBURSUPort.send(v_receivedMsg);
                //---
                transactionRSUTimer.start;
                repeat;
@@ -89,6 +105,8 @@ module MainModule {
                transactionRSUTimer.stop;
                setverdict(inconc, "Unexpected message received");
                compPort.send(m_stop);
//                p_transVerdict := getverdict;
                verdictPort.send(m_verdictStructure(getverdict));
                stop;                
            }
            [] transactionRSUTimer.timeout {
@@ -101,6 +119,8 @@ module MainModule {
                     	{setverdict (fail);}
                	}
                compPort.send(m_stop);
//                p_transVerdict := getverdict;
                verdictPort.send(m_verdictStructure(getverdict));
                stop;
            }
        }
@@ -118,7 +138,7 @@ module MainModule {
            []obuPort.receive(mw_msg_withLinkId(v_linkId)) -> value v_msg{
                transactionOBUTimer.stop;
                //---
                 commmunOBURSUPort.send(v_msg);
                 commonOBURSUPort.send(v_msg);
                //---
                if (v_sentLinkId == false) {
                       v_linkId := valueof(v_msg.linkMsg.linkId);
@@ -132,7 +152,7 @@ module MainModule {
            []obuPort.receive(mw_msg_empty) ->value v_msg{
                transactionOBUTimer.stop;
                //---
                 commmunOBURSUPort.send(v_msg);
                 commonOBURSUPort.send(v_msg);
                //---
                v_cntEmpty := v_cntEmpty +1;
                transactionOBUTimer.start;
@@ -150,15 +170,6 @@ module MainModule {

            []compPort.receive(m_stop) {
                compPort.send(v_cntEmpty);
                if (v_cntEmpty <= PX_MAX_NUM_EMPTY_UPLINK_FRAMES){
                    // 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! (" 
                                      & int2str(v_cntEmpty) & " > " & int2str(PX_MAX_NUM_EMPTY_UPLINK_FRAMES) & ")");
                }
                stop;
            }
            []transactionOBUTimer.timeout{
@@ -171,17 +182,39 @@ module MainModule {
        }
    }
  
    testcase TC_CheckTracePath(in charstring p_tracePath, out TraceFileList p_traceFileList) runs on MtcType system SystemType {
        map(mtc:controlPort, system:controlPort);
        
        controlPort.call(getTraceFileList:{p_tracePath}, 5.0) {
            [] controlPort.getreply(getTraceFileList:{-} value ?) -> value p_traceFileList {
                if(lengthof(p_traceFileList) != 0){
                    setverdict (pass, "Number of Trace files = " & int2str(lengthof(p_traceFileList)));   
                }else{
                    setverdict (fail, "!!No Trace Files Found!! Please verify the log folder!!");   
                    stop;
                }
            }
            [] controlPort.getreply {
                setverdict (fail, "Unexpected reply");
                stop;
            }
            [] controlPort.catch(timeout) {
                setverdict (fail, "Timeout while caling getTraceFileList");
                stop;
            }
        };
    }
    
    /**
     * @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 {
    testcase TC_Initialization(in charstring p_traceFile, out integer p_nrOfTransactions) runs on MtcType system SystemType {
        
        map(mtc:controlPort, system:controlPort);
        
        parseFileName(PX_TRACE_PATH, v_PowerLevel, v_OBUName, v_DutyCycle, v_RepNo);
        parseFileName(p_traceFile, v_PowerLevel, v_OBUName, v_DutyCycle, v_RepNo);
        
        controlPort.call(setTraceFile:{PX_TRACE_PATH}, 5.0) {
        controlPort.call(setTraceFile:{p_traceFile}, 5.0) {
            [] controlPort.getreply(setTraceFile:{-} value true) {
                setverdict (pass, "  PowerLevel = " & v_PowerLevel&
              					  "  OBUName = " & v_OBUName & 
@@ -200,7 +233,12 @@ module MainModule {

        controlPort.call(getTransactionCnt:{}, 5.0) {
            [] controlPort.getreply(getTransactionCnt:{} value ?) -> value p_nrOfTransactions {
                if(p_nrOfTransactions != 0){
                    setverdict (pass, "Number of Transaction = " & int2str(p_nrOfTransactions));   
                }else{
                    setverdict (fail, "!!Log file does not contain any transactions !! Please verify the log file!!");   
                    stop;
                }
            }
            [] controlPort.getreply {
                setverdict (fail, "Unexpected reply");
@@ -211,22 +249,40 @@ module MainModule {
                stop;
            }
        };
        
        controlPort.call(writeCSVITSParams:{PX_CSV_FILE, v_PowerLevel, v_OBUName, v_DutyCycle, v_RepNo}, 5.0) {
            [] controlPort.getreply(writeCSVITSParams:{-, -, -, -, -} value true) {
                setverdict (pass, "Success when writing in the csv file " & PX_CSV_FILE);
            }
            [] controlPort.getreply {
                setverdict (fail, "Problem occured when writing the ITS parameters in the csv file " & PX_CSV_FILE);
                stop;
            }
            [] controlPort.catch(timeout) {
                setverdict (fail, "Timeout while writing the ITS parameters in the  csv file "  & PX_CSV_FILE);
                stop;
            }
        };
    }
    
    /**
     * @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 {
    testcase TC_AnalyzesTrace(inout integer p_traceIndex, inout integer p_tranDuration, inout integer p_nrOfEmptyMsg, inout verdicttype p_transVerdict) runs on MtcType system SystemType {
        var RsuType rsuComponent := RsuType.create("RSU"); //DL
        var ObuType obuComponent := ObuType.create("OBU"); //UL
        var VerdictStructure v_vs;
        
        map(mtc:controlPort, system:controlPort);
        map(rsuComponent:rsuPort, system:msgPort);
        map(obuComponent:obuPort, system:msgPort);
        connect(rsuComponent:compPort, obuComponent:compPort);
        connect(rsuComponent:commmunOBURSUPort, obuComponent:commmunOBURSUPort);
        connect(rsuComponent:commonOBURSUPort, obuComponent:commonOBURSUPort);
        
        rsuComponent.start(f_rsuBehaviour(p_tranDuration));
        connect(mtc:verdictPort, rsuComponent:verdictPort);
        
//        rsuComponent.start(f_rsuBehaviour(p_tranDuration, p_nrOfEmptyMsg, p_transVerdict));
        rsuComponent.start(f_rsuBehaviour());
        obuComponent.start(f_obuBehaviour());
        
        log ("Starting analysis of trace: " & int2str(p_traceIndex));
@@ -245,25 +301,84 @@ module MainModule {
            }
        };
        
        transactionTimer.start;
        alt {
            [] verdictPort.receive(VerdictStructure:?) -> value v_vs {
                transactionTimer.stop;
                p_transVerdict := v_vs.transVerdict;
                p_tranDuration := v_vs.tranDuration;
                p_nrOfEmptyMsg := v_vs.nrOfEmptyMsg;
            }
            [] transactionTimer.timeout {
            }
        }
         
        all component.done;
        
        controlPort.call(writeCSVTransaction:{PX_CSV_FILE, p_tranDuration, p_nrOfEmptyMsg}, 5.0) {
            [] controlPort.getreply(writeCSVTransaction:{-, -, -} value true) {
                setverdict (pass);
            }
            [] controlPort.getreply {
                setverdict (fail, "Problem occured when writing the ITS parameters in the csv file " & PX_CSV_FILE);
                stop;
            }
            [] controlPort.catch(timeout) {
                setverdict (fail, "Timeout while writing the ITS parameters in the  csv file "  & PX_CSV_FILE);
                stop;
            }
        };
        
    }
    
    testcase TC_LogAnalyzesTrace(inout integer p_averageTranDuration,
                                 inout integer p_shortestTransDuration,
                                 inout integer p_shortestTransIndex,
                                 inout integer p_longestTransDuration,
                                 inout integer p_longestTransIndex) runs on MtcType system SystemType {
                                 inout integer p_longestTransIndex ,
                                 inout integer p_nrOfTransactions,
                                 inout integer p_failTran,
                                 inout integer p_inconcTran, 
                                 inout integer p_passTran) runs on MtcType system SystemType {        
        map(mtc:controlPort, system:controlPort);
         
        
//        if(p_failTran != 0 ){
//            p_failTran := (p_failTran * 100)/ p_nrOfTransactions;
//        }
         
        controlPort.call(writeCSVMinMaxErrorRate:{PX_CSV_FILE, p_shortestTransDuration,
            									p_shortestTransIndex, p_longestTransDuration,
            									p_longestTransIndex,  p_averageTranDuration,
            									p_nrOfTransactions, p_failTran}, 5.0) {
            [] controlPort.getreply(writeCSVMinMaxErrorRate:{-, -, -,-, -, -,-, -} value true) {
                setverdict (pass);
            }
            [] controlPort.getreply {
                setverdict (fail, "Problem occured when writing the error rate in the csv file " & PX_CSV_FILE);
                stop;
            }
            [] controlPort.catch(timeout) {
                setverdict (fail, "Timeout while writing the error rate in the  csv file "  & PX_CSV_FILE);
                stop;
            }
        };
                                
        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) & " micro s"  & 
                         " The longest transaction was transaction: " & int2str(p_longestTransIndex) & 
                         " and took " & int2str(p_longestTransDuration)& " micro s") ;
                         " and took " & int2str(p_longestTransDuration)& " micro s" &
                         " Erorr Rate " & int2str(p_failTran)
                         ) ;
                         
         unmap(mtc:controlPort, system:controlPort);            
    } 
    
    control {
        var integer v_nrOfTransactions := 0;
        var integer v_nrOfRelevantTransactions := 0;
        var integer v_nrOfEmptyTransactions := 0;
        var integer v_longestTransDuration := 0;
        var integer v_longestTransIndex := -1;
        var integer v_shortestTransDuration := 0;
@@ -271,12 +386,35 @@ module MainModule {
        var integer v_tranDuration := 0;
        var integer v_cumulativeTranDuration := 0;
        var integer v_averageTranDuration;
        var integer v_failTran := 0;
        var integer v_inconcTran := 0;
        var integer v_passTran := 0;
        var verdicttype v_transVerdict := fail;
        var TraceFileList v_traceFileList;
        
        execute(TC_CheckTracePath(PX_TRACE_PATH, v_traceFileList));
        
        for(var integer j:=0; j<lengthof(v_traceFileList); j:=j + 1) {
            v_nrOfTransactions := 0;
            v_nrOfRelevantTransactions := 0;
            v_nrOfEmptyTransactions := 0;
            v_longestTransDuration := 0;
            v_longestTransIndex := 0;
            v_shortestTransDuration := 0;
            v_shortestTransIndex := 0;
            v_tranDuration := 0;
            v_cumulativeTranDuration := 0;
            v_averageTranDuration := 0;
            v_transVerdict := fail;
            v_failTran := 0;
            v_inconcTran := 0;
            v_passTran := 0;
            
        execute(TC_Initialization(v_nrOfTransactions));
            execute(TC_Initialization(v_traceFileList[j], v_nrOfTransactions));
            v_nrOfRelevantTransactions := v_nrOfTransactions;
            
            for(var integer i:=0; i<v_nrOfTransactions; i:=i + 1) {
            execute(TC_AnalyzesTrace(i, v_tranDuration));
                execute(TC_AnalyzesTrace(i, v_tranDuration, v_nrOfEmptyTransactions, v_transVerdict));
                v_cumulativeTranDuration := v_cumulativeTranDuration + v_tranDuration;
                if (v_tranDuration == 0) {
                    v_nrOfRelevantTransactions := v_nrOfRelevantTransactions - 1;
@@ -287,22 +425,42 @@ module MainModule {
                if(v_shortestTransDuration > v_tranDuration){
                    log("Short v_tranDuration " & int2str(v_tranDuration));
                    v_shortestTransDuration := v_tranDuration;
                v_shortestTransIndex := i;
                    v_shortestTransIndex := i +1; // for a better understanding when reading the statistic (instead of starting counting from 0 it starts from 1)
                }
                else if(v_longestTransDuration < v_tranDuration){
                    log("Long v_tranDuration " & int2str(v_tranDuration));
                    v_longestTransDuration := v_tranDuration;
                v_longestTransIndex := i;
                    v_longestTransIndex := i +1; // for a better understanding when reading the statistic (instead of starting counting from 0 it starts from 1)
                }
                
                select(v_transVerdict){
                	case(inconc){
                        v_inconcTran := v_inconcTran +1:
                	}
                	case(fail){
                        v_failTran := v_failTran +1;
                	}
                	case(pass){
                        v_passTran := v_passTran +1;
                	}
                }
                
                
            };
            
            if(v_nrOfRelevantTransactions != 0){
                v_averageTranDuration := float2int(int2float(v_cumulativeTranDuration) / int2float(v_nrOfRelevantTransactions));
        
                execute(TC_LogAnalyzesTrace(v_averageTranDuration,
                                            v_shortestTransDuration,
                                            v_shortestTransIndex,
                                            v_longestTransDuration,
                                    v_longestTransIndex));
                                            v_longestTransIndex,
               								v_nrOfTransactions,
               								v_failTran,
                							v_inconcTran,
                							v_passTran
               								));
            }
        }
    }    
    
}
 No newline at end of file
+57 −6
Original line number Diff line number Diff line
module TraceParserSystem {
    /* @desc Path to file that holds the trace */
    //modulepar charstring PX_TRACE_PATH:= "C:\Demo_Dump2.txt";
    modulepar charstring PX_TRACE_PATH:= "C:\PowerLevel_OBUName_DutyCycle_RepNo.txt";
    modulepar charstring PX_TRACE_PATH:= "C:\PlugTest\Logs2\1_OBUName_7_2011.txt";
    /* @desc The path to the csv file */
    modulepar charstring PX_CSV_FILE:= "C:\PlugTest\Result.csv";
    /* @desc Maximum allowed number of empty uplink frames from the On Board Unit (OBU) */
    modulepar integer PX_MAX_NUM_EMPTY_UPLINK_FRAMES:= 100;
    
@@ -29,6 +31,10 @@ module TraceParserSystem {
    
    type port TraceCtrlPortType procedure{
        out
        writeCSVMinMaxErrorRate,
        writeCSVTransaction,
        writeCSVITSParams,
        getTraceFileList,
        setTraceFile,
        getTransactionCnt,
        startAnalyzeTrace,
@@ -39,10 +45,14 @@ module TraceParserSystem {
    	inout LinkId, SyncCommand, NrOfEmptyMsg;
    }
    
    type port CommunPortOBURSUType message{
    type port CommonPortOBURSUType message{
        inout PayloadStructure;
    }
    
    type port VerdictCompPort message{
        inout VerdictStructure;
    }
    
    type component SystemType {
        port TraceCtrlPortType controlPort;
        port TraceMsgPortType msgPort;
@@ -50,6 +60,7 @@ module TraceParserSystem {
    
    type component MtcType {
        port TraceCtrlPortType controlPort;
        port VerdictCompPort verdictPort;
        timer transactionTimer := 5.0 ;
        var charstring v_PowerLevel := "";
        var charstring v_OBUName := "";
@@ -63,14 +74,15 @@ module TraceParserSystem {
    type component RsuType { //downLinkType
        port TraceMsgPortType rsuPort;
        port CompPortType compPort;
        port CommunPortOBURSUType commmunOBURSUPort;
        port VerdictCompPort verdictPort;
        port CommonPortOBURSUType commonOBURSUPort;
        timer transactionRSUTimer := 1.5 ;
    }
    
    type component ObuType { //upLinkType
        port TraceMsgPortType obuPort;
        port CompPortType compPort;
        port CommunPortOBURSUType commmunOBURSUPort;
        port CommonPortOBURSUType commonOBURSUPort;
        timer transactionOBUTimer := 1.0 ;
    }
    
@@ -105,14 +117,25 @@ module TraceParserSystem {
        e_error
    }
    
    type record VerdictStructure {
		integer tranDuration, 
		integer nrOfEmptyMsg, 
		verdicttype transVerdict
	}
    
    type integer NrOfEmptyMsg;
    
    type record of charstring TraceFileList;
         
    template PayloadStructure mw_rsuBroadCastMsg := {
        broadcastMsg := {
            broadcast :=  'FF'O,
            msg := ?
       }
    }
    with {
        display "RSU BROADCAST"
    }
    
    template PayloadStructure mw_releaseMsg(template (present) LinkId p_linkId) :={
        linkMsg := {
@@ -123,6 +146,9 @@ module TraceParserSystem {
            tapdu := '200000'O
        }
    }
    with {
        display "RSU RELEASE"
    }
    
    template PayloadStructure mw_msg_withLinkId(template (present) LinkId p_linkId) :={ 
        linkMsg := {
@@ -133,6 +159,9 @@ module TraceParserSystem {
            tapdu := *
        }
    }
    with {
        display "MSG with LINK ID"
    }
    
    template PayloadStructure mw_msg_empty :={ 
        linkMsg := {
@@ -143,9 +172,23 @@ module TraceParserSystem {
            tapdu := omit
        }
    }
    with {
        display "EMPTY MSG"
    }
    
    template SyncCommand m_stop := e_stop;
    
    template VerdictStructure m_verdictStructure(
    	in template(value) verdicttype p_transVerdict,
    	in template(value) integer p_tranDuration := 0,
    	in template(value) integer p_nrOfEmptyMsg := 0
    ) := {
		tranDuration := p_tranDuration, 
		nrOfEmptyMsg := p_nrOfEmptyMsg, 
		transVerdict := p_transVerdict
	}
    

    group baseMessages {
        type integer address;
    }
@@ -155,6 +198,14 @@ module TraceParserSystem {
    
    group signatures {
        
        signature writeCSVITSParams(in charstring csvFilePath, in charstring powerLevel, in charstring obuName, in charstring dutyCycle, in charstring repNo) return boolean;
        
        signature writeCSVTransaction(in charstring csvFilePath, in integer transDuration, in integer nrOfEmptyMsg) return boolean;
        
        signature writeCSVMinMaxErrorRate(in charstring csvFilePath, in integer minTranDuration, in integer minTranIndex, in integer maxTranDuration,  in integer maxTranIndex, in integer averageTranDuration, in integer nrOfTransactions, in integer errorRate) return boolean;
        
        signature getTraceFileList(in charstring tracePath) return TraceFileList;
        
        signature setTraceFile(in charstring tracePath) return boolean;
        
        signature isFolder() return boolean;