LibCommon_Time.ttcn 2.79 KB
Newer Older
/**
 *  @author   ETSI
 *  @version  $URL$
 *            $Id$
 *  @desc     A collection of time handling functions which may be useful in
 *            the implementation of any TTCN-3 test suite.
 *  @remark   End users should be aware that any changes made to the  in
 *            definitions this module may be overwritten in future releases.
 *            End users are encouraged to contact the distributers of this
 *            module regarding their modifications or additions so that future
 *            updates will include your changes.
 *  @copyright  ETSI Copyright Notification
 *                No part may be reproduced except as authorized by written permission.
 *                The copyright and the foregoing restriction extend to reproduction in all media.
 *                All rights reserved.
 *
 */
module LibCommon_Time {

  group timeLibModuleParameters {

    /**
     * @desc    Time to control PTC.stop
     * @remark  PICS/PIXIT Reference: XXX
    */
    modulepar float PX_TDONE := 120.0;

    /**
     * @desc    Time to control the reception of a message
     * @remark  PICS/PIXIT Reference: XXX
    */
    modulepar float PX_TAC := 30.0;

    /**
     * @desc    Time to control that IUT sends nothing
     * @remark  PICS/PIXIT Reference: XXX
    */
    modulepar float PX_TNOAC := 10.0;

    /**
     * @desc    Time to control that IUT reacts prior to Upper Tester action
     * @remark  PICS/PIXIT Reference: XXX
    */
    modulepar float PX_TWAIT := 120.0;

    /**
     * @desc    Time to control sending in loops
     * @remark  PICS/PIXIT Reference: XXX
    */
    modulepar float PX_LOOP := 1.0;

  } // end group timeLibModuleParameters

  group sleeping {

    /**
     * @desc  The invocation of this function will cause a test component
     *        to sleep (or wait) for a specified amount of time.
     *        Defaults may interrupt this sleep if activated.
     * @see   LibCommon_Time.f_sleepIgnoreDef
     * @param p_duration Amount of time that the test component should wait.
     */
    function f_sleep ( in float p_duration ) {
      timer t;
      if (p_duration <= 0.0) {return}
      t.start( p_duration );
      t.timeout;
    }

    /**
     * @desc  The invocation of this function will cause a test component
     *        to sleep (or wait) for a specified amount of time.
     *        This function ignores any active defaults, i.e., the function
     *        will always wait the specified amount of time.
     * @param p_duration Amount of time that the test component should wait.
     */
    function f_sleepIgnoreDef ( in float p_duration ) {
      timer t;
      if (p_duration <= 0.0) {return}
      t.start( p_duration );
      alt {
        [] t.timeout {}
        [else] {repeat}
      } // end alt
    }

  } // end group sleeping

} // end module LibCommon_Time