XPAC Reference Guide

A VB Equivalent to the MirrorHaulRoute function.

A VB Equivalent to the MirrorHaulRoute function.

Previous topic Next topic  

A VB Equivalent to the MirrorHaulRoute function.

Previous topic Next topic  

The following function performs identical functionality to the MirrorHaulRoute function. Users of the TravelTime objects may wish to use a modified version of this code to implement mirror functionality that suits the given simulation scenario.

Sub Mirror()
Dim tt As Object
Set tt = CreateObject("TRAVELTIMECOM.TravelTime")
 
Dim hr As Object
Set hr = tt.HaulRoute
 hr.LoadTalpacTextFile ("C:\Haul Cycle1.txt")
 
Dim segCount As Double
 segCount = hr.Count
 
Dim bFoundLast As Boolean
 
For lRow = segCount - 1 To 0 Step -1
  Dim orig As Object
  Set orig = hr.Item(lRow)
  Dim seg As Object
  Set seg = CreateObject("TRAVELTIMECOM.HaulSegment")
     
  Set seg = orig
     
  If Not bFoundLast Then
     orig.FinalVelocity = 0
     bFoundLast = True
  End If
     
  ' Reverse Grade
  Dim dGrade As Double
   dGrade = seg.Grade
   seg.Grade = -dGrade
     
  ' Reverse Load
  Dim dWeight As Double
   dWeight = seg.WeightPercent
  If dWeight > 0# Then
     seg.WeightPercent = 0#
  Else
     seg.WeightPercent = 100
  End If
     
  ' Add the new segment
   hr.Add seg
     
 
Next lRow
If segCount > 0 Then
  ' Set the final forward velocity to 0.
   orig.FinalVelocity = 0
End If
 
 
' Final of previous must not exceed max of current
For lRow = segCount To hr.Count() - 2
  Dim SegFirst As Object
  Dim SegNext As Object
  Set SegFirst = hr.Item(lRow)
  Set SegNext = hr.Item(lRow + 1)
     
  Dim dMaxVel As Double
   dMaxVel = SegNext.MaximumVelocity
     
     
  If (dMaxVel <> HRP_MAX_VEL_MAX) Then
    Dim dFinalVel As Double
     dFinalVel = SegFirst.FinalVelocity
    If (dFinalVel < 0 Or dFinalVel > dMaxVel) Then
       SegFirst.FinalVelocity = dMaxVel
    End If
  End If
 
Next lRow
 
 hr.SaveToFile ("C:\Haul CycleMirror.txt")

End Sub