Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Function CalcStatus 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    value := LibOpt_RunStatus::Loaded(); 
 | 
     
 | 
    // Case: the run has been aborted because the dataset was copied during the run 
 | 
    if( this.IsAborted()  
 | 
        and this.MDSID() <> this.MDSIDRun() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::AbortedCopiedDataset(); 
 | 
    } 
 | 
    // Case: the run is aborted, but some tasks are still being processed. 
 | 
    // This happens, for example, if LibOpt_IteratorForEachLink.IsPostProcessing is set to true. 
 | 
    else if( this.IsAborted() 
 | 
             and exists( this, Task, task, true ) ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::AbortedPostProcessing(); 
 | 
       
 | 
      // While executing the post-processing steps, it is still possible to pause the run.  
 | 
      // It would be confusing if this status would be the same as the regular 'Paused' status.  
 | 
      if( not isnull( this.BreakpointEvent() ) ) 
 | 
      { 
 | 
        value := LibOpt_RunStatus::AbortedPaused(); 
 | 
      }   
 | 
    } 
 | 
    // Case: the run is aborted 
 | 
    else if( this.IsAborted() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Aborted(); 
 | 
    } 
 | 
    // Case: the run is failed 
 | 
    else if( this.IsFailed() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Failed(); 
 | 
    } 
 | 
    // Case: the run is paused due to a breakpoint 
 | 
    else if( not isnull( this.BreakpointEvent() ) ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Paused(); 
 | 
    } 
 | 
    // Case: the run is finished, as there is a finished time and it is not marked as aborted or failed. 
 | 
    else if( not this.FinishedOn().IsMinInfinity() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Finished(); 
 | 
    } 
 | 
    // Case: the run is optimizing, as it is started and not aborted, paused or finished. 
 | 
    else if( not this.StartedOn().IsMinInfinity() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Optimizing(); 
 | 
    } 
 | 
    else if( not this.RequestedOn().IsMinInfinity() ) 
 | 
    { 
 | 
      value := LibOpt_RunStatus::Requested(); 
 | 
    } 
 | 
     
 | 
    this.Status( value ); 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |