Quintiq file version 2.0
#parent: #root
Method PTF_ExecuteClient (
  structured[LibPTF_TestScript] testscripts,
  String str
) as String id:Method_LibPTF_pnlTestController_PTF_ExecuteClient
{
  #keys: '[102890.0.1874250332]'
  Body:
  [*
    // Checks the status of the expected clients and launched clients in all the scripts and launch the next batches of clients when the previous batches of clients complete its execution
    
    rowDelimiter    := LibPTF_Util::StringListRowDelimiter();   
    columnDelimiter := LibPTF_Util::StringListColumnDelimiter();
    
    tracker         := construct( Strings );
    rows            := str.Tokenize( rowDelimiter );
    
    traverse( rows, Elements, row )
    {
      columns := row.Tokenize( columnDelimiter );
    
      user                  := columns.Element( 0 );
      reqSessions           := [Number]columns.Element( 1 );
      reqConcurrentSessions := [Number]columns.Element( 2 );
      executedSessions_o    := [Number]columns.Element( 3 );
      executingSessions_o   := [Number]columns.Element( 4 );
      remainingSessions     := [Number]columns.Element( 5 );
      startTime_o           := columns.Element( 6 );
      endTime               := columns.Element( 7 );
      // elapsedtime        := columns.Element( 8 ); Not being used
      startoffset           := columns.Element( 9 );
    
      remainingConcurrentSessions := reqConcurrentSessions - executingSessions_o;
      script                      := select( testscripts,
                                             Elements,
                                             s,
                                             true,
                                             s.User() = user );
      
      currentTime := this.PTF_ConvertStringToDateTime( this.PTF_GetCurrentDatetime() );
      
      if( remainingSessions > 0
          and this.PTF_ConvertStringToDateTime( lblStartTime.Text() ) + [Duration]startoffset <= currentTime 
        )
      {
        nrOfClientsToStart := minvalue( remainingSessions, remainingConcurrentSessions );
    
        this.PTF_ExecuteClientByScript( script,
                                        nrOfClientsToStart,
                                        executedSessions_o,
                                        executingSessions_o,
                                        startTime_o
                                          );
      }
    
      columns.Flush();
      columns.Add( user );
      columns.Add( [String]reqSessions );
      columns.Add( [String]reqConcurrentSessions );
      columns.Add( [String]executedSessions_o );
      columns.Add( [String]executingSessions_o );
      columns.Add( [String]remainingSessions );
      columns.Add( startTime_o );
      columns.Add( endTime );
      columns.Add( this.PTF_GetTotalDuration( startTime_o, endTime ) );
      columns.Add( startoffset );
    
      tracker.Add( columns.ToString( columnDelimiter ) );
    }
    
    return tracker.ToString( rowDelimiter );
  *]
}
