haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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' }
}