Commit 89615a85 authored by mullers's avatar mullers
Browse files

reverted

parent 6ed954f0
Loading
Loading
Loading
Loading
+231 −0
Original line number Original line Diff line number Diff line
/**
 *  @author     ETSI / STF405
 *  @version    $URL$
 *              $Id$
 *  @desc       Module containing functions for basic Transport Protocol
 *
 */
 
 module LibItsBtp_Functions {
     
    // LibCommon
    import from LibCommon_Sync all;
    import from LibCommon_Time all;
    import from LibCommon_VerdictControl all;
    
    // LibItsCommon
    import from LibItsCommon_Functions all;
    import from LibItsCommon_TypesAndValues all;
    
    // LibItsBtp
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Templates all;
    import from LibItsBtp_Pixits 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 ItsBtp {
            
            utPort.send(p_init);
            tc_wait.start;
            alt {
                [] utPort.receive(UtInitializeResult:true) {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT initialized ***");
                }
                [] utPort.receive {
                    tc_wait.stop;
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized ***");
                    f_selfOrClientSyncAndVerdict("error", e_error);
                }
                [] tc_wait.timeout {
                    log("*** f_utInitializeIut: INFO: IUT could not be initialized in time ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);
                }
                [else] { // Shortcut defaults
                    //f_sleep(0.050); // 50 ms
                    repeat; 
                }
            }
            
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtBtpTrigger p_event) runs on ItsBtp {
            
            utPort.send(p_event);
            alt {
                [] utPort.receive(UtBtpTriggerResult:true) {
                    tc_wait.stop;
                }
                [] utPort.receive {
                    tc_wait.stop;
                }
                [] tc_wait.timeout {
                }
                [else] { // Shortcut defaults
                    //f_sleep(0.050); // 50 ms
                    repeat; 
                }
            }
        }
        
    } // End of group utFunctions
     
    group configurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsBtp {
            
            map(self:utPort, system:utPort);
            map(self:btpPort, system:btpPort);
            f_connect4SelfOrClientSync();
            
        } // end f_cfUp
        
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsBtp {
            
            unmap(self:utPort, system:utPort);
            unmap(self:btpPort, system:btpPort);
            f_disconnect4SelfOrClientSync();
            
        } // end f_cfDown
        
    } // end configurationFunctions
    
    group btpAltsteps {
        
        /**
         * @desc The base default.
         */
        altstep a_default() runs on ItsBtp {
            
            [] btpPort.receive {
                log("*** a_default: ERROR: Received an unexpected message ***");
                f_selfOrClientSyncAndVerdict("error", e_error);
            }
            [] tc_wait.timeout {
                log("*** a_default: INCONC: Timeout while awaiting reaction of the IUT prior to Upper Tester action ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] tc_ac.timeout {
                log("*** a_default: INCONC: Timeout while awaiting the reception of a message ***");
                f_selfOrClientSyncAndVerdict("error", e_timeout);
            }
            [] a_shutdown() {
                f_poDefault();
                f_cfDown();
                log("*** a_default: INFO: TEST COMPONENT NOW STOPPING ITSELF! ***");
                stop;   
            }
        }
        
        /**
         * @desc The default for handling upper tester messages.
         */
        altstep a_utDefault() runs on ItsBtp {
            var UtBtpEventInd v_ind;
            [] utPort.receive(UtBtpEventInd:?) -> value v_ind {
                //store every upper tester indication received
                vc_utEvents[lengthof(vc_utEvents)] := v_ind;
                repeat;
            }
            [] utPort.receive {
                log("*** " & testcasename() & ": INFO: Received unhandled/unknown UT message from IUT ***");
                repeat;
            }
        }
        
    } //end btpAltsteps

    group preambles {
        
        /**
         * @desc The default preamble.
         */
        function f_prDefault() runs on ItsBtp {
            activate(a_default());
            activate(a_utDefault());
        }
        
        /**
         * @desc Brings the IUT into an initial state.
         */
        function f_prInitialState() runs on ItsBtp {
            
            f_utInitializeIut(m_btpInitialize);
            f_prDefault();

        }
        
    } // end of group preambles    
    

    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsBtp {
            //empty
        }
        
    } // end postambles
    
    group getFunctions {
        
        /**
         * @desc Gets the BTP source port of the IUT.
         * @return BTP source port ID
         */
        function f_getBtpSrcPort() return BtpPortId {
            return PX_SOURCE_PORT;
        }
        
        /**
         * @desc Gets the BTP destination port of the IUT.
         * @return BTP destination port ID
         */
        function f_getBtpDstPort() return BtpPortId {
            return PX_DESTINATION_PORT;
        }
        
        /**
         * @desc Gets a unknown BTP destination port of the IUT.
         * @return Unknown BTP destination port ID
         */
        function f_getBtpUnknownDstPort() return BtpPortId {
            return PX_UNKNOWN_DESTINATION_PORT;
        }
        
        /**
         * @desc Gets the BTP destination port info of the IUT.
         * @return BTP destination port info
         */
        function f_getBtpDstPortInfo() return BtpPortId {
            return PX_DESTINATION_PORT_INFO;
        }
        
        /**
         * @desc Gets the BTP payload to use.
         * @return BTP payload
         */
        function f_getBtpPayload() return BtpPayload {
            return PX_PAYLOAD;
        }
        
    } // end getFunctions
} // end LibItsBtp_Functions
 No newline at end of file
+48 −0
Original line number Original line Diff line number Diff line
/**
 *  @author   ETSI / STF405
 *  @version  $URL$
 *            $Id$
 *  @desc     Basic Transport Protocol Templates
 *
 */
module LibItsBtp_Pixits {
    
    // LibIts
    import from LibItsBtp_TypesAndValues all;
    

        /**
         * @desc BTP source port of the IUT
         * 		 
         */
    	modulepar BtpPortId PX_SOURCE_PORT := 0;

        /**
         * @desc BTP Destination port of the IUT
         * 		 
         */
    	modulepar BtpPortId PX_DESTINATION_PORT := 0;

        /**
         * @desc BTP Unknown Destination port of the IUT
         * 		 
         */
    	modulepar BtpPortId PX_UNKNOWN_DESTINATION_PORT := 0;

        /**
         * @desc BTP Destination port Info of the IUT
         * 		 
         */
    	modulepar BtpPortId PX_DESTINATION_PORT_INFO := 0;

        /**
         * @desc Payload to be sent to the IUT for testing matter
         * 		 
         */
    	modulepar BtpPayload PX_PAYLOAD := { 
    	    decodedPayload := omit, 
    	    rawPayload := '0102030405'O 
    	};

    
} // end LibItsBtp_Pixits
 No newline at end of file
+200 −0
Original line number Original line Diff line number Diff line
/**
 *  @author   ETSI / STF405
 *  @version  $URL$
 *            $Id$
 *  @desc     Basic Transport Protocol Templates
 *
 */
module LibItsBtp_Templates {
    
    // LibIts
    import from LibItsBtp_TestSystem all;
    import from LibItsBtp_TypesAndValues all;
    import from LibItsBtp_Pixits all;
    import from LibItsCommon_TypesAndValues all;
        
    group btpPrimitivesTemplates {

        /**
         * @desc    Send template for BTP packet (BtpPort Primitive)
         * @param   p_btpPkt BTP Packet to be sent
         */
        template (value) BtpReq m_btpReq(
            template (value) BtpPacket p_btpPkt
            ) := {
            msgOut := p_btpPkt
        }
        
        /**
         * @desc    Receive template for BTP packet (BtpPort Primitive)
         * @param   p_btpPkt BTP Packet to be received
         */
        template BtpInd mw_btpInd(
            template (present) BtpPacket p_btpPkt
            ) := {
            msgIn := p_btpPkt
        }
    
        group utPrimitives {
            
            /**
             * @desc Initializes the BTP IUT. 
             */
            template (value) UtInitialize m_btpInitialize := {
                hashedId8 := '0000000000000000'O
            }
            
            /**
             * @desc Generate a BTP A packet
             * @param p_destPort  The destination port
             * @param p_srcPort   The source port
             */
            template (value) UtBtpTrigger m_generateBtpA(in BtpPortId p_destPort, in BtpPortId p_srcPort) := {
                btpA := {
                    btpAHeader := {
                        destinationPort := p_destPort,
                        sourcePort := p_srcPort
                    }
                }
            }
            
            /**
             * @desc Generate a BTP B packet
             * @param p_destPort      The destination port
             * @param p_destPortInfo  The destination port information
             */
            template (value) UtBtpTrigger m_generateBtpB(in BtpPortId p_destPort, in BtpPortInfo p_destPortInfo) := {
                btpB := {
                    btpBHeader := {
                        destinationPort := p_destPort,
                        destinationPortInfo := p_destPortInfo
                    }
                }
            }
                        
        } // end utPrimitives
        
    } // btpPrimitivesTemplates
    
    group btpPduTemplates {
        
        /**
         * @desc    Send template for BTP-A packet
         * @param   p_destPort  Destination port
         * @param   p_srcPort   Source port
         * @param   p_payload   Payload
         */
        template (value) BtpPacket m_btpA (
            template (value) BtpPayload p_payload
        ):= {
            header := { 
                btpAHeader := {
                    destinationPort := PX_DESTINATION_PORT, 
                    sourcePort := PX_SOURCE_PORT
                }
            }, 
            payload := p_payload
        }

        /**
         * @desc    Send template for BTP-B packet
         * @param   p_destPort      Destination port
         * @param   p_destPortInfo  Destination port information
         * @param   p_payload       Payload
         */
        template( value) BtpPacket m_btpB (
            template (value) BtpPayload     p_payload
        ) := {
            header := { 
                btpBHeader := {
                    destinationPort := PX_DESTINATION_PORT, 
                    destinationPortInfo := 0
                }
            }, 
            payload := p_payload
        }
        
        /**
         * @desc    Send template for BTP-A packet with port parameters
         * @param   p_destPort  Destination port
         * @param   p_srcPort   Source port
         * @param   p_payload   Payload
         */
        template (value) BtpPacket m_btpAWithPorts (
            template (value) BtpPortId  p_destPort,
            template (value) BtpPortId  p_srcPort,
            template (value) BtpPayload p_payload
        ):= {
            header := { 
                btpAHeader := {
                    destinationPort := p_destPort, 
                    sourcePort := p_srcPort
                }
            }, 
            payload := p_payload
        }

        /**
         * @desc    Send template for BTP-B packet with port parameters
         * @param   p_destPort      Destination port
         * @param   p_destPortInfo  Destination port information
         * @param   p_payload       Payload
         */
        template( value) BtpPacket m_btpBWithPorts (
            template (value) BtpPortId      p_destPort,
            template (value) BtpPortInfo    p_destPortInfo,
            template (value) BtpPayload     p_payload
        ) := {
            header := { 
                btpBHeader := {
                    destinationPort := p_destPort, 
                    destinationPortInfo := p_destPortInfo
                }
            }, 
            payload := p_payload
		}

        /**
         * @desc    Receive template for BTP-A packet
         * @param   p_destPort  Destination port
         * @param   p_srcPort   Source port
         * @param   p_payload   Payload
         */
        template BtpPacket mw_btpA (
            template (present) BtpPortId   p_destPort,
            template (present) BtpPortId   p_srcPort,
            template BtpPayload  p_payload
        ) := {
            header := { 
                btpAHeader := {
                    destinationPort := p_destPort, 
                    sourcePort := p_srcPort
                }
            }, 
            payload := p_payload
        }

        /**
         * @desc    Receive template for BTP-B packet
         * @param   p_destPort      Destination port 
         * @param   p_destPortInfo  Destination port information
         * @param   p_payload       Payload
         */
        template BtpPacket mw_btpB (	
            template (present) BtpPortId   p_destPort,
            template (present) BtpPortInfo p_destPortInfo,
            template BtpPayload  p_payload
        ) := {
            header := { 
                btpBHeader := {
                    destinationPort := p_destPort, 
                    destinationPortInfo := p_destPortInfo
                }
            }, 
            payload := p_payload
        }

    } // end btpPduTemplates
    
    
} // end LibItsBtp_Templates
 No newline at end of file
+110 −0
Original line number Original line Diff line number Diff line
/**
 *    @author     ETSI / STF405
 *  @version     $URL$
 *                $Id$
 *    @desc        Test System module for ITS BTP
 *
 */
module LibItsBtp_TestSystem {
    
    // LibCommon
    import from LibCommon_Time {modulepar all};
    import from LibCommon_Sync all;
    
    // LibIts
    import from LibItsCommon_TestSystem all;
    import from LibItsCommon_TypesAndValues all;
    import from LibItsBtp_TypesAndValues all;
    
    group portDefinitions {
    
        /**
         * @desc Upper Tester port
         */
        type port UpperTesterPort message {
            out 
                UtInitialize, UtBtpTrigger;
            in 
                UtInitializeResult, UtBtpTriggerResult, UtBtpEventInd;
        } // end UpperTesterPort
        
    } // end portDefinitions

    group interfacePorts {

        group networkAndTransportPorts {
            
            group nt1Ports {

                /**
                 * @desc NT1 BTP Port (BTP/GeoNet/G5) 
                 */
                type port BtpPort message {
                    in BtpInd;
                    out BtpReq;
                } // end BtpPort
                                
            } // End of group nt1Ports
            
        } // End of group networkAndTransportPorts
    
    } // End of group interfacePorts
    
    group componentDefinitions {

        /**
         * @desc ITS System Adapter
         */
        type component ItsBtpSystem {
            
            port UpperTesterPort utPort;
            
            // NT1 ports 
            port BtpPort btpPort;
            
        } // end component ItsAdapter
        
    } // End of group componentDefinitions
    
    /**
     * @desc Test component for ITS Network and Transport layer 
     */
    type component ItsBtp extends ItsBaseComponent {
        
        port UpperTesterPort utPort;
        
        // NT1 ports 
        port BtpPort btpPort;
                
        // timers
                
        var UtBtpEventIndList vc_utEvents := {};
        
    } // End of component ItsBtp
        
    group networkAndTransportPrimitives { 
            
        group nt1Primitives {

            /**
             * @desc NT1 BTP Indication Primitive 
             */
            type record BtpInd {
                BtpPacket msgIn
            }
        
            /**
             * @desc NT1 BTP Request Primitive 
             */
            type record BtpReq {
                BtpPacket msgOut
            }
                        
        } // end nt1Primitives
        
    } // End of group networkAndTransportPrimitives    
    with {
        encode "LibIts_Interface"
    } // end interfacePrimitives    
     
} // End of module LibItsBtp_TestSystem
+170 −0
Original line number Original line Diff line number Diff line
/**
 *  @author   ETSI / STF405
 *  @version  $URL$
 *            $Id$
 *  @desc     Module containing types and values for Basic Transport Protocol
 *
 */
module LibItsBtp_TypesAndValues {

    // LibCommon
    import from LibCommon_BasicTypesAndValues all;
    
    // LibIts
    import from CAM_PDU_Descriptions language "ASN.1:1997" {
        type CAM
    };
    import from DENM_PDU_Descriptions language "ASN.1:1997" {
        type DENM
    };
    
    group btpPdus {
     
        /**
         * @desc BTP Packet
         * @see ETSI TS 102 636-5-1 chapter 6
         * @member header
         * @member payload
         */
        type record BtpPacket {
            BtpHeader      header,
            BtpPayload     payload optional
        }
        
    } // end btpPdus
    
    group btpHeaders {
        
        /**
         * @desc BTP Header
         * @see ETSI TS 102 636-5-1 chapter 7.1
         * @member btpAHeader
         * @member btpBHeader
         */
        type union BtpHeader {
            BtpAHeader btpAHeader,
            BtpBHeader btpBHeader 
        }

        /**
         * @desc BTP-A Header
         * @see ETSI TS 102 636-5-1 chapter 7.2
         * @member destinationPort
         * @member sourcePort
         */        
        type record BtpAHeader {
            BtpPortId destinationPort,
            BtpPortId sourcePort   
        } 

        /**
         * @desc BTP-B Header
         * @see ETSI TS 102 636-5-1 chapter 7.3
         * @member destinationPort
         * @member destinationPortInfo
         */        
        type record BtpBHeader {
            BtpPortId destinationPort,
            BtpPortInfo destinationPortInfo   
        }
        
        /**
         * @desc BTP Port ID
         * @see ETSI TS 102 636-5-1 chapter 7.3.2
         */ 
        type UInt16 BtpPortId;

        /**
         * @desc BTP-B Port info
         * @see ETSI TS 102 636-5-1 chapter 7.3.2
         */ 
        type UInt16 BtpPortInfo;
        
    } // end btpHeaders

    group btpPayload {
        
        type octetstring BtpRawPayload;
        
        /**
         * @desc The payload of the BTP packet
         * @member decodedPayload The decoded payload
         * @member rawPayload Raw payload as it is received
         */
        type record BtpPayload {
            DecodedBtpPayload decodedPayload optional,
            BtpRawPayload rawPayload
        }
        
        /**
         * @desc The decoded payload of the BTP packet
         * @member camPacket The CAM packet
         * @member denmPacket The DENM packet
         * @member
         */
        type union DecodedBtpPayload {
            CAM camPacket, 
            DENM denmPacket 
        } with { 
            encode (camPacket) "LibItsCam_asn1"; 
            encode (denmPacket) "LibItsDenm_asn1" 
        }
        
    } //end btpPayload

    group utPrimitives {
        
        group utCommonPrimitives {
            
            /**
             * @desc    UT primitives for BTP
             * @member  btpA      -
             * @member  btpB    -
             */
            type union UtBtpTrigger {
                GenerateBtpA btpA,
                GenerateBtpB btpB
            }
    
            type boolean UtBtpTriggerResult;
            
            /**
             * @desc Upper Tester message to request triggering of an BTPA message at IUT 
             */
            type record GenerateBtpA {
                BtpAHeader btpAHeader
            }
                    
            /**
             * @desc Upper Tester message to request triggering of an BTPB message at IUT 
             */
            type record GenerateBtpB {
                BtpBHeader btpBHeader
            }
            
            /**
             * @desc Upper Tester message to check event/status on BTP IUT 
             */    
            type record UtBtpEventInd {
                BtpRawPayload rawPayload
            }
            
            /**
             * @desc List of Upper Tester messages to check event/status on CAM IUT 
             */    
            type record of UtBtpEventInd UtBtpEventIndList;
        }
//        with {
//            encode "LibItsCommon"
//        }
                
        
    } // end utPrimitives
    with {
        encode "UpperTester"
    }
    
}
with {
    encode "LibItsBtp"
}
Loading