module CIrIBopLedNotification
    use OperationScenariosModule
    ! use CTopDrivePanelVariables
    use SimulationVariables
    implicit none
    contains
    
    subroutine Evaluate_IrIBopLed()
        implicit none
        
        
        
!        if (DriveType == TopDrive_DriveType) then
!#ifdef OST
!            print*, 'Evaluate_IrIBopLed=TopDrive'
!#endif
!        endif
!        
!        
!        
!        
!        
!        
!        
!        
!        if (DriveType == Kelly_DriveType) then
!#ifdef OST
!            print*, 'Evaluate_IrIBopLed=Kelly'
!#endif
!        endif
        
        
        
        
    end subroutine
    
    ! subroutine Subscribe_IrIBopLed()
    !     use CDrillingConsoleVariables
!@    use ConfigurationVariables
!@    use ConfigurationVariables
    !     implicit none
    !     call OnIRIBopPress%Add(ButtonPress_IrIBop)
    ! end subroutine
    
    subroutine ButtonPress_IrIBop()
        implicit none
        
        
        
        
        
        if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
#ifdef OST
            print*, 'Evaluate_IrIBopLed=TopDrive'
#endif



            !TOPDRIVE-CODE=59
            if (Get_IrIbopPermission() .and.&
                Get_IrIBopLed() == .false.) then
            
                call Set_IrIBopLed(.true.)
                return
            end if


            
            
            !TOPDRIVE-CODE=60
            if (Get_IrIbopPermission() .and.&
                Get_IrIBopLed() == .true. .and.&
                data%EquipmentControl%TopDrivePanel%TopDriveTdsPowerState == TdsPower_OFF) then
            
                call Set_IrIBopLed(.false.)
                return
            end if
            
            
            
        endif
        
        
        
        
        
        
        
        
        if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
#ifdef OST
            print*, 'Evaluate_IrIBopLed=Kelly'
#endif

            !OPERATION-CODE=63
            if (Get_IrIbopPermission() .and.&
                Get_IrIBopLed() == .false.) then
                call Set_IrIBopLed(.true.)
                return
            end if
        
            
            !OPERATION-CODE=64
            if (Get_IrIbopPermission() .and.&
                Get_IrIBopLed()) then
                call Set_IrIBopLed(.false.)
                return
            end if

        endif
        
        
        
        
        
        
            
    end subroutine
    
end module CIrIBopLedNotification