chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
Quintiq file version 2.0
#parent: #root
Method SynchronizeTools (
  LibOpt_Scope scope
)
{
  Description:
  [*
    Method to create Tool and ToolInUnitPeriod objects.
    These objects are used as index objects within the optimizer
  *]
  TextBody:
  [*
    this.MacroPlan().Tool( relflush); 
    
    traverse( scope.GetUnitInOptimizerRun(), Elements, unit, unit.HasToolOperations() ) 
    {
      traverse( unit, UnitPeriod, up, scope.Contains( up.UnitPeriodInOptimizerRun() ) )
      {
        unitperiodoperations := this.GetOperationsForUnitPeriod( scope, up );
        unitperiodtools := selectuniquevalues( unitperiodoperations, Elements.RoutingStep, routingstep, true, routingstep.Tool() );
        
        traverse( unitperiodtools, Elements, toolname, toolname.Length() > 0)
        {
          tool := select( this, MacroPlan.Tool, t, t.Name() = toolname );
          
          if ( isnull( tool ) )
          {
            tool := this.MacroPlan().Tool( relnew, Name := toolname )
          }
          if( not exists( tool, ToolInUnitPeriod.UnitPeriod, unitperiod, unitperiod = up ) )
          {
            toolinperiod := tool.ToolInUnitPeriod( relnew )
            toolinperiod.UnitPeriod( relset, up)
          }  
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}