Commit 0814fc7f authored by berge's avatar berge
Browse files

Fixed some warning + Factorised some code (use of extends)

New synchronisation functions added allowing synchronisation of a subset of the clients: 
f_serverSyncClientsIntermediateSync
f_serverSyncClientsTimedIntermediateSync
parent 31359963
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@
        p_item := "f_peekTopStringStack: String stack is empty!";
        p_item := "f_peekTopStringStack: String stack is empty!";
        return false;
        return false;
      }
      }
      p_item := p_stack.stringItems[p_stack.stackSize-1];
      p_item := valueof(p_stack.stringItems[p_stack.stackSize-1]);
      return true;
      return true;
    }
    }


+76 −45
Original line number Original line Diff line number Diff line
@@ -95,12 +95,9 @@ module LibCommon_Sync {
         *        component type is type compatible to this component
         *        component type is type compatible to this component
         *        type definition!
         *        type definition!
         */
         */
        type component ServerSyncComp {
        type component ServerSyncComp extends BaseSyncComp {
          timer tc_shutDown := PX_TSHUT_DOWN_TIME_LIMIT;
          timer tc_shutDown := PX_TSHUT_DOWN_TIME_LIMIT;
          // definitions for BaseSyncComp
        }
          port  SyncPort syncPort;
          timer tc_sync := PX_TSYNC_TIME_LIMIT;
        } with { extension "extends BaseSyncComp" }


        /**
        /**
         * @desc  This type is used to define any synchronization
         * @desc  This type is used to define any synchronization
@@ -114,12 +111,9 @@ module LibCommon_Sync {
         *        component type is type compatible to this component
         *        component type is type compatible to this component
         *        type definition!
         *        type definition!
         */
         */
        type component ClientSyncComp {
        type component ClientSyncComp extends BaseSyncComp {
          var StringStack v_stateStack:= c_initStringStack;
          var StringStack v_stateStack:= c_initStringStack;
          // definitions for BaseSyncComp
        }
          port  SyncPort syncPort;
          timer tc_sync := PX_TSYNC_TIME_LIMIT;
        } with { extension "extends BaseSyncComp" }


        /**
        /**
         * @desc  This type is used to define any synchronization
         * @desc  This type is used to define any synchronization
@@ -135,13 +129,9 @@ module LibCommon_Sync {
         *        component test cases!
         *        component test cases!
         * @see   LibCommon_Sync.ClientSyncComp
         * @see   LibCommon_Sync.ClientSyncComp
         */
         */
        type component SelfSyncComp {
        type component SelfSyncComp extends ClientSyncComp {
          port SyncPort syncSendPort;
          port SyncPort syncSendPort;
          // definitions for ClientSyncComp
        }
          var StringStack v_stateStack:= c_initStringStack;
          port SyncPort syncPort;
          timer tc_sync := PX_TSYNC_TIME_LIMIT;
        } with { extension "extends ClientSyncComp" }


        /**
        /**
         * @desc  This port type must be imported into test suites
         * @desc  This port type must be imported into test suites
@@ -238,11 +228,7 @@ module LibCommon_Sync {
       */
       */
      function f_serverSync2ClientsAndStop( in SyncPointList p_syncPointIds )
      function f_serverSync2ClientsAndStop( in SyncPointList p_syncPointIds )
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
          f_serverSyncNClientsAndStop(2, p_syncPointIds);
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
          f_serverSyncClientsTimed(2,p_syncPointIds[i], PX_TSYNC_TIME_LIMIT);
        }
        f_serverWaitForAllClientsToStop();
      }
      }


      /**
      /**
@@ -267,11 +253,7 @@ module LibCommon_Sync {
       */
       */
      function f_serverSync3ClientsAndStop( in SyncPointList p_syncPointIds )
      function f_serverSync3ClientsAndStop( in SyncPointList p_syncPointIds )
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
          f_serverSyncNClientsAndStop(3, p_syncPointIds);
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
          f_serverSyncClientsTimed(3,p_syncPointIds[i], PX_TSYNC_TIME_LIMIT);
        }
        f_serverWaitForAllClientsToStop();
      }
      }


      /**
      /**
@@ -296,11 +278,7 @@ module LibCommon_Sync {
       */
       */
      function f_serverSync4ClientsAndStop( in SyncPointList p_syncPointIds )
      function f_serverSync4ClientsAndStop( in SyncPointList p_syncPointIds )
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
          f_serverSyncNClientsAndStop(4, p_syncPointIds);
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
          f_serverSyncClientsTimed(4,p_syncPointIds[i], PX_TSYNC_TIME_LIMIT);
        }
        f_serverWaitForAllClientsToStop();
      }
      }


      /**
      /**
@@ -325,14 +303,14 @@ module LibCommon_Sync {
       * @param  p_syncPointIds list of synchronization point name/ids
       * @param  p_syncPointIds list of synchronization point name/ids
       */
       */
      function f_serverSyncNClientsAndStop ( 
      function f_serverSyncNClientsAndStop ( 
      	in integer p_numClients,
      	in UInt p_numClients,
      	in SyncPointList p_syncPointIds )
      	in SyncPointList p_syncPointIds )
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
          f_serverSyncClientsTimed (
          f_serverSyncClientsTimed (
          	p_numClients,
          	p_numClients,
          	p_syncPointIds[i],
          	valueof(p_syncPointIds[i]),
          	PX_TSYNC_TIME_LIMIT );
          	PX_TSYNC_TIME_LIMIT );
        }
        }
        f_serverWaitForAllClientsToStop();
        f_serverWaitForAllClientsToStop();
@@ -362,7 +340,7 @@ module LibCommon_Sync {
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
        var integer i, v_noOfSyncIds := sizeof(p_syncPointIds);
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
        for ( i := 0; i < v_noOfSyncIds; i := i+1 ) {
          f_serverSyncClientsTimed(3,p_syncPointIds[i], PX_TSYNC_TIME_LIMIT);
          f_serverSyncClientsTimed(3,valueof(p_syncPointIds[i]), PX_TSYNC_TIME_LIMIT);
        }
        }
        f_serverWaitForAllClientsToStop();
        f_serverWaitForAllClientsToStop();
      }
      }
@@ -610,6 +588,28 @@ module LibCommon_Sync {
        f_serverSyncClientsTimed(p_noOfClients,p_syncId, PX_TSYNC_TIME_LIMIT);
        f_serverSyncClientsTimed(p_noOfClients,p_syncId, PX_TSYNC_TIME_LIMIT);
      }
      }


      /**
       * @desc   Implements synchronization of "n" clients from server
       *         side including intermediate synchronization. 
       *         If a problem occurs, then server sends STOP to
       *         all clients. Waits for PX_TSYNC_TIME_LIMIT to let
       *         clients finish executing their behavior until this
       *         synchronization point. See f_serverSyncClientsTimed for
       *         overwriting this later timing constraint!
       *         This function sets the server component verdict.
       * @remark The use of this function requires prior connection  of
       *         the server sync port!
       * @see    LibCommon_Sync.f_connect4SelfOrClientSync
       * @see    LibCommon_Sync.PX_TSYNC_TIME_LIMIT
       * @see    LibCommon_Sync.f_serverSyncClientsTimed
       * @param  p_noOfClients number of clients to be synchronized
       * @param  p_syncId synchronization point name/id
       */
      function f_serverSyncClientsIntermediateSync( in UInt p_noOfClients, in charstring p_syncId, in UInt p_NoOfClientIntermediate, in template (present) charstring p_syncIdIntermediate )
      runs on ServerSyncComp {
          f_serverSyncClientsTimedIntermediateSync(p_noOfClients,p_syncId, p_NoOfClientIntermediate, p_syncIdIntermediate, PX_TSYNC_TIME_LIMIT);
      }
  
      /**
      /**
       * @desc   Handles synchronization of clients from server side.
       * @desc   Handles synchronization of clients from server side.
       *         If problem occurs, then server sends STOP to all clients.
       *         If problem occurs, then server sends STOP to all clients.
@@ -626,10 +626,30 @@ module LibCommon_Sync {
                        in charstring   p_syncId,
                        in charstring   p_syncId,
                        float       p_execTimeLimit )
                        float       p_execTimeLimit )
      runs on ServerSyncComp {
      runs on ServerSyncComp {
          f_serverSyncClientsTimedIntermediateSync(p_NoOfClients, p_syncId, 0, ?, p_execTimeLimit )
      } // end function f_serverSyncClientsTimed

      /** @desc Handles synchronization of clients from server side including
       *      intermediate synchronization.
       *      If problem occurs, then server sends STOP to all clients.
       *      This function sets the server verdict.
       * @remark  The use of this function requires prior connection of
       *      the server sync ports!
       * @param   p_NoOfClients number of clients to be synchronized
       * @param   p_syncId synchronization point name/id
       * @param   p_execTimeLimit time limit given to all clients to finish the execution
       *      of their behavior up to this synchronization point
       * @see   LibCommon_Sync.f_connect4SelfOrClientSync
       * @return  execution status
       */
      function f_serverSyncClientsTimedIntermediateSync(  in UInt     p_NoOfClients,
                        in charstring   p_syncId, in UInt p_NoOfClientIntermediate, in template (present) charstring p_syncIdIntermediate,
                        float       p_execTimeLimit )
      runs on ServerSyncComp {


        var integer v_noOfRecvdSyncMsgs := 0;
        var integer v_noOfRecvdSyncMsgs := 0, v_noOfRecvdSyncMsgsIntermediate := 0;
        var boolean v_stopClients := false;
        var boolean v_stopClients := false;
        var ClientSyncCompList v_clientRefs := {};
        var ClientSyncCompList v_clientRefs := {}, v_clientRefsIntermediate := {};
        var ClientSyncComp v_clientRef;
        var ClientSyncComp v_clientRef;


        if ( p_syncId == c_prDone ) {
        if ( p_syncId == c_prDone ) {
@@ -643,6 +663,14 @@ module LibCommon_Sync {
        }
        }
        tc_sync.start(p_execTimeLimit) ;
        tc_sync.start(p_execTimeLimit) ;
        alt{
        alt{
          [v_noOfRecvdSyncMsgsIntermediate != p_NoOfClientIntermediate]  syncPort.receive(m_syncClientReady(p_syncIdIntermediate)) -> sender v_clientRef {
              v_clientRefsIntermediate[v_noOfRecvdSyncMsgsIntermediate] := v_clientRef;
              v_noOfRecvdSyncMsgsIntermediate := v_noOfRecvdSyncMsgsIntermediate + 1;
              if (v_noOfRecvdSyncMsgsIntermediate == p_NoOfClientIntermediate) {
                  f_serverSendToAllClients(v_clientRefsIntermediate, m_syncServerReady(p_syncIdIntermediate));
              }
              repeat;
            }
          []  syncPort.receive(m_syncClientReady(p_syncId)) -> sender v_clientRef {
          []  syncPort.receive(m_syncClientReady(p_syncId)) -> sender v_clientRef {
                v_clientRefs[v_noOfRecvdSyncMsgs] := v_clientRef;
                v_clientRefs[v_noOfRecvdSyncMsgs] := v_clientRef;
              v_noOfRecvdSyncMsgs := v_noOfRecvdSyncMsgs + 1;
              v_noOfRecvdSyncMsgs := v_noOfRecvdSyncMsgs + 1;
@@ -671,6 +699,9 @@ module LibCommon_Sync {
              log("**** f_serverSyncClientsTimed: A client is not responding within specified time limit - sync server is sending stop to all clients! ****");
              log("**** f_serverSyncClientsTimed: A client is not responding within specified time limit - sync server is sending stop to all clients! ****");
              v_stopClients := true; }
              v_stopClients := true; }
        } //end alt
        } //end alt
        if (v_noOfRecvdSyncMsgsIntermediate != p_NoOfClientIntermediate) {
            v_stopClients := true;
        }
        tc_sync.stop ;
        tc_sync.stop ;
        if ( v_stopClients ) {
        if ( v_stopClients ) {
          setverdict(inconc);
          setverdict(inconc);
@@ -689,7 +720,7 @@ module LibCommon_Sync {
            log("**** f_serverSyncClientsTimed: Sync server successfully passed synchronization point. ****") ;
            log("**** f_serverSyncClientsTimed: Sync server successfully passed synchronization point. ****") ;
          }
          }
        }
        }
      } // end function f_serverSyncClientsTimed
      } // end function f_serverSyncClientsTimedIntermediateSync


      /**
      /**
       * @desc  This function is intended only for use on the sync
       * @desc  This function is intended only for use on the sync
@@ -709,10 +740,10 @@ module LibCommon_Sync {
            }
            }
          [] tc_sync.timeout {
          [] tc_sync.timeout {
              log("**** f_serverWaitForAllClientsToStop: Not all sync clients have finshed execution within the sync time limit. Sync server will stop test case! ****") ;
              log("**** f_serverWaitForAllClientsToStop: Not all sync clients have finshed execution within the sync time limit. Sync server will stop test case! ****") ;
              stop;
            }
            }
        } // end alt
        } // end alt
        setverdict(pass);
        setverdict(pass);
          stop;
      } // end function f_serverWaitForAllClientsToStop
      } // end function f_serverWaitForAllClientsToStop


    } // end group serverRelated
    } // end group serverRelated
@@ -914,13 +945,13 @@ module LibCommon_Sync {
       * @desc  Default time limit for a sync client to reach a
       * @desc  Default time limit for a sync client to reach a
       *        synchronization point
       *        synchronization point
       */
       */
      modulepar {float PX_TSYNC_TIME_LIMIT := 120.0}
      modulepar float PX_TSYNC_TIME_LIMIT := 120.0;


      /*
      /*
       * @desc  Default time limit for a sync client to finish
       * @desc  Default time limit for a sync client to finish
       *        its execution of the shutdown default
       *        its execution of the shutdown default
       */
       */
      modulepar {float PX_TSHUT_DOWN_TIME_LIMIT := 120.0}
      modulepar float PX_TSHUT_DOWN_TIME_LIMIT := 120.0;
    }
    }


    group otherSyncTypes {
    group otherSyncTypes {
@@ -1098,11 +1129,11 @@ module LibCommon_Sync {
    } // end group syncProtocolDefinition
    } // end group syncProtocolDefinition


    group syncMessages {
    group syncMessages {
      template SyncCmd m_syncClientReady( template charstring p_syncId ) := {
      template SyncCmd m_syncClientReady( template (present) charstring p_syncId ) := {
        clientReady := { p_syncId }
        clientReady := { p_syncId }
      }
      }


      template SyncCmd m_syncServerReady( template charstring p_syncId ) := {
      template SyncCmd m_syncServerReady( template (present) charstring p_syncId ) := {
        serverReady := { p_syncId }
        serverReady := { p_syncId }
      }
      }


@@ -1124,11 +1155,11 @@ module LibCommon_Sync {
       * @param p_syncCmd The actual synchronization message to be sent out
       * @param p_syncCmd The actual synchronization message to be sent out
       */
       */
      function f_serverSendToAllClients(  in ClientSyncCompList p_clientRefs,
      function f_serverSendToAllClients(  in ClientSyncCompList p_clientRefs,
                        in template SyncCmd p_syncCmd)
                        in template (value) SyncCmd p_syncCmd)
      runs on ServerSyncComp {
      runs on ServerSyncComp {
        var integer i:=0;
        var integer i:=0;
        for (i:=0; i< sizeof(p_clientRefs); i:=i+1 ){
        for (i:=0; i< sizeof(p_clientRefs); i:=i+1 ){
          syncPort.send(p_syncCmd) to p_clientRefs[i];
          syncPort.send(p_syncCmd) to valueof(p_clientRefs[i]);
        }
        }
      } // end function f_serverSendToAllClients
      } // end function f_serverSendToAllClients


+5 −5
Original line number Original line Diff line number Diff line
@@ -18,31 +18,31 @@ module LibCommon_Time {
     * @desc    Time to control PTC.stop
     * @desc    Time to control PTC.stop
     * @remark  PICS/PIXIT Reference: XXX
     * @remark  PICS/PIXIT Reference: XXX
    */
    */
    modulepar {float PX_TDONE := 120.0}
    modulepar float PX_TDONE := 120.0;


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


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


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


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


  } // end group timeLibModuleParameters
  } // end group timeLibModuleParameters