yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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
Quintiq file version 2.0
#parent: #root
Method PollOptimizerRunController (Boolean canstart) const as stream[Boolean]
{
  Description:
  [*
    This method is called every `LibOpt_OptimizerRunController.PollingDuration` milliseconds.
    This continues until the `LibOpt_Run` is stopped or until the `CanStart` method returns true. (The `CanStart` method returns true if `LibOpt_Run` receives approval from the `LibOpt_OptimizerRunController` that it is allowed to start). 
    Note: This method is Const and only depends on objects from the `LibOpt_OptimizerRunController` dataset. 
    This is intentional to ensure that the polling only requires read access to the `LibOpt_OptimizerRunController` dataset. We don't want this method to depend on any other dataset for performance reasons.
  *]
  TextBody:
  [*
    // evr3 Apr-26-2022 (created)
    
    canstartstream := emit( canstart );
    
    // The run can be aborted before it is actually started. In this case, we should also stop polling the optimizer controller
    if( not canstart and not this.HasStopped() )
    {
      pollingduration := Duration::Millis( this.OptimizerRunController().PollingDuration() );
      canstartstream := stream[Void]::Wait( pollingduration )
                        ->|this->CanStart();
      canstartstream := this->PollOptimizerRunController( canstartstream );
    }
    
    return canstartstream;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}