module CTongEnum
    use OperationScenariosModule
    implicit none
    contains
    
    subroutine Evaluate_Tong()
        implicit none
        
!        if (DriveType == TopDrive_DriveType) then
!            if(print_log) print*, 'Evaluate_Tong=TopDrive'
!        endif
!        if (DriveType == Kelly_DriveType) then
!            if(print_log) print*, 'Evaluate_Tong=Kelly'
!        endif
        
    end subroutine
    
    ! subroutine Subscribe_Tong()
    !     use CDrillingConsoleVariables
    !@    use ConfigurationVariables
    !     implicit none
        
    !     call OnBreakoutLeverPress%Add(ButtonPress_Breakout_TongNotification)
    !     call OnMakeupLeverPress%Add(ButtonPress_Makeup_TongNotification)
    !     call OnTongNeutralPress%Add(ButtonPress_Neutral_TongNotification)
        
    ! end subroutine
    
    
    
    subroutine ButtonPress_Breakout_TongNotification()
        implicit none
        if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
            if(print_log) print*, 'ButtonPress_Breakout_TongNotification=TopDrive'
            !TOPDRIVE-CODE=70
            if (Get_TongNotification()) then
                call Set_Tong(TONG_BREAKOUT_BEGIN)
                return
            end if
        endif
        if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
            if(print_log) print*, 'ButtonPress_Breakout_TongNotification=Kelly'
            !OPERATION-CODE=74
            if (Get_TongNotification()) then
                call Set_Tong(TONG_BREAKOUT_BEGIN)
            endif
        endif
    end subroutine
    
    
    
    
    
    
    
    subroutine ButtonPress_Makeup_TongNotification()
        use NotificationModule
        implicit none
        
        if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
            if(print_log) print*, 'ButtonPress_Makeup_TongNotification=TopDrive'
            !TOPDRIVE-CODE=69
            if (Get_TongNotification()) then
                call Set_Tong(TONG_MAKEUP_BEGIN)
                return
            end if
        endif
        
        if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
            if(print_log) print*, 'ButtonPress_Makeup_TongNotification=Kelly'
            !OPERATION-CODE=73
            if (Get_TongNotification()) then
                call Set_Tong(TONG_MAKEUP_BEGIN)
            endif
        endif        
        
    end subroutine
    
    subroutine ButtonPress_Neutral_TongNotification()
        implicit none
        if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
            if(print_log) print*, 'ButtonPress_Neutral_TongNotification=TopDrive'
        endif

        if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
            if(print_log) print*, 'ButtonPress_Neutral_TongNotification=Kelly'
            call Set_Tong(TONG_NEUTRAL)
        endif
    end subroutine
    
end module CTongEnum