Commit a7e62424 authored by reinaortega's avatar reinaortega
Browse files

V2G modules added

parent aa897dbe
Loading
Loading
Loading
Loading
+204 −0
Original line number Diff line number Diff line
/**
 *  @author     ETSI / STFS46
 *  @version    $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/V2G/LibItsV2G_Functions.ttcn $
 *              $Id: LibItsV2G_Functions.ttcn 429 2012-03-13 16:11:47Z reinaortega $
 *  @desc       Module containing functions for V2G application layer protocols
 *
 */
 
 module LibItsV2G_Functions {
     
    // LibCommon
    
    // LibIts
    import from LibItsCommon_Functions all;
    import from LibItsV2G_TestSystem all;
    import from LibItsV2G_TypesAndValues all;
    import from LibItsV2G_Templates all;
    import from LibItsV2G_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 ItsV2G {
            
            utPort.send(p_init);
            tc_wait.start;
            alt {
                [] utPort.receive(UtResult: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
                    repeat; 
                }
            }
            
        }
        
        /**
         * @desc    Triggers event from the application layer
         * @param   p_event The event to trigger.
         */
        function f_utTriggerEvent(template (value) UtEvent p_event) runs on ItsV2G {
            var template (value) UtTrigger v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                }
                [] utPort.receive {
                    tc_wait.stop;
                }
                [] tc_wait.timeout {
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
        }
        
        /**
         * @desc Checks that the event was indicated at the application layer
         * @param p_event The event to check.
         * @param   p_discard The event should not appear. Default value: FALSE.
         */
        function f_utCheckEvent(template (value) UtEvent p_event, boolean p_discard) runs on ItsV2G {
            var template (value) UtCheck v_utMsg := { p_event };
            
            utPort.send(v_utMsg);
            tc_wait.start;
            alt {
                [] utPort.receive(UtResult:true) {
                    tc_wait.stop;
                    if (p_discard == false) {
                        log("*** f_utCheckEvent: INFO: Event correctly indicated at application layer ***");
                    }
                    else {
                        log("*** f_utCheckEvent: ERROR: Event indicated at application layer where it should be discarded ***");
                        f_selfOrClientSyncAndVerdict("error", e_error);
                    }
                }
                [] utPort.receive(UtResult:false) {
                    tc_wait.stop;
                    if (p_discard == false) {
                        log("*** f_utCheckEvent: ERROR: Event not correctly indicated at application layer ***");
                        f_selfOrClientSyncAndVerdict("error", e_error);
                    }
                    else {
                        log("*** f_utCheckEvent: INFO: Event not indicated at application layer***");
                    }
                }
                [] tc_wait.timeout {
                    log("*** f_utCheckEvent: ERROR: Timeout while waiting for event check result ***");
                    f_selfOrClientSyncAndVerdict("error", e_timeout);                    
                }
                [else] { // Shortcut defaults
                    repeat; 
                }
            }
        }
                    
    } // End of group utFunctions
     
    group configurationFunctions {
        
        /**
         * @desc    Setups default configuration   
         */
        function f_cfUp() runs on ItsV2G {
            
            map(self:utPort, system:utPort);
            map(self:btpPort, system:btpPort);
            f_connect4SelfOrClientSync();
            
        } // end f_cfUp
        
        /**
         * @desc    Deletes default configuration 
         */
        function f_cfDown() runs on ItsV2G {
            
            unmap(self:utPort, system:utPort);
            unmap(self:v2gPort, system:v2gPort);
            f_disconnect4SelfOrClientSync();
            
        } // end f_cfDown
        
    } // end configurationFunctions
    
    group v2gAltsteps {
        
        /**
         * @desc The base default.
         */
        altstep a_default() runs on ItsV2G {
            
            [] v2gPort.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;   
            }
        }
    } //end v2gAltsteps

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

        }
        
    } // end of group preambles    
    

    group postambles {
        
        /**
         * @desc The default postamble.
         */
        function f_poDefault() runs on ItsV2G {
            //empty
        }
        
    } // end postambles
    
} // end LibItsV2G_Functions
 No newline at end of file
+17 −0
Original line number Diff line number Diff line
/**
 *  @author   ETSI / STFS46
 *  @version  $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/V2G/LibItsV2G_Pixits.ttcn $
 *            $Id: LibItsV2G_Pixits.ttcn 429 2012-03-13 16:11:47Z reinaortega $
 *  @desc     V2G application layer protocols Pixits
 *
 */
module LibItsV2G_Pixits {
    
    // LibIts
    import from LibItsV2G_TypesAndValues all;
    

        

    
} // end LibItsV2G_Pixits
 No newline at end of file
+48 −0
Original line number Diff line number Diff line
/**
 *  @author   ETSI / STFS46
 *  @version  $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/V2G/LibItsV2G_Templates.ttcn $
 *            $Id: LibItsV2G_Templates.ttcn 429 2012-03-13 16:11:47Z reinaortega $
 *  @desc     V2G application layer protocols Templates
 *
 */
module LibItsV2G_Templates {
    
    // LibIts
    import from LibItsV2G_TestSystem all;
    import from LibItsV2G_TypesAndValues all;
    import from LibItsV2G_Pixits all;
        
    group v2gPrimitivesTemplates {

        
    
        group utPrimitives {
            
            /**
             * @desc Initializes the V2G IUT. 
             */
            template (value) UtInitialize m_v2gInitialize := {
                utV2Ginitialize := {
                }
            }
            
             /**
             * @desc Upper Tester template for checking that V2G payload has been transmitted to upper layer
             * @param p_payload Payload to be checked
             */
            template (value) UtEvent m_checkPayload(in V2Gpayload p_payload) := {
                utV2Gevent := {
                    payload := p_payload
                }
            }
            
        } // end utPrimitives
        
    } // v2gPrimitivesTemplates
    
    group v2gPduTemplates {

    } // end v2gPduTemplates
    
    
} // end LibItsV2G_Templates
 No newline at end of file
+107 −0
Original line number Diff line number Diff line
/**
 *    @author     ETSI / STFS46
 *  @version     $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/LibItsV2G_TestSystem.ttcn $
 *                $Id: LibItsV2G_TestSystem.ttcn 408 2012-02-28 13:49:56Z reinaortega $
 *    @desc        Test System module for ITS V2G
 *
 */
module LibItsV2G_TestSystem {
    
    // LibCommon
    import from LibCommon_Time {modulepar all};
    import from LibCommon_Sync all;
    
    // LibIts
    import from LibItsCommon_TestSystem all;
    import from LibItsV2G_TypesAndValues all;
    
    group portDefinitions {
    
        /**
         * @desc Upper Tester port
         */
        type port UpperTesterPort message {
            out 
                UtInitialize, UtTrigger, UtCheck;
            in 
                UtResult;
        } // end UpperTesterPort
        
    } // end portDefinitions

    group interfacePorts {

        group v2gApplicationLayerPorts {
            
            group xxxPorts {

                /**
                 * @desc XXX V2G Application Layer Port  
                 */
                type port V2Gport message {
                    in V2Gind;
                    out V2Greq;
                } // end V2Gport
                                
            } // End of group xxxPorts
            
        } // End of group v2gApplicationLayerPorts
    
    } // End of group interfacePorts
    
    group componentDefinitions {

        /**
         * @desc ITS System Adapter
         */
        type component ItsV2Gsystem {
            
            port UpperTesterPort utPort;
            
            // NT1 ports 
            port V2Gport v2gPort;
            
        } // end component ItsAdapter
        
    } // End of group componentDefinitions
    
    /**
     * @desc Test component for ITS V2G Application layer 
     */
    type component ItsV2G extends ItsBaseComponent {
        
        port UpperTesterPort utPort;
        
        // NT1 ports 
        port V2Gport v2gPort;
                
        // timers
                
    } // End of component ItsV2G
        
    group v2gApplicationLayerPrimitives { 
            
        group xxxPrimitives {

            /**
             * @desc XXX V2G Indication Primitive 
             */
            type record V2Gind {
                V2Gpacket msgIn
            }
        
            /**
             * @desc XXX V2G Request Primitive 
             */
            type record V2Greq {
                V2Gpacket msgOut
            }
                        
        } // end xxxPrimitives
        
    } // End of group v2gApplicationLayerPrimitives    
    with {
        encode "LibIts_Interface"
    } // end interfacePrimitives    
     
} // End of module LibItsV2G_TestSystem
+101 −0
Original line number Diff line number Diff line
/**
 *  @author   ETSI / STFS46
 *  @version  $URL: svn+ssh://vcs.etsi.org/TTCN3/LIB/LibIts/trunk/ttcn/V2G/LibItsV2G_TypesAndValues.ttcn $
 *            $Id: LibItsV2G_TypesAndValues.ttcn 429 2012-03-13 16:11:47Z reinaortega $
 *  @desc     Module containing types and values for V2G application layer protocols
 *
 */
module LibItsV2G_TypesAndValues {

    // LibCommon
    import from LibCommon_BasicTypesAndValues all;
    
    // LibIts
    /*import from V2G_PDU_Descriptions language "XML" {
        type V2Gpdu
    };*/
    
    group v2gPdus {
     
        
    } // end v2gPdus
    
    group v2gHeaders {
        
             
    } // end v2gHeaders

    group v2gPayload {
        
        /**
         * @desc The payload of the V2G packet
         * @remark Change it to concrete union value if necessary
         */
        type union V2Gpayload {
            V2Gpdu v2gPacket,
            octetstring otherPayload
        }
        
    } //end v2gPayload

    group utPrimitives {
    	
    	group utCommonPrimitives {
    		
	        /**
	         * @desc Upper Tester message to initialize IUT 
	         */
	        type union UtInitialize {
	            UtV2Ginitialize utV2Ginitialize
	        }
	
	        /**
	         * @desc Upper Tester message describing an action/event 
	         */
	        type union UtEvent {
	            UtV2Gevent utV2Gevent
	        }
	                
	        /**
	         * @desc Upper Tester message to trigger an action on IUT 
	         */
	        type record UtTrigger {
	            UtEvent utEvent
	        }
	        
	        /**
	         * @desc Upper Tester message to check event/status on IUT 
	         */    
	        type record UtCheck {
	            UtEvent utEvent
	        }
	        
	        /**
	         * @desc Upper Tester response message  
	         */    
	        type boolean UtResult;
        }
        with {
            encode "LibItsCommon_TypesAndValues"
        }
                
        /**
         * @desc Upper Tester message to initialize V2G IUT 
         */
        type record UtV2Ginitialize {
        }
        
        /**
         * @desc Upper Tester message generating V2G packet
         */
        type union UtV2gEvent {
            V2Gheader   v2gHeader,
            V2Gpayload  payload
        }
        
    } // end utPrimitives
    
}
with {
    encode "LibItsV2G_TypesAndValues"
}