Quintiq file version 2.0 
 | 
#parent: #root 
 | 
StaticMethod ThermalTrialRatio ( 
 | 
  Routing routing, 
 | 
  Unit unit, 
 | 
  Number capacity, 
 | 
  Date start, 
 | 
  Date end, 
 | 
  Number ratio 
 | 
) as owning Routings 
 | 
{ 
 | 
  Description: 'Check input is valid' 
 | 
  TextBody: 
 | 
  [* 
 | 
    // Adhi Feb-10-2016 (created) 
 | 
    thermaltrial := Unit::GetThermalTrial(); 
 | 
    newroutings := construct( Routings ); 
 | 
     
 | 
    for( starttime := start; starttime <= end; starttime := starttime + 1 ){ 
 | 
      uc := selectobject( unit, UnitCapacity, uc, uc.Start().Date() = starttime ); 
 | 
      if( isnull( uc ) ){ 
 | 
        uc := UnitCapacity::Create( unit, starttime.DateTime(), 'Day', 0.0, [Real]capacity, 100.0, 1, false ); 
 | 
      } 
 | 
      uc.MaxCapacity( [Real]capacity * ratio ); 
 | 
    } 
 | 
     
 | 
    newrouting := routing.Copy(); 
 | 
    name := newrouting.Name().ReplaceAll( 'Copy', thermaltrial ); 
 | 
    newrouting.Name( name ); 
 | 
    newrouting.UpdateTypeIndex( name ); 
 | 
    routing.Start( start ); 
 | 
    routing.End( end ); 
 | 
     
 | 
    routingstep := newrouting.LastStep(); 
 | 
    //info( '------------------', routingstep.Tool(), ',', unit.ID() ); 
 | 
    newroutingstep := RoutingStep::Create( newrouting, thermaltrial, routingstep.Tool(), false ); 
 | 
     
 | 
    traverse( routingstep, Operation, operation ){ 
 | 
      id := Operation::GetConcatenatedID( newrouting.ID(), newroutingstep.Name(), unit.ID() ); 
 | 
    //  info( '------------------', operation.Name(), routingstep.Name(), newroutingstep.Name() ); 
 | 
      stockingpoint := StockingPoint_MP::FindCreateUpdate( routing.MacroPlan(), thermaltrial, unit, newrouting, true ); 
 | 
       
 | 
      traverse( operation, OperationBOM, obom, not obom.IsInput() ){ 
 | 
        pisp := obom.PISPNodeInRouting().ProductInStockingPoint_MP(); 
 | 
    //    info( 'before----', ',', obom.StockingPointID(), pisp.StockingPointID(), pisp.ProductID() ); 
 | 
        obom.OldStockingPointID( obom.StockingPointID() ); 
 | 
        newpisp := pisp.Product_MP().AddToStockingPoint( stockingpoint ); 
 | 
    //    obom.PISPNodeInRouting().ProductInStockingPoint_MP( relset, newpisp ); 
 | 
        obom.PISPNodeInRouting().Update( newpisp.Product_MP(), newpisp.StockingPoint_MP() ); 
 | 
    //    afterpisp := obom.PISPNodeInRouting().ProductInStockingPoint_MP(); 
 | 
        obom.UpdateTypeIndex( obom.OperationID(), obom.ProductID(), stockingpoint.ID(), obom.IsInput() ); 
 | 
    //    info( 'after----', obom.StockingPointID(), afterpisp.StockingPointID(), afterpisp.ProductID() ); 
 | 
      } 
 | 
    //  info( '------------------------------', operation.SourceOperationLink( relsize ) ); 
 | 
       
 | 
      operation.Copy( newroutingstep, stockingpoint, id, unit ); 
 | 
    } 
 | 
     
 | 
    traverse( newrouting, RoutingStep.Operation.SourceOperationLink, ol ) 
 | 
    { 
 | 
      ol.SynchronizeAll( false ); 
 | 
    } 
 | 
     
 | 
    newroutings.Add( routing ); 
 | 
     
 | 
    return &newroutings; 
 | 
  *] 
 | 
} 
 |