method Items.SchedulePDM (Item as HITEM, Key as Variant)
Scheduling the chart using the PDM.

 TypeDescription 
   Item as HITEM A long expression that specifies the handle of the item where the PDM starts, or 0, if the Key indicates an unique key of the bar that starts scheduling the PDM.  
   Key as Variant A VARIANT expression that specifies the key of the bar where the PDM begins. If the Item parameter is 0, the chart looks for the first bar with specified key.  
 ReturnDescription 
  LongA long expression that specifies if the operation was successfully (0), or any non-zero vaue, if the ScedulePDM method failed. 
The SchedulePDM method arrange the activities on the plan based on the links / relationships / dependencies. The SchedulePDM calculates early and late dates, based on bar's position, link types and link lag. The SchedulePDM starts from the giving bar, and continue arranging related bars, till done. If a bar has no related bars ( no incoming or outgoing links ) the procedure still looking for grouped or summary bars, till found some relative bars. The SchedulePDM method keeps count on the grouping bars, limited bars ( the bars that have margins, or range ), summary bars, non-working units, and any limit related to bars . For instance, the SchedulePDM method may fail if a bar can not be moved, and at some point it is required moving that bar. The ChartStartChaning(exPDM) event is fired once the SchedulePDM method is called. The ChartEndChaning(exPDM) event is fired once the SchedulePDM method is called. If Undo/Redo is available, the entire operation is hold as a block, so the chart can be restored by calling the Undo operation, or by pressing the CTRL + Z on chart. You can check the ChartUndoListAction property to lists the actions being performed during the SchedulePDM method. The DefSchedulePDM property defines options to be used by the SchedulePDM method. If required any option to be used the DefSchedulePDM should be called before the SchedulePDM method else it will have no effect. For instance, use the Def SchedulePDM property to specify a start date for the project, so the SchedulePDM method will use it, to arrange all bars so no bars will start before the specified date. The same if you require to specify the end of the project.

The following screen show shows the chart before calling the SchedulePDM on the Oplata bar:

The following screen show shows the chart after calling the SchedulePDM on the Oplata bar:

Calling SchedulePDM method invokes the BarResize event for all affected bars. 

In conclusion, if using the SchedulePDM method during a BarResize event, you can use a counter to prevent calling the SchedulePDM multiple times, like in the following sample VB:

Dim iSchedulePDM As Long
Private Sub G2antt1_BarResize(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    Debug.Print "BarResize invoked"
    If (iSchedulePDM = 0) Then
        iSchedulePDM = iSchedulePDM + 1
            G2antt1.Items.SchedulePDM Item, Key
        iSchedulePDM = iSchedulePDM - 1
    End If
End Sub

The following VB sample displays a message when the SchedulePDM starts and ends:

Private Sub G2antt1_ChartStartChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM starts"
    End If
End Sub

Private Sub G2antt1_ChartEndChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM ends"
    End If
End Sub

The output shows as follows:   

BarResize invoked
SchedulePDM starts
	BarResize invoked
	BarResize invoked
SchedulePDM ends

If using the SchedulePDM method during a BarResizing event, you can see the order of the events in the following VB sample:

Private Sub G2antt1_BarResize(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    Debug.Print "BarResize invoked"
End Sub

Private Sub G2antt1_BarResizing(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal Key As Variant)
    Debug.Print "BarResizing invoked"
    G2antt1.Items.SchedulePDM Item, Key
End Sub

Private Sub G2antt1_ChartStartChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM starts"
    End If
End Sub

Private Sub G2antt1_ChartEndChanging(ByVal Operation As EXG2ANTTLibCtl.BarOperationEnum)
    If (Operation = exPDM) Then
        Debug.Print "SchedulePDM ends"
    End If
End Sub

The output shows as follows:   

BarResizing invoked
SchedulePDM starts
	BarResize invoked
	BarResize invoked
SchedulePDM ends
BarResize invoked

So, knowing that the BarResize event could be fired during the SchedulePDM itself, you can use the following technique to prevent calling again the SchedulePDM:

iPDMRunning = 0

event ChartStartChaning(Operation)
    if ( Operation == exPDM (12) )
        iPDMRunning++

event ChartEndChaning(Operation)
    if ( Operation == exPDM (12) )
        iPDMRunning--

event BarResize(Item,Key)
    if ( iPDMRunning == 0 )
        Call SchedulePDM(Item,Key)

This snippet of code, ensures that the SchedulePDM is not called for inside BarResize event.

The SchedulePDM method handles bars as:

A link between two bars is:

For instance, a FS link between bar A and B, means that the bar B starts when bar A ends.  

The Link(exLinkPDMWorkingDelay) property indicates the working units between 2 linked bars. For instance, if bar A is linked FS with a bar B and the exLinkPDMWorkingDelay is 2, the bar B starts after 2 working days once the bar A ends. The Link(exLinkPDMDelay) property indicates the units between 2 linked bars. For instance, if bar A is linked FS with a bar B and the exLinkPDMDelay is 2, the bar B starts after 2 days once the bar A ends.

The following screen shot shows the chart using different type of links before calling the SchedulePDM:

The following screen shot shows the chart using different type of links after calling the SchedulePDM:

and if we move the first bar and call again the SchedulePDM we get ( the sample preserve the working units for each bar ):

The following screen shot shows the activities, when exLinkPDMWorkingDelay property is set for links ( SF has 1 working day, FS has 2 working days and the FF has 3 working days delay ) :

 


Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.