# 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Notifications/CSwingLedNotification.f90"
module CSwingLedNotification
    use OperationScenariosModule
    use UnityModule
    implicit none
    contains
    
    subroutine Evaluate_SwingLed()
        implicit none
        
        
        
        
        
        if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
# 17




        endif
        
        
        
        
        
        
        
        
        
        if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
# 34



!OPERATION-CODE=22
            if (Get_OperationCondition() == OPERATION_TRIP .and.&
                Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.&
                Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.&
                Get_JointConnectionPossible() == .false. .and.&
                (Get_Swing() /= SWING_WELL_BEGIN .and.& 
                 Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
                 Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
                Get_Slips() == SLIPS_SET_END) then
            
                call Set_SwingLed(.true.)
                return
            end if
            
            
!OPERATION-CODE=23
            if (Get_OperationCondition() == OPERATION_TRIP .and.&
                Get_HookHeight() >= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.&
                Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.&
                Get_JointConnectionPossible() == .false. .and.&
                (Get_Swing() /= SWING_WELL_BEGIN .and.& 
                 Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
                 Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
                Get_Slips() == SLIPS_SET_END) then
            
                call Set_SwingLed(.true.)
                return
            end if
            
            
!OPERATION-CODE=24
            if (Get_OperationCondition() == OPERATION_DRILL .and.&
                Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG) .and.&
                Get_JointConnectionPossible() == .false. .and.&
                Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
                (Get_Swing() /= SWING_WELL_BEGIN .and.& 
                 Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
                 Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
                Get_Slips() == SLIPS_SET_END) then
            
                call Set_SwingLed(.true.)
                return
            end if
            
!OPERATION-CODE=25
            if (Get_OperationCondition() == OPERATION_DRILL .and.&
                Get_HookHeight() >= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%PL) .and. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection() + data%State%OperationScenario%LG + data%State%OperationScenario%PL) .and.&
                Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
                Get_JointConnectionPossible() == .false. .and.&
                (Get_Swing() /= SWING_WELL_BEGIN .and.& 
                 Get_Swing() /= SWING_MOUSE_HOLE_BEGIN .and.&
                 Get_Swing() /= SWING_RAT_HOLE_BEGIN) .and.&
                Get_Slips() == SLIPS_SET_END) then
            
                call Set_SwingLed(.true.)
                return
            end if
               
            
            call Set_SwingLed(.false.)
            
            
        endif
        
        
        
        
        
        
        
        
    end subroutine
    
! subroutine Subscribe_SwingLed()
!     implicit none
        
!     call OnOperationConditionChange%Add(Evaluate_SwingLed)
!     call OnHookHeightChange%Add(Evaluate_SwingLed)
!     call OnElevatorConnectionChange%Add(Evaluate_SwingLed)
!     call OnKellyConnectionChange%Add(Evaluate_SwingLed)
!     call OnSwingChange%Add(Evaluate_SwingLed)
!     call OnSlipsChange%Add(Evaluate_SwingLed)
!     call OnFillMouseHoleLedChange%Add(Evaluate_SwingLed)
        
! end subroutine
    
end module CSwingLedNotification