Quintiq file version 2.0
#parent: #root
Method Optimizer_UpdateIconResultStatus () id:Method_ApplicationLibMacroPlanner_Optimizer_UpdateIconResultStatus
{
  #keys: '[144528.3.415842982]'
  Body:
  [*
    // Draw optimizer status
    scenario := DataHolderActiveScenario.Data();
    
    if( isnull( scenario ) )
    {
      ImageOptimizerStatus.Image( '' ); // Reset image if no active scenario (e.g scenario deleted and no more other active scenario)
    }
    else
    {                                             
      scenarioMP := scenario.astype( ScenarioMP );
      img := "";
      status := scenarioMP.OptimizerStatus();
      remark := scenarioMP.OptimizerRemark();
      runlevelfeedbacks := scenarioMP.RunUIfeedbacks();
      
      isrunning := MacroPlan::GetIsStatusRunning( status );
      lastrun := ifexpr( MacroPlan.LastOptimizerRun().IsInfinite(), "-", [String]MacroPlan.LastOptimizerRun() );
      
      if( isrunning )
      {
        img := "GEAR_RUN";
      }
      else if( Optimization::GetIsStatusTerminated( status ) )
      {
        img := "GEAR_STOP";
      }
      else if( Optimization::GetIsStatusFeasibleWithNumericalWarnings( status ) )
      {
        img := "GEAR_INFORMATION";
      }
      else if( Optimization::GetIsStatusInfeasibleExceedsTimeLimit( status, remark ) )
      {
        img := "GEAR_ERROR";
      }
      else if( Optimization::GetIsStatusInfeasibleWithinTimeLimit( status, remark ) )
      {
        img := "GEAR_WARNING";
      }
      else if( Optimization::GetIsStatusTimeLimitExceeded( status ) )
      {
        img := "GEAR_TIME";
      }
      else if( Optimization::GetIsStatusFeasibleExceedsTimeLimit( status, remark ) )
      {
        img := "GEAR_TIME";
      }
      else if( Optimization::GetIsStatusFeasibleWithinTimeLimit( status, remark ) )
      {
        img := "GEAR_OK"; 
      }
      
      ImageOptimizerStatus.Image( img );
      
      lastrunstatus := Translations::MP_Algorithm_OptimizerStatusTooltip( lastrun, status );
      
      if( isrunning )
      {
        lastrunstatus := Translations::MP_Designer_OptimizerIsRunning();
      }
      
      lastrunstatus := lastrunstatus + runlevelfeedbacks;
        
      ImageOptimizerStatus.Tooltip( lastrunstatus );
    }
  *]
}
