Attribute VB_Name = "Module1"
'#Uses "..\include\Const.inc"
'#Uses "..\include\Format.inc"
'#Uses "..\include\Global.inc"
'#Uses "..\include\Pages.inc"
'#Uses "..\include\Port.inc"
'#Uses "Include.inc"


Option Explicit
'*****************************************************************************
' Module:
'        CAN
'-----------------------------------------------------------------------------
' Description:
'        This file contains functions which are create controls for the
'        module 'CAN'.
'        Furthermore it contains functions for the event handling of
'        these controls.
'
'-----------------------------------------------------------------------------
' History:
'
'        Rev. Author         Date        Description
'        ---------------------------------------------------------------------
'        1.0  ste            04.04.00    final version
'        1.1  ste            02.11.00    the TC1775B has a new Single Transmission
'                                        Try mode; new FIFO direction (FD) bit;
'                                        new FIFO and Gateway handling
'
'        ----------------------------------------------------------------------
'        3.1  ahe            13.08.02     final version for TC1775B, TC1765
'                                         - add line 2793 and 2836
'        ----------------------------------------------------------------------
'        4.0  ste            21.10.02     final version for TC1796
'        ----------------------------------------------------------------------
'             ste            01.08.03     version for TC1766
'                                         only 2 node available
'                                         only 64 message objects available
'                                         only 6 SRNs available
'             ste            25.08.03     content of cboPRI changed
'             ste            14.11.03     TC1766 and TC1796 merged
'        ----------------------------------------------------------------------
'             Sheshadri      06.10.05     TCCAN name removed in ("cboPRI")
'                                         as per TC1766B step
'
'*****************************************************************************

Const TOOLTIP_DISABLED_OBJECT = "this message object is not enabled"

'*****************************************************************************
'Description:
'        This function is called from DAvE just before the Peripherals
'        window is shown.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnLoad(ps As Peripherals) As Boolean
    On Error GoTo OnLoadError

    OnLoad = False

    '-------------------------------------------------------------------------
    ' page: Object
    '-------------------------------------------------------------------------
    If (Not OnLoadPageObject(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: FIFO_Gateway
    '-------------------------------------------------------------------------
    If (Not OnLoadPageFIFO_Gateway(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupt
    '-------------------------------------------------------------------------
    If (Not OnLoadPageInterrupt(ps)) Then Exit Function

    '-------------------------------------------------------------------------
    ' End of pages
    '-------------------------------------------------------------------------
    
    ' call function to initialize the menu
    If (Not InitMenu(ps, "CAN\Objx")) Then Exit Function

    OnLoad = True
    Exit Function

OnLoadError:
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE just before a page
'        is shown.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Page            no. of the page (starts with 1)
'        Pagename        name of the page
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnChangingPage(ps As Peripherals, Page As Integer, Pagename As String) As Boolean
    On Error GoTo OnChangingPageError

    Dim vIndex As Variant
    Dim sVarPre As String

    vIndex = ps.Parameters.v("x")
    sVarPre = "CAN" & vIndex

    OnChangingPage = False

    '-------------------------------------------------------------------------
    'page: Object
    '-------------------------------------------------------------------------
    If (Not OnChangingPageObject(ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: FIFO_Gateway
    '-------------------------------------------------------------------------
    If (Not OnChangingPageFIFO_Gateway(ps, Pagename)) Then Exit Function

    '-------------------------------------------------------------------------
    'page: Interrupt
    '-------------------------------------------------------------------------
    If (Not OnChangingPageInterrupt(ps, Pagename)) Then Exit Function


    OnChangingPage = True
    Exit Function

OnChangingPageError:
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE in two cases:
'
'        1.
'            The contents of the peripherals window must be refreshed.
'            In this case the 'Controlname' parameter is a empty string
'            and the values array 'v()' contains nothing.
'
'        2.
'            A control on the peripherals has been changed.
'            In this case the 'Controlname' parameter contains the name
'            of the changed control and the values array 'v()' contains the
'            changed value(s).
'
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     name of the changed control (for case 2)
'        v()             array with the changed values (for case 2)
'        Page            no. of the page (starts with 1)
'        Pagename        name of the page
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnShow(ps As Peripherals, Controlname As String, v() As Variant, Page As Integer, Pagename As String) As Boolean
    On Error GoTo OnShowError

    Dim vIndex As Variant
    Dim sVarPre As String

    vIndex = ps.Parameters.v("x")
    sVarPre = "CAN" & vIndex

    OnShow = False

    '-------------------------------------------------------------------------
    ' page: Object
    '-------------------------------------------------------------------------
    If (Not OnShowPageObject(ps, Controlname, Pagename, v)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: FIFO_Gateway
    '-------------------------------------------------------------------------
    If (Not OnShowPageFIFO_Gateway(ps, Controlname, Pagename, v)) Then Exit Function

    '-------------------------------------------------------------------------
    ' page: Interrupt
    '-------------------------------------------------------------------------
    If (Not OnShowPageInterrupt(ps, Controlname, Pagename, v)) Then Exit Function

    OnShow = True
    Exit Function

OnShowError:
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE if the user clicks on a button.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     name of the button
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnClick(ps As Peripherals, Controlname As String) As Boolean
    On Error GoTo OnClickError

    OnClick = False

    Dim np As Peripherals


    OnClick = True
    Exit Function

OnClickError:
    Errorbox "Can not process the click", Err.Description
    Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from DAvE if the user clicks on a menu entry.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Toolname        name of the entry
'        ToolId          id of the entry
'        Tooltext        additional text of the entry
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnMenuClick(ps As Peripherals, Toolname As String, ToolId As Long, Tooltext As String) As Boolean
    On Error GoTo OnMenuClickError

    OnMenuClick = False

    If (Not MenuClick(ps, Toolname, ToolId, Tooltext, "CAN\Objx")) Then Exit Function

    OnMenuClick = True
    Exit Function

OnMenuClickError:
    Exit Function
End Function


'-----------------------------------------------------------------------------
' local functions
'-----------------------------------------------------------------------------

'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add the page 'Control'.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageObject(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageObject = False

  If (Not ps.AddPage("Object")) Then Exit Function

  OnLoadPageObject = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnChangingPageObject(ps As Object, Pagename As String) As Boolean
  On Error Resume Next
  Dim r As ProjectData
  Dim iNr As Integer
  Dim vIndex As Variant
  Dim sVarPre As String

  vIndex = ps.Parameters.v("x")
  sVarPre = "CAN" & vIndex
  iNr = ps.Parameters.v("Number")

  Set r = ps.ProjectData

  OnChangingPageObject = False
  
  If (Not ps.ExtenderCollection("Object").Loaded) And (Pagename = "Object") Then
    ps.ExtenderCollection("Object").Loaded = True

    '-------------------------------
    ' frame: frmMSGVAL
    '-------------------------------
    If (Not ps.AddFrame("frmMSGVAL", 100, 100, 2850, 1000, "Message Valid")) Then Exit Function
        If (Not ps.AddCheck("chkMSGVAL", 200, 350, 2450, 400, "Enable message object " & iNr & " (MSGVAL)")) Then Exit Function

    '-------------------------------
    ' frame: frmIDE
    '-------------------------------
    If (Not ps.AddFrame("frmIDE", 3100, 100, 2700, 1000, "Identifier Selection (IDE)")) Then Exit Function
        If (Not ps.AddOption("optIDE_0", 200, 300, 2050, 300, "Standard 11-bit identifier")) Then Exit Function
        If (Not ps.AddOption("optIDE_1", 200, 600, 2125, 300, "Extended 29-bit identifier")) Then Exit Function

    '-------------------------------
    ' frame: frmLIST
    '-------------------------------
    If (Not ps.AddFrame("frmLIST", 5950, 100, 2600, 1000, "List Allocation (LIST)")) Then Exit Function
        If (Not ps.AddLabel("lblLIST", 1, 200, 450, 2000, 305, "List x (node y)")) Then Exit Function

    '-------------------------------
    ' frame: frmDIR
    '-------------------------------
    If (Not ps.AddFrame("frmDIR", 100, 1200, 2850, 1350, "Message Direction (DIR)")) Then Exit Function
        If (Not ps.AddOption("optDIR_0", 200, 300, 2425, 380, "Receive ..")) Then Exit Function
        If (Not ps.AddOption("optDIR_1", 200, 800, 2400, 380, "Transmit ..")) Then Exit Function

    '-------------------------------
    ' frame: frmID
    '-------------------------------
    If (Not ps.AddFrame("frmID", 3100, 1200, 2700, 1350, "Arbitration Register")) Then Exit Function
        If (Not ps.AddText("txtID11", 1450, 350, 975, 315)) Then Exit Function
        If (Not ps.AddLabel("lblID11", 0, 200, 350, 1200, 395, "Identifier 11-bit (ID28-18)")) Then Exit Function
        If (Not ps.AddText("txtID29", 1450, 850, 1150, 315)) Then Exit Function
        If (Not ps.AddLabel("lblID29", 0, 200, 850, 1200, 395, "Identifier 29-bit (ID28-0)")) Then Exit Function

    '-------------------------------
    ' frame: frmRMM
    '-------------------------------
    If (Not ps.AddFrame("frmRMM", 5950, 1200, 2600, 1350, "Remote Monitoring")) Then Exit Function
        If (Not ps.AddCheck("chkRMM", 200, 250, 2350, 900, "Copy the identifier, DLC and IDE code of a remote frame with matching identifier to this transmit object (RMM)")) Then Exit Function

    '-------------------------------
    ' frame: frmDLC
    '-------------------------------
    If (Not ps.AddFrame("frmDLC", 100, 2650, 2850, 800, "Data Length Code (DLC)")) Then Exit Function
        If (Not ps.AddCombo("cboDLC", 1150, 300, 1500, 315)) Then Exit Function
        If (Not ps.AddLabel("lblDLC", 0, 200, 350, 950, 305, "Data length")) Then Exit Function

    '-------------------------------
    ' frame: frmDATA
    '-------------------------------
    If (Not ps.AddFrame("frmDATA", 100, 3550, 2850, 1750, "Data Fields (MODATAL, MODATAH)")) Then Exit Function
        If (Not ps.AddText("txtDATA0", 750, 300, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA0", 0, 200, 300, 550, 300, "DB0")) Then Exit Function
        If (Not ps.AddText("txtDATA1", 2000, 300, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA1", 0, 1450, 300, 500, 300, "DB1")) Then Exit Function
        If (Not ps.AddText("txtDATA2", 750, 650, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA2", 0, 200, 650, 550, 300, "DB2")) Then Exit Function
        If (Not ps.AddText("txtDATA3", 2000, 650, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA3", 0, 1450, 650, 500, 300, "DB3")) Then Exit Function
        If (Not ps.AddText("txtDATA4", 750, 1000, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA4", 0, 200, 1000, 550, 300, "DB4")) Then Exit Function
        If (Not ps.AddText("txtDATA5", 2000, 1000, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA5", 0, 1450, 1000, 500, 300, "DB5")) Then Exit Function
        If (Not ps.AddText("txtDATA6", 750, 1350, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA6", 0, 200, 1350, 550, 300, "DB6")) Then Exit Function
        If (Not ps.AddText("txtDATA7", 2000, 1350, 600, 300)) Then Exit Function
        If (Not ps.AddLabel("lblDATA7", 0, 1450, 1350, 500, 300, "DB7")) Then Exit Function

    '-------------------------------
    ' frame: frmAM
    '-------------------------------
    If (Not ps.AddFrame("frmAM", 3100, 2650, 2700, 2650, "Acceptance Mask")) Then Exit Function
        If (Not ps.AddOption("optMIDE_0", 200, 300, 2450, 400, "Accept reception of standard and extended frames")) Then Exit Function
        If (Not ps.AddOption("optMIDE_1", 200, 800, 2400, 400, "Only receive frames with matching IDE bit")) Then Exit Function
        If (Not ps.AddText("txtAM11", 1350, 1450, 975, 315)) Then Exit Function
        If (Not ps.AddLabel("lblAM11", 0, 200, 1400, 1050, 395, "Mask 11-bit (AM28-18)")) Then Exit Function
        If (Not ps.AddText("txtAM29", 1350, 1900, 1150, 315)) Then Exit Function
        If (Not ps.AddLabel("lblAM29", 0, 200, 1900, 1050, 395, "Mask 29-bit (AM28-0)")) Then Exit Function

    '-------------------------------
    ' frame: frmPRI
    '-------------------------------
    If (Not ps.AddFrame("frmPRI", 5950, 2650, 2600, 750, "Priority Class (PRI)")) Then Exit Function
        If (Not ps.AddLabel("lblPri", 0, 200, 300, 750, 300, "Priority")) Then Exit Function
        If (Not ps.AddCombo("cboPRI", 1000, 300, 1150, 315)) Then Exit Function

    '-------------------------------
    ' frame: frmSDT
    '-------------------------------
    If (Not ps.AddFrame("frmSDT", 5950, 3450, 2600, 950, "Single Data Transfer Mode")) Then Exit Function
        If (Not ps.AddCheck("chkSDT", 200, 250, 2300, 600, "Disable the object auto- matically after a successful data transfer (SDT)")) Then Exit Function

    '-------------------------------
    ' frame: frmSTT
    '-------------------------------
    If (Not ps.AddFrame("frmSTT", 5950, 4450, 2600, 850, "Single Transmission Trial")) Then Exit Function
        If (Not ps.AddCheck("chkSTT", 200, 300, 2250, 400, "Enable single transmission trial (STT)")) Then Exit Function

  End If
  OnChangingPageObject = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnShowPageObject(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageObjectError

  OnShowPageObject = False

  Dim r As ProjectData
  Dim c As Object
  Dim e As Object
  Dim bDisabled As Boolean
  Dim vIndex As Variant
  Dim sVarPre As String
  Dim sRegPre As String
  Dim d As String
  Dim iNr As Integer
  Dim i As Integer
  Dim bReturn As Boolean
  Dim iBaseNr As Integer
  Dim iIsObjFIFOSlave As Integer

  vIndex = ps.Parameters.v("x")
  iNr = ps.Parameters.v("Number")
  sVarPre = "CAN" & vIndex
  sRegPre = sVarPre & "_"

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection

  If (Pagename = "Object") Then
    '-------------------------------------------------------------------------
    ' page: Object (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: chkMSGVAL (action)
        '---------------------------------------------------------------------
        Case "chkMSGVAL"
              If (v(1) = 1) Then
                r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 1
              Else
                bReturn = True
                If (bReturn) Then
                  ' sets the standard mode and release all FIFO slaves
                  bReturn = SetStandardMode(r, vIndex, iNr)
                End If
                If (bReturn) Then
                  'reset object
                  r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
                  r.sfr(sRegPre & "MOFCR" & iNr) = &H0
                End If
              End If

        '---------------------------------------------------------------------
        ' control: optIDE_0 (action)
        '---------------------------------------------------------------------
        Case "optIDE_0"
              r.v(sRegPre & "MOAR" & iNr & "_IDE") = 0
'              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
'              Call ChangeGatewayDestinationSettings(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: optIDE_1 (action)
        '---------------------------------------------------------------------
        Case "optIDE_1"
              r.v(sRegPre & "MOAR" & iNr & "_IDE") = 1
'              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
'              Call ChangeGatewayDestinationSettings(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: optDIR_0 (action)
        '---------------------------------------------------------------------
        Case "optDIR_0"
             ' sets the standard mode and release all FIFO slaves
              SetStandardMode(r, vIndex, iNr)
              r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0
              r.v(sRegPre & "MOFCR" & iNr & "_RMM") = 0

        '---------------------------------------------------------------------
        ' control: optDIR_1 (action)
        '---------------------------------------------------------------------
        Case "optDIR_1"
             ' sets the standard mode and release all FIFO slaves
              SetStandardMode(r, vIndex, iNr)
              bReturn = True
              If (bReturn) Then
                r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 1
              End If

        '---------------------------------------------------------------------
        ' control: txtID11 (action)
        '---------------------------------------------------------------------
        Case "txtID11"
             If (IsInputFormatOK(v(1), "H3", c("lblID11").Caption, 0, &H7FF)) Then
               r.v(sRegPre & "MOAR" & iNr & "_ID") = v(1) * 2 ^ 18
 '              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
            Else
               Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: txtID29 (action)
        '---------------------------------------------------------------------
        Case "txtID29"
             If (IsInputFormatOK(v(1), "H8", c("lblID29").Caption, 0, &H1FFFFFFF)) Then
               r.v(sRegPre & "MOAR" & iNr & "_ID") = v(1)
 '              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
             Else
               Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: chkRMM (action)
        '---------------------------------------------------------------------
        Case "chkRMM"
              r.v(sRegPre & "MOFCR" & iNr & "_RMM") = v(1)

        '---------------------------------------------------------------------
        ' control: cboDLC (action)
        '---------------------------------------------------------------------
        Case "cboDLC"
            For i = 0 To 8
              If (i & " data bytes" = v(1)) Then
                r.v(sRegPre & "MOFCR" & iNr & "_DLC") = i
                Exit For
              End If
            Next i

        '---------------------------------------------------------------------
        ' control: optMIDE_0 (action)
        '---------------------------------------------------------------------
        Case "optMIDE_0"
              r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 0

        '---------------------------------------------------------------------
        ' control: optMIDE_1 (action)
        '---------------------------------------------------------------------
        Case "optMIDE_1"
              r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1

        '---------------------------------------------------------------------
        ' control: txtAM11 (action)
        '---------------------------------------------------------------------
        Case "txtAM11"
             If (IsInputFormatOK(v(1), "H3", c("lblAM11").Caption, 0, &H7FF)) Then
               r.v(sRegPre & "MOAMR" & iNr & "_AM") = v(1) * 2 ^ 18
 '              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
             Else
               Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: txtAM29 (action)
        '---------------------------------------------------------------------
        Case "txtAM29"
             If (IsInputFormatOK(v(1), "H8", c("lblAM29").Caption, 0, &H1FFFFFFF)) Then
               r.v(sRegPre & "MOAMR" & iNr & "_AM") = v(1)
 '              ChangeFIFOSettings(r, vIndex, iNr, r.v(sRegPre & "MOFCR" & iNr & "_FSIZE"))
             Else
               Exit Function
             End If

        '---------------------------------------------------------------------
        ' control: cboPRI (action)
        '---------------------------------------------------------------------
        Case "cboPRI"
            r.v(sRegPre & "MOAR" & iNr & "_PRI") = (c("cboPRI").ListIndex + 1)

        '---------------------------------------------------------------------
        ' control: chkSDT (action)
        '---------------------------------------------------------------------
        Case "chkSDT"
              r.v(sRegPre & "MOFCR" & iNr & "_SDT") = v(1)

        '---------------------------------------------------------------------
        ' control: chkSTT (action)
        '---------------------------------------------------------------------
        Case "chkSTT"
              r.v(sRegPre & "MOFCR" & iNr & "_STT") = v(1)


      Case Else
    End Select

    For i = 0 To 7
      '---------------------------------------------------------------------
      ' control: txtDATAx (action) (x = 0-7)
      '---------------------------------------------------------------------
      If (Controlname = "txtDATA" & i) Then
        If (IsInputFormatOK(v(1), "H2", c("lblDATA" & i).Caption, 0, &HFF)) Then
          If (i < 4) Then
            r.v(sRegPre & "MODATAL" & iNr & "_DB" & i) = v(1)
          Else
            r.v(sRegPre & "MODATAH" & iNr & "_DB" & i) = v(1)
          End If
          Exit For
        Else
          Exit Function
        End If

      End If
    Next i


    '-------------------------------------------------------------------------
    ' page: Object (show)
    '-------------------------------------------------------------------------

    iIsObjFIFOSlave = IsObjFIFOSlave(r, vIndex, iNr)
    '-------------------------------------------------------------------------
    ' control: chkMSGVAL (show)
    '-------------------------------------------------------------------------
    With c("chkMSGVAL")
      ' disable condition
      bDisabled = IsModuleClockDisabled(r, vIndex) Or (r.v(sRegPre & "MOCTR" & iNr & "_LIST") = 0) Or (iIsObjFIFOSlave >= 0)
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 1)
    End With

    With e("chkMSGVAL")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (IsModuleClockDisabled(r, vindex)) Then
        .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleClockDisabled(r, vIndex)
        End If
        If (r.v(sRegPre & "MOCTR" & iNr & "_LIST") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not allocated to a List (node)")
        End If
        If (iIsObjFIFOSlave >= 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is a FIFO slave object, connected to the base object " & iIsObjFIFOSlave)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblLIST (show)
    '-------------------------------------------------------------------------
    With c("lblLIST")
      .Enabled = Not (bDisabled)
      If (r.v(sRegPre & "MOCTR" & iNr & "_LIST") = 0) Then
        .Caption = "unallocated"
      Else
        .Caption = "List " & r.v(sRegPre & "MOCTR" & iNr & "_LIST") & " (node " & r.v(sRegPre & "MOCTR" & iNr & "_LIST") - 1 & ")"
      End If
    End With

    With e("lblLIST")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = ""
      Else
        ' tooltip if control is enabled
      End If
    End With


    For i = 0 To 1
      '-------------------------------------------------------------------------
      ' control: optIDE_x (show) (x = 0,1)
      '-------------------------------------------------------------------------
      With c("optIDE_" & i)
        ' disable condition
        bDisabled = IsModuleClockDisabled(r, vIndex) Or r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or (iIsObjFIFOSlave >= 0)
        .Enabled = Not (bDisabled)
        ' show condition
        .Value = (r.v(sRegPre & "MOAR" & iNr & "_IDE") = i)
      End With

      With e("optIDE_" & i)
        If (bDisabled) Then
          ' tooltip if control is disabled
          .DisabledTooltipText = TOOLTIP_DISABLED_IF
          If (IsModuleClockDisabled(r, vindex)) Then
          .DisabledTooltipText = .DisabledTooltipText & GetTooltipModuleClockDisabled(r, vindex)
          End If
          If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
          End If
        Else
          ' tooltip if control is enabled
        End If
      End With
    Next i

    '-------------------------------------------------------------------------
    ' control: optDIR_0 (show)
    '-------------------------------------------------------------------------
    With c("optDIR_0")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or (iIsObjFIFOSlave >= 0)
      .Enabled = Not (bDisabled)
      .Caption = "Receive data frames, transmit remote frames"
      ' if the connected node is in analyser mode
      If (IsObjConnectedToAnalyzer(r, vIndex, iNr)) Then
        .Caption = "Receive data frames"
      End If
      ' show condition
      .Value = (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0)
    End With

    With e("optDIR_0")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optDIR_1 (show)
    '-------------------------------------------------------------------------
    With c("optDIR_1")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or (iIsObjFIFOSlave >= 0)
      .Enabled = Not (bDisabled)
      ' if the connected node is in analyser mode
      .Caption = "Transmit data frames, receive and answer remote frames"
      If (IsObjConnectedToAnalyzer(r, vIndex, iNr)) Then
        .Caption = "Receive remote frames"
      End If
      ' show condition
      .Value = (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 1)
    End With

    With e("optDIR_1")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtID11 (show)
    '-------------------------------------------------------------------------
    With c("txtID11")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOAR" & iNr & "_IDE") = 1
      .Enabled = Not (bDisabled)
      ' show condition
      .Text = FormatTextOutput(r.v(sRegPre & "MOAR" & iNr & "_ID") \ 2 ^ 18, "H3")
    End With

    With e("txtID11")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 1) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the extended 29-bit identifier is selected")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblID11 (show)
    '-------------------------------------------------------------------------
    With c("lblID11")
      ' same as for txtID11
      .Enabled = Not (bDisabled)
    End With

    With e("lblID11")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("txtID11").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtID29 (show)
    '-------------------------------------------------------------------------
    With c("txtID29")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOAR" & iNr & "_IDE") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Text = FormatTextOutput(r.v(sRegPre & "MOAR" & iNr & "_ID"), "H8")
    End With

    With e("txtID29")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the standard 11-bit identifier is selected")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblID29 (show)
    '-------------------------------------------------------------------------
    With c("lblID29")
      ' same as for txtID29
      .Enabled = Not (bDisabled)
    End With

    With e("lblID29")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("txtID29").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMIDE_0 (show)
    '-------------------------------------------------------------------------
    With c("optMIDE_0")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 0)
    End With

    With e("optMIDE_0")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMIDE_1 (show)
    '-------------------------------------------------------------------------
    With c("optMIDE_1")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1)
    End With

    With e("optMIDE_1")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtAM11 (show)
    '-------------------------------------------------------------------------
    With c("txtAM11")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 1 And r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1)
      .Enabled = Not (bDisabled)
      ' show condition
      .Text = FormatTextOutput(r.v(sRegPre & "MOAMR" & iNr & "_AM") \ 2 ^ 18, "H3")
    End With

    With e("txtAM11")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 1 And r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("only reception of receive frames with matching IDE bit is selected")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblAM11 (show)
    '-------------------------------------------------------------------------
    With c("lblAM11")
      ' same as for txtAM11
      .Enabled = Not (bDisabled)
    End With

    With e("lblAM11")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("txtAM11").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: txtAM29 (show)
    '-------------------------------------------------------------------------
    With c("txtAM29")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 0 And r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1)
      .Enabled = Not (bDisabled)
      ' show condition
      .Text = FormatTextOutput(r.v(sRegPre & "MOAMR" & iNr & "_AM"), "H8")
    End With

    With e("txtAM29")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOAR" & iNr & "_IDE") = 0 And r.v(sRegPre & "MOAMR" & iNr & "_MIDE") = 1) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("only reception of receive frames with matching IDE bit is selected")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblAM29 (show)
    '-------------------------------------------------------------------------
    With c("lblAM29")
      ' same as for txtAM29
      .Enabled = Not (bDisabled)
    End With

    With e("lblAM29")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("txtAM29").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkRMM (show)
    '-------------------------------------------------------------------------
    With c("chkRMM")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_RMM") = 1)
    End With

    With e("chkRMM")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
         If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0) Then  ' if receive object
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is configured as receive object")
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboDLC (show)
    '-------------------------------------------------------------------------
    With c("cboDLC")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      For i = 0 To 8
        .AddItem i & " data bytes"
      Next i
      .ListIndex = r.v(sRegPre & "MOFCR" & iNr & "_DLC")
    End With

    With e("cboDLC")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblDLC (show)
    '-------------------------------------------------------------------------
    With c("lblDLC")
      ' same as for cboDLC
      .Enabled = Not (bDisabled)
    End With

    With e("lblDLC")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboDLC").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With


    For i = 0 To 7
      '-------------------------------------------------------------------------
      ' control: txtDATAx  (show) (x = 0-7)
      '-------------------------------------------------------------------------
      With c("txtDATA" & i)
        ' disable condition
        bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_DLC") <= i
        .Enabled = Not (bDisabled)
        ' show condition
        If (i < 4) Then
          .Text = FormatTextOutput(r.v(sRegPre & "MODATAL" & iNr & "_DB" & i), "H2")
        Else
          .Text = FormatTextOutput(r.v(sRegPre & "MODATAH" & iNr & "_DB" & i), "H2")
        End If
     End With

      With e("txtDATA" & i)
        If (bDisabled) Then
          ' tooltip if control is disabled
          .DisabledTooltipText = TOOLTIP_DISABLED_IF
           If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
             .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
           End If
           If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0) Then  ' if receive object
             .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is configured as receive object")
           End If
           If (r.v(sRegPre & "MOFCR" & iNr & "_DLC") <= i) Then
             .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the data length code is configured only for " & r.v(sRegPre & "MOFCR" & iNr & "_DLC") & " data bytes")
           End If
        Else
          ' tooltip if control is enabled
        End If
      End With

      '-------------------------------------------------------------------------
      ' control: lblDATAx (show)  (x = 0-7)
      '-------------------------------------------------------------------------
      With c("lblDATA" & i)
        ' same as for txtDATAx
        .Enabled = Not (bDisabled)
      End With

      With e("lblDATA" & i)
        If (bDisabled) Then
          ' tooltip if control is disabled
          .DisabledTooltipText = e("txtDATA" & i).DisabledTooltipText
        Else
          ' tooltip if control is enabled
        End If
      End With

    Next i

    '-------------------------------------------------------------------------
    ' control: cboPRI (show)
    '-------------------------------------------------------------------------
    With c("cboPRI")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
'      .AddItem "Reserved"
      .AddItem "list order"
      .AddItem "CAN ID"
      .AddItem "list order"
      .ListIndex = (r.v(sRegPre & "MOAR" & iNr & "_PRI") - 1)
    End With

    With e("cboPRI")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblPRI (show)
    '-------------------------------------------------------------------------
    With c("lblPRI")
      ' same as for cboPRI
      .Enabled = Not (bDisabled)
    End With

    With e("lblPRI")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboPRI").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkSDT (show)
    '-------------------------------------------------------------------------
    With c("chkSDT")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_SDT") = 1)
    End With

    With e("chkSDT")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: chkSTT (show)
    '-------------------------------------------------------------------------
    With c("chkSTT")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_STT") = 1)
    End With

    With e("chkSTT")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    ' if a FIFO slave object or Gateway destination is automatically configured by DAvE then this disable
    ' condition and tooltips are used
    ' NOTE: all show statements after this are overwriting this settings
    iBaseNr = iIsObjFIFOSlave
    If (iBaseNr >= 0) Then
      bDisabled = True
      ' tooltip if control is disabled
      d = TOOLTIP_DISABLED_IF
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 1) Then
        d = d & FormatDisabledTooltip("this object is a receive FIFO slave object, connected to the base object " & iBaseNr)
        Call SetDefaultPropertiesForAllControlsOnPage("Object", c, e, bDisabled, d, "")
         
         'by ashish ,enable DLC for slave mo's
''        With c("cboDLC")
''           .Enabled = True
''             ' show condition
''            .Clear
''          For i = 0 To 8
''              .AddItem i & " data bytes"
''              Next i
''    .ListIndex = r.v(sRegPre & "MOFCR" & iNr & "_DLC")
''       End With
''
''        c("lblDLC").Enabled = True
''        For i = 0 To 7
''            c("txtDATA" & i).Enabled = True
''            c("lblDATA" & i).Enabled = True
''      Next i
     End If
     'end by ashish
      
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 2) Then
        d = d & FormatDisabledTooltip("this object is a transmit FIFO slave object, connected to the base object " & iBaseNr)
        Call SetDefaultPropertiesForAllControlsOnPage("Object", c, e, bDisabled, d, "")
        'by ashish ,enable DLC for slave mo's
        With c("cboDLC")
            .Enabled = True
             ' show condition
            .Clear
          For i = 0 To 8
              .AddItem i & " data bytes"
               Next i
   .ListIndex = r.v(sRegPre & "MOFCR" & iNr & "_DLC")
      End With
        c("lblDLC").Enabled = True
        If (r.v(sRegPre & "MOFCR" & iNr & "_DLC") <> 0) Then
       For i = 0 To (r.v(sRegPre & "MOFCR" & iNr & "_DLC") - 1)
            c("txtDATA" & i).Enabled = True
           c("lblDATA" & i).Enabled = True
        Next i
        Else
         'all data bytes will be disabled
        End If
        End If
        'end by ashish
        
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 4) Then
        d = d & FormatDisabledTooltip("this object is a gateway destination object, connected to the source object " & iBaseNr)
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmMSGVAL").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmIDE").Caption, c, e, bDisabled, d, "")
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmLIST").Caption, c, e, bDisabled, d, "")
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmDIR").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmID").Caption, c, e, bDisabled, d, "")
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmRMM").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmDLC").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmDATA").Caption, c, e, bDisabled, d, "")
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmAM").Caption, c, e, bDisabled, d, "")
        Call SetDefaultPropertiesForAllControlsOnFrame(c("frmPRI").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmSDT").Caption, c, e, bDisabled, d, "")
        'Call SetDefaultPropertiesForAllControlsOnFrame(c("frmSTT").Caption, c, e, bDisabled, d, "")
      End If
   End If

  End If


  OnShowPageObject = True
  Exit Function

OnShowPageObjectError:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add the page 'FIFO_Gateway'.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageFIFO_Gateway(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageFIFO_Gateway = False

  If (Not ps.AddPage("FIFO/Gateway")) Then Exit Function

  OnLoadPageFIFO_Gateway = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnChangingPageFIFO_Gateway(ps As Object, Pagename As String) As Boolean
  On Error Resume Next
  Dim r As ProjectData
  Dim iNr As Integer
  Dim vIndex As Variant
  Dim sVarPre As String

  OnChangingPageFIFO_Gateway = False

  vIndex = ps.Parameters.v("x")
  sVarPre = "CAN" & vIndex
  iNr = ps.Parameters.v("Number")

  Set r = ps.ProjectData
  
  If (Not ps.ExtenderCollection("FIFO/Gateway").Loaded) And (Pagename = "FIFO/Gateway") Then
    ps.ExtenderCollection("FIFO/Gateway").Loaded = True



    '-------------------------------
    ' frame: frmMMC
    '-------------------------------
    If (Not ps.AddFrame("frmMMC", 100, 100, 4000, 2300, "Message Object Mode Control (MMC)")) Then Exit Function
        If (Not ps.AddOption("optMMC_0", 200, 400, 3650, 300, "Standard message object")) Then Exit Function
        If (Not ps.AddOption("optMMC_1", 200, 750, 3650, 300, "Receive FIFO base object")) Then Exit Function
        If (Not ps.AddOption("optMMC_2", 200, 1100, 3650, 300, "Transmit FIFO base object")) Then Exit Function
        If (Not ps.AddOption("optMMC_3", 200, 1450, 3650, 300, "Transmit FIFO slave object")) Then Exit Function
        If (Not ps.AddOption("optMMC_4", 200, 1800, 2750, 300, "Gateway source object")) Then Exit Function

    '-------------------------------
    ' frame: frmPointer
    '-------------------------------
    If (Not ps.AddFrame("frmPointer", 4300, 100, 4300, 2300, "FIFO / Gateway Pointer")) Then Exit Function
        If (Not ps.AddLabel("lblBOT", 0, 200, 350, 1250, 400, "Bottom pointer (BOT)")) Then Exit Function
        If (Not ps.AddCombo("cboBOT", 1500, 400, 1000, 315)) Then Exit Function
        If (Not ps.AddLabel("lblTOP", 0, 200, 800, 1250, 400, "Top pointer (TOP)")) Then Exit Function
        If (Not ps.AddCombo("cboTOP", 1500, 850, 1000, 315)) Then Exit Function
        If (Not ps.AddLabel("lblCUR", 0, 200, 1250, 1250, 400, "Current object pointer (CUR)")) Then Exit Function
        If (Not ps.AddCombo("cboCUR", 1500, 1300, 1000, 315)) Then Exit Function
        If (Not ps.AddLabel("lblSEL", 0, 200, 1700, 1250, 400, "Object select pointer (SEL)")) Then Exit Function
        If (Not ps.AddCombo("cboSEL", 1500, 1750, 1000, 315)) Then Exit Function
        If (Not ps.AddListbox("lstRelatedMOs", 2800, 400, 1050, 1250)) Then Exit Function
        If (Not ps.AddLabel("lblReleatedMOs", 0, 2800, 1700, 1050, 400, "Related FIFO objects")) Then Exit Function

    '-------------------------------
    ' frame: frmDLCC
    '-------------------------------
    If (Not ps.AddFrame("frmDLCC", 100, 2500, 4000, 900, "Data Length Code Copy")) Then Exit Function
        If (Not ps.AddCheck("chkDLCC", 200, 350, 3750, 400, "The received source DLC information is copied to the gateway destination object (DLCC)")) Then Exit Function

    '-------------------------------
    ' frame: frmIDC
    '-------------------------------
    If (Not ps.AddFrame("frmIDC", 4300, 2500, 4300, 900, "Identifier Copy")) Then Exit Function
        If (Not ps.AddCheck("chkIDC", 200, 350, 4075, 400, "The identifier of the gateway source object is copied to the gateway destination (IDC)")) Then Exit Function

    '-------------------------------
    ' frame: frmGDFS
    '-------------------------------
    If (Not ps.AddFrame("frmGDFS", 100, 3500, 4000, 900, "Gateway Data Frame Send")) Then Exit Function
        If (Not ps.AddCheck("chkGDFS", 200, 350, 3750, 400, "A frame received by the source object is auto- matically sent by the destination object (GDFS)")) Then Exit Function

    '-------------------------------
    ' frame: frmDATC
    '-------------------------------
    If (Not ps.AddFrame("frmDATC", 4300, 3500, 4300, 900, "Data Copy")) Then Exit Function
        If (Not ps.AddCheck("chkDATC", 200, 350, 3950, 400, "The data fields of the gateway source object are copied to the gateway destination (DATC)")) Then Exit Function

    '-------------------------------
    ' frame: frmFRREN
    '-------------------------------
    If (Not ps.AddFrame("frmFRREN", 100, 4500, 8500, 700, "Foreign Remote Request Enable")) Then Exit Function
        If (Not ps.AddCheck("chkFRREN", 200, 300, 8100, 300, "A matching remote frame on a destination CAN bus generate a remote frame on the source CAN bus (FRREN)")) Then Exit Function

  End If
  OnChangingPageFIFO_Gateway = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnShowPageFIFO_Gateway(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageFIFO_GatewayError

  OnShowPageFIFO_Gateway = False

  Dim r As ProjectData
  Dim c As Object
  Dim e As Object
  Dim bDisabled As Boolean
  Dim vIndex As Variant
  Dim sVarPre As String
  Dim sRegPre As String
  Dim d As String
  Dim iNr As Integer
  Dim i As Integer
  Dim j As Integer
  Dim iFirstNr As Integer
  Dim iLastNr As Integer
  Dim iNextNr As Integer
  Dim iBaseNr As Integer

  vIndex = ps.Parameters.v("x")
  iNr = ps.Parameters.v("Number")
  sVarPre = "CAN" & vIndex
  sRegPre = sVarPre & "_"

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection

  If (Pagename = "FIFO/Gateway") Then
    '-------------------------------------------------------------------------
    ' page: FIFO_Gateway (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: optMMC_0 (action)
        '---------------------------------------------------------------------
        Case "optMMC_0"  ' normal mode
              ' the standard mode was set and all FIFO slaves are released
              SetStandardMode(r, vIndex, iNr)
             ' r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0 '--ash

        '---------------------------------------------------------------------
        ' control: optMMC_1 (action)
        '---------------------------------------------------------------------
        Case "optMMC_1"  ' Receive FIFO base object
              r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 1
              SetFIFOBaseMode(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: optMMC_2 (action)
        '---------------------------------------------------------------------
        Case "optMMC_2"  ' Transmit FIFO base object
              r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 2
              SetFIFOBaseMode(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: optMMC_3 (action)
        '---------------------------------------------------------------------
        Case "optMMC_3"  ' Transmit FIFO slave object
              ' will be set by DAvE automatically
               r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 3

        '---------------------------------------------------------------------
        ' control: optMMC_4 (action)
        '---------------------------------------------------------------------
        Case "optMMC_4"  ' gateway source object
              ' a gateway source is the same as a FIFO base object
              ' the gateway destination is how a FIFO slave
              r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 4
              SetFIFOBaseMode(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: cboBOT (action)
        '---------------------------------------------------------------------
        Case "cboBOT"
            ' all current slaves released
            ResetFIFOSlaves(r, vIndex, iNr)
            If ("n.a." = v(1)) Then
              r.v(sRegPre & "MOFGPR" & iNr & "_BOT") = &HFF
              r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = &HFF
              r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = &HFF
              r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = &HFF
            Else
              For i = 0 To (CAN_MAX_OBJECTS - 1)
                If ("MO" & i = v(1)) Then
                  r.v(sRegPre & "MOFGPR" & iNr & "_BOT") = i
                  r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = i
                  r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = i
                  r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = i ' SEL = TOP
                  Exit For
                End If
              Next i
            End If
            ' all new slaves configured
            SetFIFOSlaves(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: cboTOP (action)
        '---------------------------------------------------------------------
        Case "cboTOP"
            ' all current slaves released
            ResetFIFOSlaves(r, vIndex, iNr)
            If ("n.a." = v(1)) Then
              r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = &HFF
              r.v(sRegPre & "MOFGPR" & iNr & "_BOT") = &HFF
              r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = &HFF
            Else
              For i = 0 To (CAN_MAX_OBJECTS - 1)
                If ("MO" & i = v(1)) Then
                  r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = i
                  r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = i
                  Exit For
                End If
              Next i
            End If
            ' all new slaves configured
            SetFIFOSlaves(r, vIndex, iNr)

        '---------------------------------------------------------------------
        ' control: cboCUR (action)
        '---------------------------------------------------------------------
        ' the CUR pointer is configured automatically for a transmit FIFO slave
        ' and for Gateway mode
        Case "cboCUR"
            If ("n.a." = v(1)) Then
              r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = &HFF
            Else
              For i = 0 To (CAN_MAX_OBJECTS - 1)
                If ("MO" & i = v(1)) Then
                  r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = i
                  Exit For
                End If
              Next i
            End If

        '---------------------------------------------------------------------
        ' control: cboSEL (action)
        '---------------------------------------------------------------------
        Case "cboSEL"
            If ("n.a." = v(1)) Then
              r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = &HFF
            Else
              For i = 0 To (CAN_MAX_OBJECTS - 1)
                If ("MO" & i = v(1)) Then
                  r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = i
                  Exit For
                End If
              Next i
            End If

        '---------------------------------------------------------------------
        ' control: lstRelatedMOs (action)
        '---------------------------------------------------------------------
        Case "lstRelatedMOs"

        '---------------------------------------------------------------------
        ' control: chkDLCC (action)
        '---------------------------------------------------------------------
        Case "chkDLCC"
              r.v(sRegPre & "MOFCR" & iNr & "_DLCC") = v(1)

        '---------------------------------------------------------------------
        ' control: chkIDC (action)
        '---------------------------------------------------------------------
        Case "chkIDC"
              r.v(sRegPre & "MOFCR" & iNr & "_IDC") = v(1)

        '---------------------------------------------------------------------
        ' control: chkDATC (action)
        '---------------------------------------------------------------------
        Case "chkDATC"
              r.v(sRegPre & "MOFCR" & iNr & "_DATC") = v(1)

        '---------------------------------------------------------------------
        ' control: chkGDFS (action)
        '---------------------------------------------------------------------
        Case "chkGDFS"
              r.v(sRegPre & "MOFCR" & iNr & "_GDFS") = v(1)

        '---------------------------------------------------------------------
        ' control: chkFRREN (action)
        '---------------------------------------------------------------------
        Case "chkFRREN"
              r.v(sRegPre & "MOFCR" & iNr & "_FRREN") = v(1)

      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: FIFO_Gateway (show)
    '-------------------------------------------------------------------------

    '-------------------------------------------------------------------------
    ' control: optMMC_0 (show) Standard message object
    '-------------------------------------------------------------------------
    With c("optMMC_0")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0)
    End With

    With e("optMMC_0")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMMC_1 (show)   Receive FIFO base object
    '-------------------------------------------------------------------------
    With c("optMMC_1")
      ' disable condition
      bDisabled = (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOCTR" & iNr & "_DIR") <> 0)
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 1)
    End With

    With e("optMMC_1")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
         If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") <> 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a receive object")
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMMC_2 (show)  Transmit FIFO base object
    '-------------------------------------------------------------------------
    With c("optMMC_2")
      ' disable condition
       bDisabled = (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOCTR" & iNr & "_DIR") <> 1)
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 2)
    End With

    With e("optMMC_2")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
         If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") <> 1) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a transmit object")
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMMC_3 (show)  Transmit FIFO slave object
    '-------------------------------------------------------------------------
    With c("optMMC_3")
      ' disable condition
      bDisabled = True
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 3)
    End With

    With e("optMMC_3")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = FormatNormalTooltip("this setting will be configured by DAvE automatically")
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: optMMC_4 (show)       gateway source object
    '-------------------------------------------------------------------------
    With c("optMMC_4")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 4)
    End With

    With e("optMMC_4")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboBOT (show)
    '-------------------------------------------------------------------------
    With c("cboBOT")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      .AddItem "n.a."
      If (r.v(sRegPre & "MOFGPR" & iNr & "_BOT") = &HFF) Then
        .ListIndex = 0
      End If
      j = 1
      For i = 0 To (CAN_MAX_OBJECTS - 1)
        ' show all MOs which are connected to a Node and which are in the standard mode and which are not
        ' part of a FIFO
        If (r.v(sRegPre & "MOCTR" & i & "_LIST") > 0) Then
          iBaseNr = IsObjFIFOSlave(r, vIndex, i)
          If ((iBaseNr = -1 And r.v(sRegPre & "MOFCR" & i & "_MMC") = 0) Or iBaseNr = iNr Or i = iNr) Then
            .AddItem "MO" & i
            If (r.v(sRegPre & "MOFGPR" & iNr & "_BOT") = i) Then
              .ListIndex = j
            End If
            j = j + 1
          End If
        End If
      Next i
    End With

    With e("cboBOT")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a FIFO base object or a gateway source object")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblBOT (show)
    '-------------------------------------------------------------------------
    With c("lblBOT")
      ' same as for cboBOT
      .Enabled = Not (bDisabled)
    End With

    With e("lblBOT")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboBOT").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With


    '-------------------------------------------------------------------------
    ' control: cboTOP (show)
    '-------------------------------------------------------------------------
    With c("cboTOP")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      .AddItem "n.a."
      If (r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = &HFF) Then
        .ListIndex = 0
      End If
      j = 1
      For i = 0 To (CAN_MAX_OBJECTS - 1)
        ' show all MOs which are connected to the same Node as MO iNr and the LISTPOS is >= BOT
        ' also the MO must be in the standard mode and not part of a FIFO
        If (r.v(sRegPre & "MOFGPR" & iNr & "_TOP") <= (CAN_MAX_OBJECTS - 1)) Then
          If (r.v(sRegPre & "MOCTR" & r.v(sRegPre & "MOFGPR" & iNr & "_BOT") & "_LIST") > 0) Then
            If (r.v(sRegPre & "MOCTR" & i & "_LIST") = r.v(sRegPre & "MOCTR" & r.v(sRegPre & "MOFGPR" & iNr & "_BOT") & "_LIST")) Then
              If (r.v(sVarPre & "_MO" & i & "_LISTPOS") >= r.v(sVarPre & "_MO" & r.v(sRegPre & "MOFGPR" & iNr & "_BOT") & "_LISTPOS")) Then
                iBaseNr = IsObjFIFOSlave(r, vIndex, i)
                If ((iBaseNr = -1 And r.v(sRegPre & "MOFCR" & i & "_MMC") = 0) Or iBaseNr = iNr Or i = iNr) Then
                  .AddItem "MO" & i
                  If (r.v(sRegPre & "MOFGPR" & iNr & "_TOP") = i) Then
                    .ListIndex = j
                  End If
                  j = j + 1
                End If
              End If
            End If
          End If
        End If
      Next i
    End With

    With e("cboTOP")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a FIFO base object or a gateway source object")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblTOP (show)
    '-------------------------------------------------------------------------
    With c("lblTOP")
      ' same as for cboTOP
      .Enabled = Not (bDisabled)
    End With

    With e("lblTOP")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboTOP").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboCUR (show)
    '-------------------------------------------------------------------------
    With c("cboCUR")
      ' disable condition
      bDisabled = True
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      .AddItem "n.a."
      If (r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = &HFF) Then
        .ListIndex = 0
      End If
      j = 1
      For i = 0 To (CAN_MAX_OBJECTS - 1)
        If (r.v(sRegPre & "MOCTR" & i & "_LIST") > 0) Then
          .AddItem "MO" & i
          If (r.v(sRegPre & "MOFGPR" & iNr & "_CUR") = i) Then
            .ListIndex = j
          End If
          j = j + 1
        End If
      Next i
    End With

    With e("cboCUR")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the current object pointer (CUR) will be automatically set by DAvE")
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
'          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblCUR (show)
    '-------------------------------------------------------------------------
    With c("lblCUR")
      ' same as for cboCUR
      .Enabled = Not (bDisabled)
    End With

    With e("lblCUR")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboCUR").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboSEL (show)
    '-------------------------------------------------------------------------
    With c("cboSEL")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      .AddItem "n.a."
      If (r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = &HFF) Then
        .ListIndex = 0
      End If
      j = 1
      ' suche alle MOs von BOT bis TOP des MOs iNr
      iFirstNr = r.v(sRegPre & "MOFGPR" & iNr & "_BOT")
      iLastNr = r.v(sRegPre & "MOFGPR" & iNr & "_TOP")
      If (iFirstNr <= (CAN_MAX_OBJECTS - 1) And iLastNr <= (CAN_MAX_OBJECTS - 1)) Then
        If (r.v(sRegPre & "MOCTR" & iFirstNr & "_LIST") > 0 And r.v(sRegPre & "MOCTR" & iLastNr & "_LIST") > 0) Then
          iNextNr = iFirstNr
          Do
            If (iNextNr <> iLastNr) Then
              .AddItem "MO" & iNextNr
              If (r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = iNextNr) Then
                .ListIndex = j
              End If
              j = j + 1
              iNextNr = GetPNEXT(r, vIndex, iNextNr)
            End If
          Loop Until iNextNr = iLastNr
          .AddItem "MO" & iLastNr
          If (r.v(sRegPre & "MOFGPR" & iNr & "_SEL") = iLastNr) Then
            .ListIndex = j
          End If
        End If
      End If
  
    End With

    With e("cboSEL")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_MMC") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a FIFO base object or a gateway source object")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblSEL (show)
    '-------------------------------------------------------------------------
    With c("lblSEL")
      ' same as for cboSEL
      .Enabled = Not (bDisabled)
    End With

    With e("lblSEL")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = e("cboSEL").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lstRelatedMOs (show)
    '-------------------------------------------------------------------------
    With c("lstRelatedMOs")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear

      ' suche alle MOs von BOT bis TOP des MOs iNr
      iFirstNr = r.v(sRegPre & "MOFGPR" & iNr & "_BOT")
      iLastNr = r.v(sRegPre & "MOFGPR" & iNr & "_TOP")
      If (iFirstNr <= (CAN_MAX_OBJECTS - 1) And iLastNr <= (CAN_MAX_OBJECTS - 1)) Then
        If (r.v(sRegPre & "MOCTR" & iFirstNr & "_LIST") > 0 And r.v(sRegPre & "MOCTR" & iLastNr & "_LIST") > 0) Then
          iNextNr = iFirstNr
          Do
            If (iNextNr <> iLastNr) Then
              .AddItem "MO" & iNextNr
              iNextNr = GetPNEXT(r, vIndex, iNextNr)
            End If
          Loop Until iNextNr = iLastNr
          .AddItem "MO" & iLastNr
        End If
      End If
  
    End With

    With e("lstRelatedMOs")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
         If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
           .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
         End If
      Else
        ' tooltip if control is enabled
      End If
    End With

'    '-------------------------------------------------------------------------
'    ' control: lblRelatedMOs (show)
'    '-------------------------------------------------------------------------
'    With c("lblRelatedMOs")
'      ' same as for lstRelatedMOs
'      .Enabled = Not(bDisabled)
'    End With
'
'    With e("lblRelatedMOs")
'      If (bDisabled) Then
'        ' tooltip if control is disabled
'        .DisabledTooltipText = e("lstRelatedMOs").DisabledTooltipText
'      Else
'        ' tooltip if control is enabled
'      End If
'    End With


    '-------------------------------------------------------------------------
    ' frame: frmDLCC, frmIDC, frmDATC, frmGDFS (show)
    '-------------------------------------------------------------------------
    bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 4
    ' tooltip if control is disabled
    d = TOOLTIP_DISABLED_IF
    If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
      d = d & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
    End If
    If (r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 4) Then
      d = d & FormatDisabledTooltip("this object is not a gateway source object")
    End If
    Call SetDefaultPropertiesForAllControlsOnFrame(c("frmDLCC").Caption, c, e, bDisabled, d, "")
    Call SetDefaultPropertiesForAllControlsOnFrame(c("frmIDC").Caption, c, e, bDisabled, d, "")
    Call SetDefaultPropertiesForAllControlsOnFrame(c("frmDATC").Caption, c, e, bDisabled, d, "")
    Call SetDefaultPropertiesForAllControlsOnFrame(c("frmGDFS").Caption, c, e, bDisabled, d, "")

    '-------------------------------------------------------------------------
    ' control: chkDLCC (show)
    '-------------------------------------------------------------------------
    With c("chkDLCC")
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_DLCC") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkIDC (show)
    '-------------------------------------------------------------------------
    With c("chkIDC")
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_IDC") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkDATC (show)
    '-------------------------------------------------------------------------
    With c("chkDATC")
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_DATC") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkGDFS (show)
    '-------------------------------------------------------------------------
    With c("chkGDFS")
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_GDFS") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkFRREN (show)
    '-------------------------------------------------------------------------
    With c("chkFRREN")
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_FRREN") = 1)
    End With

    ' -------------------------------------------------------------------------------
    ' if a FIFO slave object is automatically configured by DAvE then this disable
    ' condition and tooltips are used
    ' -------------------------------------------------------------------------------
    iBaseNr = IsObjFIFOSlave(r, vIndex, iNr)
    If (iBaseNr >= 0) Then
      bDisabled = True
      ' tooltip if control is disabled
      d = TOOLTIP_DISABLED_IF
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 1) Then
        d = d & FormatDisabledTooltip("this object is a receive FIFO slave object, connected to the base object " & iBaseNr)
      End If
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 2) Then
        d = d & FormatDisabledTooltip("this object is a transmit FIFO slave object, connected to the base object " & iBaseNr)
      End If
      If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") = 4) Then
        d = d & FormatDisabledTooltip("this object is a gateway destination object, connected to the source object " & iBaseNr)
      End If
      Call SetDefaultPropertiesForAllControlsOnPage("FIFO/Gateway", c, e, bDisabled, d, "")
    End If

    '-------------------------------------------------------------------------
    ' control: chkFRREN (show)
    '-------------------------------------------------------------------------
    iBaseNr = IsObjFIFOSlave(r, vIndex, iNr)
    With c("chkFRREN")
      ' disable condition
      If (iBaseNr >= 0) Then ' if slave object
        bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") <> 4
      Else
        bDisabled = True
      End If
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_FRREN") = 1)
    End With

    With e("chkFRREN")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (iBaseNr >= 0) Then
          If (r.v(sRegPre & "MOFCR" & iBaseNr & "_MMC") <> 4) Then
            .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a gateway destination object")
          End If
        Else
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a gateway destination object")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With



  End If

  OnShowPageFIFO_Gateway = True
  Exit Function

OnShowPageFIFO_GatewayError:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnLoad function of the associated
'        module in order to add the page 'Interrupt'.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnLoadPageInterrupt(ps As Object) As Boolean
  On Error Resume Next

  OnLoadPageInterrupt = False

  If (Not ps.AddPage("Interrupt")) Then Exit Function

  OnLoadPageInterrupt = True
End Function


'*****************************************************************************
'Description:
'        This function is called from the OnChangingPage function of the
'        associated module in order load all controls for the requested page
'        if they are not already loaded.
'-----------------------------------------------------------------------------
'Parameters:
'        ps               reference to the Peripherals object
'        Pagename         requested page name
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Function OnChangingPageInterrupt(ps As Object, Pagename As String) As Boolean
  On Error Resume Next
  Dim r As ProjectData
  Dim iNr As Integer
  Dim vIndex As Variant
  Dim sVarPre As String

  OnChangingPageInterrupt = False

  vIndex = ps.Parameters.v("x")
  sVarPre = "CAN" & vIndex
  iNr = ps.Parameters.v("Number")

  Set r = ps.ProjectData

  
  If (Not ps.ExtenderCollection("Interrupt").Loaded) And (Pagename = "Interrupt") Then
    ps.ExtenderCollection("Interrupt").Loaded = True
  
    '-------------------------------
    ' frame: frmInterrupt
    '-------------------------------
    If (Not ps.AddFrame("frmInterrupt", 100, 100, 8400, 1400, "Interrupt Control")) Then Exit Function
        If (Not ps.AddCheck("chkRXIE", 200, 350, 6900, 380, "Enable receive interrupt; bit RXPND is set after successful reception of a frame (RXIE)")) Then Exit Function
        If (Not ps.AddCheck("chkTXIE", 200, 800, 7100, 380, "Enable transmit interrupt; bit TXPND is set after successful transmission of a frame (TXIE)")) Then Exit Function

    '-------------------------------
    ' frame: frmOVIE
    '-------------------------------
    If (Not ps.AddFrame("frmOVIE", 100, 1650, 8400, 800, "Overflow Interrupt Enable")) Then Exit Function
        If (Not ps.AddCheck("chkOVIE", 200, 300, 3000, 380, "Enable FIFO overflow interrupt (OVIE)")) Then Exit Function
        If (Not ps.AddCombo("cboOVIE", 3600, 300, 2100, 315)) Then Exit Function

    '-------------------------------
    ' frame: frmINP
    '-------------------------------
    If (Not ps.AddFrame("frmINP", 100, 2600, 8400, 1600, "Interrupt Node Pointer")) Then Exit Function
        If (Not ps.AddCombo("cboRXINP", 3600, 400, 2100, 315)) Then Exit Function
        If (Not ps.AddLabel("lblRXINP", 0, 200, 400, 3100, 385, "Receive interrupt node pointer (RXINP)")) Then Exit Function
        If (Not ps.AddCombo("cboTXINP", 3600, 1000, 2100, 315)) Then Exit Function
        If (Not ps.AddLabel("lblTXINP", 0, 200, 1000, 3100, 385, "Transmit interrupt node pointer (TXINP)")) Then Exit Function

  End If
  OnChangingPageInterrupt = True
End Function



'*****************************************************************************
'Description:
'        This function is called from the OnShow function of the associated
'        module. See the description for the OnShow function of the
'        associated module for details.
'-----------------------------------------------------------------------------
'Parameters:
'        ps              reference to the Peripherals object
'        Controlname     control name
'        Pagename        current page name
'        v()             value array
'-----------------------------------------------------------------------------
'Returns:
'        True            on successful operation
'        False           else
'*****************************************************************************
Public Function OnShowPageInterrupt(ps As Object, Controlname As String, Pagename As String, v() As Variant) As Boolean
  On Error GoTo OnShowPageInterruptError

  OnShowPageInterrupt = False

  Dim r As ProjectData
  Dim c As Object
  Dim e As Object
  Dim bDisabled As Boolean
  Dim vIndex As Variant
  Dim sVarPre As String
  Dim sRegPre As String
  Dim d As String
  Dim iNr As Integer
  Dim i As Integer

  vIndex = ps.Parameters.v("x")
  iNr = ps.Parameters.v("Number")
  sVarPre = "CAN" & vIndex
  sRegPre = sVarPre & "_"

  Set r = ps.ProjectData
  Set c = ps.ControlCollection
  Set e = ps.ExtenderCollection

  If (Pagename = "Interrupt") Then
    '-------------------------------------------------------------------------
    ' page: Interrupt (action)
    '-------------------------------------------------------------------------
    Select Case (Controlname)
        '---------------------------------------------------------------------
        ' control: chkTXIE (action)
        '---------------------------------------------------------------------
        Case "chkTXIE"
                r.v(sRegPre & "MOFCR" & iNr & "_TXIE") = v(1)

        '---------------------------------------------------------------------
        ' control: chkRXIE (action)
        '---------------------------------------------------------------------
        Case "chkRXIE"
                r.v(sRegPre & "MOFCR" & iNr & "_RXIE") = v(1)

        '---------------------------------------------------------------------
        ' control: chkOVIE (action)
        '---------------------------------------------------------------------
        Case "chkOVIE"
                r.v(sRegPre & "MOFCR" & iNr & "_OVIE") = v(1)
                
                
        '---------------------------------------------------------------------
        ' control: cboOVIE (action)
        '---------------------------------------------------------------------
        Case "cboOVIE"
            For i = 0 To (CAN_MAX_SRNS - 1)
              If ("Use CAN SRN " & i = v(1)) Then
               If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 1) Then
                   r.v(sRegPre & "MOIPR" & iNr & "_RXINP") = i
             ElseIf (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0) Then
                  r.v(sRegPre & "MOIPR" & iNr & "_TXINP") = i
                  Else
                  
                  End If
''                for the current DAvE implementation TXINP and RXINP must be the same
''                r.v(sRegPre & "MOIPR" & iNr & "_RXINP") = i
                Exit For
              End If
            Next i
        '---------------------------------------------------------------------
        ' control: cboTXINP (action)
        '---------------------------------------------------------------------
        Case "cboTXINP"
            For i = 0 To (CAN_MAX_SRNS - 1)
              If ("Use CAN SRN " & i = v(1)) Then
                r.v(sRegPre & "MOIPR" & iNr & "_TXINP") = i
''                ' for the current DAvE implementation TXINP and RXINP must be the same
''                r.v(sRegPre & "MOIPR" & iNr & "_RXINP") = i
                Exit For
              End If
            Next i

        '---------------------------------------------------------------------
        ' control: cboRXINP (action)
        '---------------------------------------------------------------------
        Case "cboRXINP"
            For i = 0 To (CAN_MAX_SRNS - 1)
              If ("Use CAN SRN " & i = v(1)) Then
                r.v(sRegPre & "MOIPR" & iNr & "_RXINP") = i
''                ' for the current DAvE implementation TXINP and RXINP must be the same
''                r.v(sRegPre & "MOIPR" & iNr & "_TXINP") = i
                Exit For
              End If
            Next i

      Case Else
    End Select

    '-------------------------------------------------------------------------
    ' page: Interrupt (show)
    '-------------------------------------------------------------------------
    '-------------------------------------------------------------------------
    ' frame: frmInterrupt (show)
    '-------------------------------------------------------------------------
    bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0
    ' tooltip if control is disabled
    d = TOOLTIP_DISABLED_IF
    If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
      d = d & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
    End If
    Call SetDefaultPropertiesForAllControlsOnFrame(c("frmInterrupt").Caption, c, e, bDisabled, d, "")

    '-------------------------------------------------------------------------
    ' control: chkTXIE (show)
    '-------------------------------------------------------------------------
    With c("chkTXIE")
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_TXIE") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkRXIE (show)
    '-------------------------------------------------------------------------
    With c("chkRXIE")
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_RXIE") = 1)
    End With

    '-------------------------------------------------------------------------
    ' control: chkOVIE (show)
    '-------------------------------------------------------------------------
    With c("chkOVIE")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 1 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 2 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 4
      .Enabled = Not (bDisabled)
      ' show condition
      .Value = -CInt(r.v(sRegPre & "MOFCR" & iNr & "_OVIE") = 1)
    End With

    With e("chkOVIE")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 1 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 2 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 4) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a FIFO base object or a Gateway source object")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With
    
    
     '-------------------------------------------------------------------------
    ' control: cboOVIE (show)
    '-------------------------------------------------------------------------
    With c("cboOVIE")
      ' disable condition
      
      bDisabled = r.v(sRegPre & "MOFCR" & iNr & "_OVIE") = 0
      'bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_TXIE") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      For i = 0 To (CAN_MAX_SRNS - 1)
        .AddItem "Use CAN SRN " & i
      Next i
             If (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 1) Then
                  .ListIndex = r.v(sRegPre & "MOIPR" & iNr & "_RXINP")
             ElseIf (r.v(sRegPre & "MOCTR" & iNr & "_DIR") = 0) Then
              .ListIndex = r.v(sRegPre & "MOIPR" & iNr & "_TXINP")
      End If
    End With

    With e("cboOVIE")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        ElseIf (r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 1 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 2 And r.v(sRegPre & "MOFCR" & iNr & "_MMC") <> 4) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("this object is not a FIFO base object or a Gateway source object")
        ElseIf (r.v(sRegPre & "MOFCR" & iNr & "_OVIE") = 0) Then
        .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("FIFO overflow interrupt is not selected ")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboTXINP (show)
    '-------------------------------------------------------------------------
    With c("cboTXINP")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_TXIE") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      For i = 0 To (CAN_MAX_SRNS - 1)
        .AddItem "Use CAN SRN " & i
      Next i
      .ListIndex = r.v(sRegPre & "MOIPR" & iNr & "_TXINP")
    End With

    With e("cboTXINP")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_TXIE") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the transmit interrupt is not enabled")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblTXINP (show)
    '-------------------------------------------------------------------------
    With c("lblTXINP")
      ' same as for cboTXINP
      .Enabled = Not (bDisabled)
    End With

    With e("lblTXINP")
      If (bDisabled) Then
        .DisabledTooltipText = e("cboTXINP").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: cboRXINP (show)
    '-------------------------------------------------------------------------
    With c("cboRXINP")
      ' disable condition
      bDisabled = r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0 Or r.v(sRegPre & "MOFCR" & iNr & "_RXIE") = 0
      .Enabled = Not (bDisabled)
      ' show condition
      .Clear
      For i = 0 To (CAN_MAX_SRNS - 1)
        .AddItem "Use CAN SRN " & i
      Next i
      .ListIndex = r.v(sRegPre & "MOIPR" & iNr & "_RXINP")
    End With

    With e("cboRXINP")
      If (bDisabled) Then
        ' tooltip if control is disabled
        .DisabledTooltipText = TOOLTIP_DISABLED_IF
        If (r.v(sRegPre & "MOCTR" & iNr & "_MSGVAL") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip(TOOLTIP_DISABLED_OBJECT)
        End If
        If (r.v(sRegPre & "MOFCR" & iNr & "_RXIE") = 0) Then
          .DisabledTooltipText = .DisabledTooltipText & FormatDisabledTooltip("the receive interrupt is not enabled")
        End If
      Else
        ' tooltip if control is enabled
      End If
    End With

    '-------------------------------------------------------------------------
    ' control: lblRXINP (show)
    '-------------------------------------------------------------------------
    With c("lblRXINP")
      ' same as for cboRXINP
      .Enabled = Not (bDisabled)
    End With

    With e("lblRXINP")
      If (bDisabled) Then
        .DisabledTooltipText = e("cboRXINP").DisabledTooltipText
      Else
        ' tooltip if control is enabled
      End If
    End With

  End If

  OnShowPageInterrupt = True
  Exit Function

OnShowPageInterruptError:
  Errorbox "Can not show page", Err.Description
  Exit Function
End Function




