Attribute VB_Name = "Module1"
'#Uses "..\classes\InterruptClass.cls"
'#Uses "..\classes\ModuleClass.cls"
'#Uses "..\classes\Port.cls"
'#Uses "..\classes\PortPin.cls"
'#Uses "..\classes\ManualLinkClass.cls"
'#Uses "Global.inc"

Option Explicit
'*****************************************************************************
' Module:
'
'-----------------------------------------------------------------------------
' Description:
'                This module contains global functions that must be used
'                to install the system.
'
'-----------------------------------------------------------------------------
' History:
'
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'*****************************************************************************

'*****************************************************************************
' @bfunc   Public | InstallBackimage | |
'
'-----------------------------------------------------------------------------
'          This function loades the first bitmap.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | gc | GraphicConfigure |
'
'*****************************************************************************
Public Function InstallBackimage(gc As GraphicConfigure) As Boolean
  On Error Resume Next
  InstallBackimage = False
  Dim Controller As String
  Controller = DefGetValue("Name")
  If (Not gc.LoadBackimage(DefGetPath("Bitmaps") & "main" & Controller & ".bmp", 680, 400)) Then Exit Function

  InstallBackimage = True
End Function

'*****************************************************************************
' @bfunc   Public | InstallModule | Boolean |
'
'-----------------------------------------------------------------------------
'          For each module that should be used in the system a line
'          "Call AddModule .." must be insert in this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | d | DAvECollection | the collection of the modules
'
'*****************************************************************************
Public Function InstallModule(d As DAvECollection) As Boolean
  On Error Resume Next
  InstallModule = False

  ' for each module in the system the function AddModule must be called
  '
  ' AddModule(c As DAvECollection, ModuleName As String, ModuleDescription As String,
  '           ModuleDirectory As String, ParameterValue As Integer, ModuleWithCG As Boolean) As Boolean
  '
  ' c                 | DAvECollection | the module collection
  ' ModuleName        | String         | identifier of the module
  ' ModuleDescription | String         | name of the module
  ' ModuleDirectory   | String         | sub directory name of this module
  ' ParameterValue    | Variant        | a parameter for the new script file
  ' ModuleWithCG      | Boolean        | indicates if the module has an codegenerator or not
  
  Call GetModuleDetails
  'Start (P11 - Jai)
  Call GetControllerDetails
  'End (P11 - Jai)
  If (Not AddModule(d, "MAIN", "Project Settings", "MAIN", "", True)) Then Exit Function

  If ModuleCheck("IO") Then
    If (Not AddModule(d, "IO", "Parallel Ports", "IO", "", True)) Then Exit Function
  End If

  
  If ModuleCheck("USIC0") Then   'USIC0
    If (Not AddModule(d, "USIC0", "Universal Serial Interface Channel (USIC0)", "USIC", "0", False)) Then Exit Function
  End If

  If ModuleCheck("USIC1") Then   'USIC0
    If (Not AddModule(d, "USIC1", "Universal Serial Interface Channel (USIC1)", "USIC", "1", False)) Then Exit Function
  End If

  If ModuleCheck("USIC2") Then   'USIC0
    If (Not AddModule(d, "USIC2", "Universal Serial Interface Channel (USIC2)", "USIC", "2", False)) Then Exit Function
  End If


  If ModuleCheck("U0C0") Then   'USIC0
    If (Not AddModule(d, "U0C0", "Universal Serial Interface Channel (USIC) U0C0", "USIC", "U0C0", True)) Then Exit Function
  End If
  If ModuleCheck("U0C1") Then
    If (Not AddModule(d, "U0C1", "Universal Serial Interface Channel (USIC) U0C1", "USIC", "U0C1", True)) Then Exit Function
  End If
  If ModuleCheck("U1C0") Then   'USIC1
    If (Not AddModule(d, "U1C0", "Universal Serial Interface Channel (USIC) U1C0", "USIC", "U1C0", True)) Then Exit Function
  End If
  If ModuleCheck("U1C1") Then
    If (Not AddModule(d, "U1C1", "Universal Serial Interface Channel (USIC) U1C1", "USIC", "U1C1", True)) Then Exit Function
  End If
  If ModuleCheck("U2C0") Then   'USIC2
    If (Not AddModule(d, "U2C0", "Universal Serial Interface Channel (USIC) U2C0", "USIC", "U2C0", True)) Then Exit Function
  End If
  If ModuleCheck("U2C1") Then
    If (Not AddModule(d, "U2C1", "Universal Serial Interface Channel (USIC) U2C1", "USIC", "U2C1", True)) Then Exit Function
  End If
  If ModuleCheck("GPT1") Then
    If (Not AddModule(d, "GPT1", "General Purpose Timer Unit (GPT1)", "GPT1", "", True)) Then Exit Function
  End If
  If ModuleCheck("GPT2") Then
    If (Not AddModule(d, "GPT2", "General Purpose Timer Unit (GPT2)", "GPT2", "", True)) Then Exit Function
  End If
  If ModuleCheck("CC2") Then
    If (Not AddModule(d, "CC2", "Capture / Compare Unit 2 (CAPCOM2)", "CCx", 2, True)) Then Exit Function
  End If
  If ModuleCheck("CCU60") Then
    If (Not AddModule(d, "CCU60", "Capture / Compare Unit 60 (CCU60)", "CC6x", 60, True)) Then Exit Function
  End If
  
  If ModuleCheck("CCU61") Then
    If (Not AddModule(d, "CCU61", "Capture / Compare Unit 61 (CCU61)", "CC6x", 61, True)) Then Exit Function
  End If
  If ModuleCheck("CCU62") Then
    If (Not AddModule(d, "CCU62", "Capture / Compare Unit 62 (CCU62)", "CC6x", 62, True)) Then Exit Function
  End If
  If ModuleCheck("CCU63") Then
    If (Not AddModule(d, "CCU63", "Capture / Compare Unit 63 (CCU63)", "CC6x", 63, True)) Then Exit Function
  End If
  If ModuleCheck("ADC Clock") Then
    If (Not AddModule(d, "ADC Clock", "Analog / Digital Converter (ADC) Clock", "ADCx", "Clock", True)) Then Exit Function
  End If

  If ModuleCheck("ADC0") Then
    If (Not AddModule(d, "ADC0", "Analog / Digital Converter  (ADC0)", "ADCx", "0", True)) Then Exit Function
  End If
  If ModuleCheck("ADC1") Then
    If (Not AddModule(d, "ADC1", "Analog / Digital Converter (ADC1)", "ADCx", "1", True)) Then Exit Function
  End If
  If ModuleCheck("RTC") Then
    If (Not AddModule(d, "RTC", "Real Time Clock (RTC)", "RTC", "", True)) Then Exit Function
  End If
  If ModuleCheck("CAN") Then
    If (Not AddModule(d, "CAN", "MultiCAN Module (CAN)", "CAN", "", True)) Then Exit Function
  End If
  If ModuleCheck("INT") Then
    If (Not AddModule(d, "INT", "Interrupt Controller (INT)", "INT", "", True)) Then Exit Function
  End If
  If ModuleCheck("WDT") Then
    If (Not AddModule(d, "WDT", "Watchdog Timer (WDT)", "WDT", "", True)) Then Exit Function
  End If
  If ModuleCheck("SCU") Then
    If (Not AddModule(d, "SCU", "System Control Unit (SCU)", "SCU", "", True)) Then Exit Function
  End If
'Commented on 05.12.07
'for not providing in beta
''  If ModuleCheck("EBC") Then
''    If (Not AddModule(d, "EBC", "External Bus Controller (EBC)", "EBC", "", True)) Then Exit Function
''  End If

  InstallModule = True


End Function

'*****************************************************************************
' @bfunc   Public | InstallHotspots | Boolean |
'
'-----------------------------------------------------------------------------
'          For each hotspot on the backimage a line "m.AddHotspot .."
'          must be insert in this function.
'
'          NOTE:
'          The identifiere of the hotspot must be have the same name as the
'          identifiere of the module which was added with the function
'          AddModule.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | gc | GraphicConfigure |
'
'*****************************************************************************
Public Function InstallHotspots(gc As GraphicConfigure) As Boolean
  On Error Resume Next
  Dim iModIndex As Integer
  Dim iModCount As Integer
  InstallHotspots = False
  
  ' *************************
  ' Include For loop, get the module name from the "Type" and concatenate with ".bmp"
  ' *************************
  
    iModCount = UBound(ModuleDetails)
    For iModIndex = 0 To iModCount - 1
       With ModuleDetails(iModIndex)
           If (Not gc.AddHotspot(.ModuleName, DefGetPath("Bitmaps") & .ModuleName & ".bmp", .Left, .Top, .Left, .Top, .Width, .Height)) Then Exit Function
       End With
    Next iModIndex

  InstallHotspots = True
End Function

'*****************************************************************************
' @bfunc   Public | InstallInterrupts | Boolean |
'
'-----------------------------------------------------------------------------
'          For each interrupt that should be used in the system a line
'          "Call AddInterrupt .." must be inserted in this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | c | DAvECollection | the collection of the interrupts
'
'*****************************************************************************
Public Function InstallInterrupts(c As DAvECollection) As Boolean
  On Error Resume Next
  
  InstallInterrupts = False
  
  Dim v As Variant
  Dim i As Integer

  ' for each interrupt in the system the function AddInterrupt must be called
  '
  ' AddInterrupt(c As DAvECollection, IntName As String, LevelName As String,
  '              GroupName As String) As Boolean
  '
  ' c         | DAvECollection | the interrupt collection
  ' IntName   | String         | name of the interrupt
  ' LevelName | String         | name of the level bit field
  ' GroupName | String         | name of the group bit field
  ' Enabled   | String         | name of the int. enabled bit
  ' RegName   | String         | name of the interupt control register; now bit name

  'GPT1 Interrupts
  If (ModuleCheck("GPT1")) Then
        v = "GPT12E_T2IC"
        If (Not AddInterrupt(c, "GPT1 T2 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "GPT12E_T3IC"
        If (Not AddInterrupt(c, "GPT1 T3 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "GPT12E_T4IC"
        If (Not AddInterrupt(c, "GPT1 T4 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'GPT2 Interrupts
  If (ModuleCheck("GPT2")) Then
        v = "GPT12E_CRIC"
        If (Not AddInterrupt(c, "GPT2 CAPREL INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "GPT12E_T5IC"
        If (Not AddInterrupt(c, "GPT2 T5 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "GPT12E_T6IC"
        If (Not AddInterrupt(c, "GPT2 T6 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'USIC - U0C0 Interrupts
  If (ModuleCheck("U0C0")) Then
        v = "U0C0_0IC"
        If (Not AddInterrupt(c, "U0C0_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U0C0_1IC"
        If (Not AddInterrupt(c, "U0C0_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U0C0_2IC"
        If (Not AddInterrupt(c, "U0C0_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If
   
  'USIC - U0C1 Interrupts
  If (ModuleCheck("U0C1")) Then
        v = "U0C1_0IC"
        If (Not AddInterrupt(c, "U0C1_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U0C1_1IC"
        If (Not AddInterrupt(c, "U0C1_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U0C1_2IC"
        If (Not AddInterrupt(c, "U0C1_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'USIC - U1C0 Interrupts
  If (ModuleCheck("U1C0")) Then
        v = "U1C0_0IC"
        If (Not AddInterrupt(c, "U1C0_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U1C0_1IC"
        If (Not AddInterrupt(c, "U1C0_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U1C0_2IC"
        If (Not AddInterrupt(c, "U1C0_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'USIC - U1C1 Interrupts
  If (ModuleCheck("U1C1")) Then
        v = "U1C1_0IC"
        If (Not AddInterrupt(c, "U1C1_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U1C1_1IC"
        If (Not AddInterrupt(c, "U1C1_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U1C1_2IC"
        If (Not AddInterrupt(c, "U1C1_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'USIC - U2C0 Interrupts
  If (ModuleCheck("U2C0")) Then
        v = "U2C0_0IC"
        If (Not AddInterrupt(c, "U2C0_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U2C0_1IC"
        If (Not AddInterrupt(c, "U2C0_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U2C0_2IC"
        If (Not AddInterrupt(c, "U2C0_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'USIC - U2C1 Interrupts
  If (ModuleCheck("U2C1")) Then
        v = "U2C1_0IC"
        If (Not AddInterrupt(c, "U2C1_0IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U2C1_1IC"
        If (Not AddInterrupt(c, "U2C1_1IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "U2C1_2IC"
        If (Not AddInterrupt(c, "U2C1_2IC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If
  
  'PEC Interrupt
  v = "EOPIC"
''  If (Not AddInterrupt(c, "EOP INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
    If (Not AddInterrupt(c, "EOP INT", v & "_ILVL", v & "_GLVL", v & "_EOPIE", v)) Then Exit Function

  'RTC Interrupt
  If (ModuleCheck("RTC")) Then
        v = "RTC_IC"
        If (Not AddInterrupt(c, "RTC INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  'ADC Interrupts
  
  If (ModuleCheck("ADC0")) Then
    For i = 0 To 3
      'ADC Interrupt
      v = "ADC_" & i & "IC"
      If (Not AddInterrupt(c, "ADC INT " & i, v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
    Next i
  End If

  If (ModuleCheck("ADC1")) Then
    For i = 4 To 7
      'ADC Interrupt
      v = "ADC_" & i & "IC"
      If (Not AddInterrupt(c, "ADC INT " & i, v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
    Next i
  End If
  
  If (ModuleCheck("CC2")) Then
        v = "CC2_T7IC"
        If (Not AddInterrupt(c, "CC2 T7 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
        v = "CC2_T8IC"
        If (Not AddInterrupt(c, "CC2 T8 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If
  
 
  If (ModuleCheck("CC2")) Then
          For i = 16 To 31
              v = "CC2_CC" & i & "IC"
              If (Not AddInterrupt(c, "CC2 Ch" & i & " INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
          Next i
  End If
  
 'CC60 Interrupts
  If (ModuleCheck("CCU60")) Then
      v = "CCU60_0IC"
      If (Not AddInterrupt(c, "CCU60 I0 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU60_1IC"
      If (Not AddInterrupt(c, "CCU60 I1 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU60_2IC"
      If (Not AddInterrupt(c, "CCU60 I2 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU60_3IC"
      If (Not AddInterrupt(c, "CCU60 I3 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If
'CC61 Interrupts
  If (ModuleCheck("CCU61")) Then
      v = "CCU61_0IC"
      If (Not AddInterrupt(c, "CCU61 I0 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU61_1IC"
      If (Not AddInterrupt(c, "CCU61 I1 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU61_2IC"
      If (Not AddInterrupt(c, "CCU61 I2 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU61_3IC"
      If (Not AddInterrupt(c, "CCU61 I3 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

'CC62 Interrupts
  If (ModuleCheck("CCU62")) Then
      v = "CCU62_0IC"
      If (Not AddInterrupt(c, "CCU62 I0 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU62_1IC"
      If (Not AddInterrupt(c, "CCU62 I1 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU62_2IC"
      If (Not AddInterrupt(c, "CCU62 I2 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU62_3IC"
      If (Not AddInterrupt(c, "CCU62 I3 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

'CC63 Interrupts
  If (ModuleCheck("CCU63")) Then
      v = "CCU63_0IC"
      If (Not AddInterrupt(c, "CCU63 I0 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU63_1IC"
      If (Not AddInterrupt(c, "CCU63 I1 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU63_2IC"
      If (Not AddInterrupt(c, "CCU63 I2 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "CCU63_3IC"
      If (Not AddInterrupt(c, "CCU63 I3 INT", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

'WDT Interrupts
  If (ModuleCheck("WDT")) Then
      v = "SCU_0IC"
      If (Not AddInterrupt(c, "WDT_INT0", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
      v = "SCU_1IC"
      If (Not AddInterrupt(c, "WDT_INT1", v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
  End If

  If (ModuleCheck("CAN")) Then
    For i = 0 To 15
      'CAN Interrupt
      v = "CAN_" & i & "IC"
      If (Not AddInterrupt(c, "CAN INT " & i, v & "_ILVL", v & "_GLVL", v & "_IE", v)) Then Exit Function
    Next i
  End If


  InstallInterrupts = True
End Function

'*****************************************************************************
' @bfunc   Public | InstallPorts | Boolean |
'
'-----------------------------------------------------------------------------
'          For each Port which should be used in the system a line
'          "Call AddPort .." must be insert in this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | cPorts | DAvECollection | the collection of the ports
'
'*****************************************************************************
Public Function InstallPorts(cPorts As DAvECollection) As Boolean
  On Error Resume Next
  InstallPorts = False
   
  Dim iPort As Integer
   
  ' for each port in the system the function AddPort must be called
  '
  'AddPort(p As DAvECollection, vPortNumber As Variant, sPortDescription As String, iFirstPin As Integer, _
  '        iLastPin As Integer, Optional iInputThresholdType As Integer = 0, Optional iOutputEdgeType As Integer = 0, _
  '        Optional iOutputDriverType As Integer = 0) As Boolean
  '
  ' cPorts              | DAvECollection | the port collection
  ' vPortNumber         | Variant        | number of the port
  ' sPortDescription    | String         | name (description) of the port
  ' iFirstPin           | Integer        | number of the first pin that should be shown in the mask
  ' iLastPin            | Integer        | number of the last pin that should be shown in the mask

  ' iInputThresholdType | Integer        | the input threshold type can be configured pin- (1), nible- (2),
  '                                        byte- (3) or port-wise (4)
  ' iOutputEdgeType     | Integer        | the output edge characteristic can be configured pin- (1), nible- (2),
  '                                        byte- (3) or port-wise (4)
  ' iOutputDriverType   | Integer        | the output driver characteristic can be configured pin- (1), nible- (2),
  '                                        byte- (3) or port-wise (4)

Call GetPortpinDetails
 
 For iPort = 0 To UBound(Ports) - 1                      ' Looping for number of ports
     With Ports(iPort)
          If (Not AddPort(cPorts, .PortName, .PortDescription, .StartPin, .LastPin, .InputChar, .EdgeChar, .DriveStrength)) Then Exit Function
     End With
Next iPort

  InstallPorts = True
End Function

'*****************************************************************************
' @bfunc   Public | InstallPortPins | Boolean |
'
'-----------------------------------------------------------------------------
'          For each Pin which should be used in the system a line
'          "Call AddPin .." must be insert in this function.
'          For each alternate pin name that should be used in the system a
'          line "Call AddAlternateName .." must be insert in this function.
'
'          Note:
'          For each added pin a project variable with the name "MuxFor_Px_y"
'          must be exist in the *.vars file. And for each alternate pin name
'          a project variable with the name "MuxFor_AlternateName" must be
'          exist.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | p | DAvECollection | the collection of the pins
'
'*****************************************************************************
Public Function InstallPortPins(p As PortPin) As Boolean
  On Error Resume Next
  InstallPortPins = False

  Dim i As Integer
  Dim j As Integer
  Dim k As Integer

  ' for each Pin in the system the function AddPin must be called
  '
  ' AddPin(p As PortPin, vPort as Variant, iPin As Integer, bUse As Boolean, Optional bExclusive As Boolean = False) As Boolean
  '
  ' p                 | PortPin    | class for the port pins
  ' vPort             | Variant    | number of the port
  ' iPin              | Integer    | number of the pin
  ' bUse              | Boolean    | flag that shows if the pin is availible
  ' bExclusive        | Boolean    | flag that shows if the pin should be used exclusive


  ' for each alternate pin name in the system the function AddAlternateName must be
  ' called
  '
  ' AddAlternateName(p As PortPin, sAlternateName As String, sDescription As String, _
  '                  Optional bExclusive As Boolean = False, Optional iFunction As Integer = 1) As Boolean

  '
  ' p                 | PortPin    | object of the class for the port pins
  ' sAlternateName    | String     | alternate name of a pin (used as identifier)
  ' sDescription      | String     | description of the alternate pin function
  ' bExclusive        | Boolean    | flag that shows if the pin should be used exclusive
  ' iFunction         | Integer    | number of the alternate output function of this pin
  '                                  (used for the ALTSEL registers), -1 means the pin is input
  
 For i = 0 To UBound(PortDetails) - 1                      ' Looping for number of ports

   For j = 0 To UBound(PortDetails(i).PinDetails) - 1      ' Looping for number of pins in each port

           With PortDetails(i).PinDetails(j)
               If (Not AddPin(p, .PortName, .PinNum, True, True)) Then Exit Function

               For k = 0 To UBound(.sAltName) - 1          ' Looping for number of alterante functions for each pin in each port
                If (CInt(.iFunction(k)) = 0) Then

                    If (.bExclusive(k) = True) Then
                       If (Not AddAlternateName(p, CStr(.sAltName(k)), CStr(.sDescription(k)), True)) Then Exit Function
                    Else
                       If (Not AddAlternateName(p, CStr(.sAltName(k)), CStr(.sDescription(k)), False)) Then Exit Function
                    End If
                ElseIf (CInt(.iFunction(k)) > 0) Then
                    If (.bExclusive(k) = True) Then
                       If (Not AddAlternateName(p, CStr(.sAltName(k)), CStr(.sDescription(k)), True, CInt(.iFunction(k)))) Then Exit Function
                    Else
                       If (Not AddAlternateName(p, CStr(.sAltName(k)), CStr(.sDescription(k)), False, CInt(.iFunction(k)))) Then Exit Function
                    End If
                End If

               Next k

           End With
   Next j

 Next i
        If (Not p.Sort) Then Exit Function

  InstallPortPins = True
End Function

'*****************************************************************************
' @bfunc   Public | InstallManualLinks | Boolean |
'
'-----------------------------------------------------------------------------
'          For each Script which has a Manual Link menu a line
'          ".. AddMenu .." must be inserted in this function.
'          For each Link in this menu a
'          line ".. AddLink .." must be inserted in this function.
'
'          Note:
'          For each added Link a entry with the link key must be inserted in
'          the *.def file under the specified section.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | p | DAvECollection | the collection of the pins
'
'*****************************************************************************
Public Function InstallManualLinks(m As ManualLinkClass) As Boolean
  On Error Resume Next
  InstallManualLinks = False
 
  Dim sDefSection As String

  ' for each Script which has a Manual Link menu the property AddMenu must be called
  '
  ' AddMenu(sScriptName As String) As Boolean
  '
  ' sScriptName  | String   | name and subdirectory of the scriptfile (e.g. "SSCx\Dialog")


  ' for each Link in the menu the proberty AddLink must be called
  '
  ' AddLink(sDefSection As String, sLinkName As String, Optional sKeyName As String = "", Optional bGroup As Boolean = False) As Boolean

  '
  ' sDefSection  | String   | name of the section in the *.def file
  ' sLinkName    | String   | caption of the manual link which shows in the menu
  ' sKeyName     | String   | name of the link entry in the *.def file under the section
  '                           specified with sDefSection. This name can be the same as sLinkName.
  '                           If this an empty string then the name from sLinkName are used automatically.
  ' bGroup       | Boolean  | if true then a new group (line) in the menu was created

' sDefSection = "Main"
'    AddManualLink m, "Main\Dialog", sDefSection
'
' If ModuleCheck("INT") Then
'    sDefSection = "INT"
'    AddManualLink m, "INT\Dialog", sDefSection
'    AddManualLink m, "PEC\PEC", sDefSection
' End If
'
' If ModuleCheck("SCU") Then
'    sDefSection = "SCU"
'    AddManualLink m, "SCU\Dialog", sDefSection
' End If
'
' If ModuleCheck("WDT") Then
'    sDefSection = "WDT"
'    AddManualLink m, "WDT\Dialog", sDefSection
'End If
'
' If ModuleCheck("IO") Then
'    sDefSection = "IO"
'    AddManualLink m, "IO\Dialog", sDefSection
'    AddManualLink m, "IO\Port0", sDefSection
'    AddManualLink m, "IO\Port1", sDefSection
'    AddManualLink m, "IO\Port2", sDefSection
'    AddManualLink m, "IO\Port3", sDefSection
'    AddManualLink m, "IO\Port4", sDefSection
'    AddManualLink m, "IO\Port5", sDefSection
'    AddManualLink m, "IO\Port6", sDefSection
'    AddManualLink m, "IO\Port7", sDefSection
'    AddManualLink m, "IO\Port8", sDefSection
'    AddManualLink m, "IO\Port9", sDefSection
'    AddManualLink m, "IO\Port10", sDefSection
'    AddManualLink m, "IO\Port11", sDefSection
'    AddManualLink m, "IO\Port15", sDefSection
' End If
'
' If ModuleCheck("RTC") Then
'    sDefSection = "RTC"
'    AddManualLink m, "RTC\Dialog", sDefSection
' End If
'
' If ModuleCheck("ADC") Then
'    sDefSection = "ADC"
'    AddManualLink m, "ADC\Dialog", sDefSection
'    AddManualLink m, "ADC\NormalControl", sDefSection
'    AddManualLink m, "ADC\EnhancedControl", sDefSection
' End If
'
' If ModuleCheck("CC2") Then
'    sDefSection = "CCx"
'    AddManualLink m, "CCx\Channel_x", sDefSection
'    AddManualLink m, "CCx\Dialog", sDefSection
' End If
'
' If ModuleCheck("GPT1") Then
'    sDefSection = "GPT1"
'    AddManualLink m, "GPT1\Dialog", sDefSection
' End If
'
' If ModuleCheck("GPT2") Then
'    sDefSection = "GPT2"
'    AddManualLink m, "GPT2\Dialog", sDefSection
' End If
'
' If ModuleCheck("CAN") Then
'    sDefSection = "CAN"
'    AddManualLink m, "CAN\Dialog", sDefSection
'    AddManualLink m, "CAN\Nodex", sDefSection
'    AddManualLink m, "CAN\Objx", sDefSection
' End If
'
' If ModuleCheck("CCU60") Then
'    sDefSection = "CC6x"
'    AddManualLink m, "CC6x\Dialog", sDefSection
'    AddManualLink m, "CC6x\CC6_CHANNEL_012", sDefSection
'    AddManualLink m, "CC6x\CC6_CHANNEL_3", sDefSection
'    AddManualLink m, "CC6x\CC6_INERRUPT_NODE", sDefSection
' End If
' If ModuleCheck("CCU61") Then
'    sDefSection = "CC6x"
'    AddManualLink m, "CC6x\Dialog", sDefSection
'    AddManualLink m, "CC6x\CC6_CHANNEL_012", sDefSection
'    AddManualLink m, "CC6x\CC6_CHANNEL_3", sDefSection
'    AddManualLink m, "CC6x\CC6_INERRUPT_NODE", sDefSection
' End If
 
  InstallManualLinks = True
End Function

'*****************************************************************************
'*****************************************************************************
'                    Do not change the following code !!
'*****************************************************************************
'*****************************************************************************


'*****************************************************************************
' @bfunc   Public | AddInterrupt | |
'
'-----------------------------------------------------------------------------
'          This function adds a new interrupt source to a collection. Each
'          interrupt which should be displayed on the interrupt page must be
'          added with this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | c | DAvECollection | the interrupt collection
' @bparm   | IntName | String | name of the interrupt
' @bparm   | LevelName | String | name of the level bit field
' @bparm   | GroupName | String | name of the group bit field
' @bparm   | Enabled   | String | name of the enabled bit
' @bparm   | RegName           | String | name of the interrupt control register; now bit name
'
'*****************************************************************************
Public Function AddInterrupt(c As DAvECollection, IntName As String, LevelName As String, GroupName As String, Enabled As String, RegName As String) As Boolean
  On Error Resume Next
  AddInterrupt = False

  Dim ir As InterruptClass

  Set ir = New InterruptClass
  ir.LevelName = LevelName
  ir.GroupName = GroupName
  ir.IntName = IntName
  ir.Enabled = Enabled
  ir.RegName = Enabled
  
  'ahe 07.08.2002
  ir.GPXName = RegName & "_GPX"

  c.Add ir, IntName

  AddInterrupt = True
End Function


'*****************************************************************************
' @bfunc   Public | AddModule | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a new module to a collection. Each module which
'          should be used in the system must be added with this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | c | DAvECollection | the module collection
' @bparm   | ModuleName | String | identifier of the module
' @bparm   | ModuleDescription | String | name of the module
' @bparm   | ModuleDirectory   | String  | sub directory name of this module
' @bparm   | ParameterValue    | Variant | a parameter for the new script file
' @bparm   | ModuleWithCG      | Boolean | indicates if the module has an codegenerator or not
'
'*****************************************************************************
Public Function AddModule(c As DAvECollection, ModuleName As String, ModuleDescription As String, _
                          ModuleDirectory As String, ParameterValue As Variant, Optional ModuleWithCG As Boolean = True) As Boolean
  On Error GoTo AddModuleError
  AddModule = False

  Dim mo As ModuleClass

  Set mo = New ModuleClass
  mo.ModuleName = ModuleName
  mo.ModuleDescription = ModuleDescription
  mo.ModuleDirectory = ModuleDirectory
  mo.ParameterValue = ParameterValue
  mo.ModuleWithCG = ModuleWithCG
  c.Add mo, ModuleName

  AddModule = True
  Exit Function

AddModuleError:
  ErrorBox "Can not install modules", Err.Description
  Exit Function
End Function


'*****************************************************************************
' @bfunc   Public | AddPort | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a new Port to a collection. Each Port which
'          should be used in the system must be added with this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | p                   | DAvECollection | the port collection
' @bparm   | vPortNumber         | Variant | number of the port
' @bparm   | sPortDescription    | String  | name of the port (description)
' @bparm   | iFirstPin           | Integer | number of the first pin that should be shown in the mask
' @bparm   | iLastPin            | Integer | number of the last pin that should be shown in the mask
' @bparm   | iInputThresholdType | Integer | the input threshold type can be configured pin- (1), nible- (2),
'                                            byte- (3) or port-wise (4)
' @bparm   | iOutputEdgeType     | Integer | the output edge characteristic can be configured pin- (1), nible- (2),
'                                            byte- (3) or port-wise (4)
' @bparm   | iOutputDriverType   | Integer | the output driver characteristic can be configured pin- (1), nible- (2),
'                                            byte- (3) or port-wise (4)
'
'*****************************************************************************
Public Function AddPort(p As DAvECollection, vPortNumber As Variant, sPortDescription As String, iFirstPin As Integer, _
                        iLastPin As Integer, Optional iInputThresholdType As Integer = 0, Optional iOutputEdgeType As Integer = 0, _
                        Optional iOutputDriverType As Integer = 0) As Boolean
  On Error Resume Next
  AddPort = False
  Dim newPort As Port

  Set newPort = New Port
  
  newPort.PortNumber = vPortNumber
  newPort.Description = sPortDescription
  newPort.FirstPin = iFirstPin
  newPort.LastPin = iLastPin

  newPort.InputThresholdType = iInputThresholdType
  newPort.OutputEdgeType = iOutputEdgeType
  newPort.OutputDriverType = iOutputDriverType

  p.Add newPort, "P" & vPortNumber

  AddPort = True
End Function

'*****************************************************************************
' @bfunc   Public | AddPin | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a new Pin to the system. Each Pin which
'          should be used in the system must be added with this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' p          object of the class for the port pins
' vPort      number of the port
' iPin       number of the pin
' bUse       flag that shows if the pin is availible
' bExclusive flag that shows if the pin should be used exclusive
'
'*****************************************************************************
Public Function AddPin(p As PortPin, vPort As Variant, iPin As Integer, bUse As Boolean, Optional bExclusive As Boolean = False) As Boolean
  On Error Resume Next
  AddPin = False

  Dim s As String
  
   If bUse Then
     If (vPort = 5) Then
       s = "Use P" & vPort & "." & iPin & " as general Input"
     ElseIf (vPort = 15) Then
       s = "Use P" & vPort & "." & iPin & " as general Input"
     Else
     s = "Use P" & vPort & "." & iPin & " as general IO"
     End If
   Else
    s = "P" & vPort & "." & iPin & " no pin assigned"
   End If
        If (Not p.Add("P" & vPort & "_" & iPin, vPort, iPin, s, bUse, bExclusive)) Then Exit Function

  AddPin = True
End Function

'*****************************************************************************
' @bfunc   Public | AddAlternateName | Boolean |
'
'-----------------------------------------------------------------------------
'          This function adds a new alternate name to a Pin. Each alternate
'          name which should be used in the system must be added with this
'          function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | p     | PortPin | object of the class for the port pins
' @bparm   | sAlternateName | String | alternate name of a pin (used as identifier)
' @bparm   | sDescription | String | description of the alternate pin function
'        bExclusive      flag that shows if the pin should be used exclusive
'        iFunction       number of the alternate output function of this pin
'                        (used for the ALTSEL registers), -1 means the pin is input
'
'*****************************************************************************
Public Function AddAlternateName(p As PortPin, sAlternateName As String, sDescription As String, _
                                 Optional bExclusive As Boolean = False, Optional iFunction As Integer = -1) As Boolean
  On Error Resume Next
  AddAlternateName = False

        If (Not p.AddAlternateName(sAlternateName, sDescription, bExclusive, iFunction)) Then Exit Function

  AddAlternateName = True
End Function

'*****************************************************************************
' @bfunc   Public | AddManualLink | Boolean |
'-----------------------------------------------------------------------------
'          For each Script which has a Manual Link menu a line
'          ".. AddMenu .." must be insert in this function.
'-----------------------------------------------------------------------------
' @m              | ManualLinkClass
' @sMenuName      | String   | name and subdirectory of the scriptfile (e.g. "SSCx\Dialog")
' @sDefSection    | String   | name of the section in the *.def file
'-----------------------------------------------------------------------------
'
'*****************************************************************************
Public Sub AddManualLink(m As ManualLinkClass, sMenuName As String, sDefSection As String)
  Dim i As Integer
  Dim f As Variant
  Dim szFile As String, szLine As String
  Dim sMenulink(2) As String
  Dim bLineflag As Boolean
    
    szFile = DefGetFile("CfgFile")
    If (Not m.AddMenu(sMenuName)) Then Exit Sub
    f = FreeFile
    Open szFile For Input As f
    Line Input #f, szLine
    szLine = LCase(Trim(szLine))
        
    While (InStr(szLine, LCase(sMenuName)) = 0)
        Line Input #f, szLine
        szLine = LCase(Trim(szLine))
    Wend
        
    If (InStr(szLine, LCase(sMenuName)) > 0) Then
    Line Input #f, szLine
    szLine = Trim(szLine)
    While (szLine <> "<end_menu>")
        bLineflag = False
        sMenulink(2) = ""
        If InStr(szLine, ",") = 0 Then
            sMenulink(1) = Trim(szLine)
        Else
            sMenulink(1) = Trim(Left(szLine, InStr(szLine, ",") - 1))
            sMenulink(2) = Trim(Right(szLine, Len(szLine) - InStr(szLine, ",")))
            If LCase(sMenulink(2)) = "true" Then
                bLineflag = True
            End If
        End If
        
        If (Not m.AddLink(sDefSection, sMenulink(1), , bLineflag)) Then Exit Sub
        Line Input #f, szLine
        szLine = Trim(szLine)
    Wend
    End If
        
    Close f
End Sub


'*****************************************************************************
' @bfunc   Public | AddCC60NodeIntr | |
'
'-----------------------------------------------------------------------------
'          This function adds a new interrupt to a collection. Each
'          interrupt which should be displayed on the interrupt page must be
'          added with this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | c | DAvECollection | the interrupt collection
' @bparm   | IntName | String | name of the interrupt
' @bparm   | LevelName | String | name of the level bit field
' @bparm   | GroupName | Stri ng | name of the group bit field
' @bparm   | Enabled   | String | name of the enabled bit
' @bparm   | RegName           | String | name of the interrupt control register; now bit name
'
'*****************************************************************************

Function AddCC60NodeIntr(cn60 As DAvECollection, IntName As String, LevelName As Variant, GroupName As String, Enabled As Variant) As Boolean
  On Error Resume Next
  AddCC60NodeIntr = False
  
  Dim irn As InterruptClass
  Set irn = New InterruptClass
  irn.LevelName = LevelName
  irn.GroupName = GroupName
  irn.IntName = IntName
  irn.Enabled = Enabled
  irn.RegName = Enabled

  cn60.Add irn, IntName

  AddCC60NodeIntr = True
End Function


Function AddCC61NodeIntr(cn61 As DAvECollection, IntName As String, LevelName As Variant, GroupName As String, Enabled As Variant) As Boolean
  On Error Resume Next
  AddCC61NodeIntr = False
  
  Dim irn1 As InterruptClass
  Set irn1 = New InterruptClass
  irn1.LevelName = LevelName
  irn1.GroupName = GroupName
  irn1.IntName = IntName
  irn1.Enabled = Enabled
  irn1.RegName = Enabled

  cn61.Add irn1, IntName

  AddCC61NodeIntr = True
End Function


Function AddCC62NodeIntr(cn62 As DAvECollection, IntName As String, LevelName As Variant, GroupName As String, Enabled As Variant) As Boolean
  On Error Resume Next
  AddCC62NodeIntr = False
  
  Dim irn2 As InterruptClass
  Set irn2 = New InterruptClass
  irn2.LevelName = LevelName
  irn2.GroupName = GroupName
  irn2.IntName = IntName
  irn2.Enabled = Enabled
  irn2.RegName = Enabled

  cn62.Add irn2, IntName

  AddCC62NodeIntr = True
End Function


Function AddCC63NodeIntr(cn63 As DAvECollection, IntName As String, LevelName As Variant, GroupName As String, Enabled As Variant) As Boolean
  On Error Resume Next
  AddCC63NodeIntr = False
  
  Dim irn3 As InterruptClass
  Set irn3 = New InterruptClass
  irn3.LevelName = LevelName
  irn3.GroupName = GroupName
  irn3.IntName = IntName
  irn3.Enabled = Enabled
  irn3.RegName = Enabled

  cn63.Add irn3, IntName

  AddCC63NodeIntr = True
End Function



'*****************************************************************************
' @bfunc   Public | InstallCCU60NodesIntr | Boolean |
'
'-----------------------------------------------------------------------------
'          For each interrupt that should be used in the system a line
'          "Call AddCC6NodeIntr .." must be inserted in this function.
'
'-----------------------------------------------------------------------------
' @rdesc   one of the following values
' @flag    True |
' @flag    False|
'
'-----------------------------------------------------------------------------
' @bparm   | c | DAvECollection | the collection of the interrupts
'
'*****************************************************************************

Function InstallCCU60NodesIntr(cn60 As DAvECollection) As Boolean
    InstallCCU60NodesIntr = False

    Dim str As String

    If (ModuleCheck("CCU60")) Then
        str = "CCU60_INP"
        If (Not AddCC60NodeIntr(cn60, "CC60 Interrupts", "CCU60_USE_Level1", str & "_INPCC60", "CCU60_INPCC60_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "CC61 Interrupts", "CCU60_USE_Level2", str & "_INPCC61", "CCU60_INPCC61_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "CC62 Interrupts", "CCU60_USE_Level3", str & "_INPCC62", "CCU60_INPCC62_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "CHE Interrupts", "CCU60_USE_Level4", str & "_INPCHE", "CCU60_INPCHE_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "ERR Interrupts", "CCU60_USE_Level5", str & "_INPERR", "CCU60_INPERR_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "T12 Interrupts", "CCU60_USE_Level6", str & "_INPT12", "CCU60_INPT12_ENINTR")) Then Exit Function
        If (Not AddCC60NodeIntr(cn60, "T13 Interrupts", "CCU60_USE_Level7", str & "_INPT13", "CCU60_INPT13_ENINTR")) Then Exit Function
    End If
    InstallCCU60NodesIntr = True
End Function

Function InstallCCU61NodesIntr(cn61 As DAvECollection) As Boolean
    InstallCCU61NodesIntr = False

    Dim str As String

    If (ModuleCheck("CCU61")) Then
        str = "CCU61_INP"
        If (Not AddCC61NodeIntr(cn61, "CC60 Interrupt", "CCU61_USE_Level1", str & "_INPCC60", "CCU61_INPCC60_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "CC61 Interrupt", "CCU61_USE_Level2", str & "_INPCC61", "CCU61_INPCC61_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "CC62 Interrupt", "CCU61_USE_Level3", str & "_INPCC62", "CCU61_INPCC62_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "CHE Interrupts", "CCU61_USE_Level4", str & "_INPCHE", "CCU61_INPCHE_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "ERR Interrupts", "CCU61_USE_Level5", str & "_INPERR", "CCU61_INPERR_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "T12 Interrupts", "CCU61_USE_Level6", str & "_INPT12", "CCU61_INPT12_ENINTR")) Then Exit Function
        If (Not AddCC61NodeIntr(cn61, "T13 Interrupts", "CCU61_USE_Level7", str & "_INPT13", "CCU61_INPT13_ENINTR")) Then Exit Function
    End If
    InstallCCU61NodesIntr = True
End Function

Function InstallCCU62NodesIntr(cn62 As DAvECollection) As Boolean
    InstallCCU62NodesIntr = False

    Dim str As String

    If (ModuleCheck("CCU62")) Then
        str = "CCU62_INP"
        If (Not AddCC62NodeIntr(cn62, "CC60 Interrupts", "CCU62_USE_Level1", str & "_INPCC60", "CCU62_INPCC60_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "CC61 Interrupts", "CCU62_USE_Level2", str & "_INPCC61", "CCU62_INPCC61_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "CC62 Interrupts", "CCU62_USE_Level3", str & "_INPCC62", "CCU62_INPCC62_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "CHE Interrupts", "CCU62_USE_Level4", str & "_INPCHE", "CCU62_INPCHE_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "ERR Interrupts", "CCU62_USE_Level5", str & "_INPERR", "CCU62_INPERR_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "T12 Interrupts", "CCU62_USE_Level6", str & "_INPT12", "CCU62_INPT12_ENINTR")) Then Exit Function
        If (Not AddCC62NodeIntr(cn62, "T13 Interrupts", "CCU62_USE_Level7", str & "_INPT13", "CCU62_INPT13_ENINTR")) Then Exit Function
    End If
    InstallCCU62NodesIntr = True
End Function

Function InstallCCU63NodesIntr(cn63 As DAvECollection) As Boolean
    InstallCCU63NodesIntr = False

    Dim str As String
    If (ModuleCheck("CCU63")) Then
        str = "CCU63_INP"
        If (Not AddCC63NodeIntr(cn63, "CC60 Interrupts", "CCU63_USE_Level1", str & "_INPCC60", "CCU63_INPCC60_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "CC61 Interrupts", "CCU63_USE_Level2", str & "_INPCC61", "CCU63_INPCC61_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "CC62 Interrupts", "CCU63_USE_Level3", str & "_INPCC62", "CCU63_INPCC62_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "CHE Interrupts", "CCU63_USE_Level4", str & "_INPCHE", "CCU63_INPCHE_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "ERR Interrupts", "CCU63_USE_Level5", str & "_INPERR", "CCU63_INPERR_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "T12 Interrupts", "CCU63_USE_Level6", str & "_INPT12", "CCU63_INPT12_ENINTR")) Then Exit Function
        If (Not AddCC63NodeIntr(cn63, "T13 Interrupts", "CCU63_USE_Level7", str & "_INPT13", "CCU63_INPT13_ENINTR")) Then Exit Function
    End If
    InstallCCU63NodesIntr = True
End Function

