subroutine Drawworks_Direction

    use CDrillingConsoleVariables
    use SimulationVariables
    use SimulationVariables
    use CDataDisplayConsole
    use SimulationVariables
    use SimulationVariables !@

	IMPLICIT NONE
    
    
    
    
    
    
    if (data%State%Drawworks%Switch==1) then            !Up
        data%State%Drawworks%motion = +1
        data%State%Drawworks%w_old_drum = data%State%Drawworks%w_drum !(pi*(data%State%Drawworks%N_old/data%State%Drawworks%Conv_Ratio)/30.d0)  ?
        data%State%Drawworks%w_drum = (pi*(data%State%Drawworks%Speed/data%State%Drawworks%Conv_Ratio)/30.d0)         ![rad/s]
        data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height+(((data%State%Drawworks%Diameter/2.0)*(data%State%Drawworks%time_step*0.5d0*(data%State%Drawworks%w_drum+data%State%Drawworks%w_old_drum)))/data%State%Drawworks%NumberOfLine)    ![m]
    else if (data%State%Drawworks%Switch==-1) then      !Down
        data%State%Drawworks%motion = -1
        data%State%Drawworks%w_old_drum = data%State%Drawworks%w_drum !(pi*(data%State%Drawworks%N_old/data%State%Drawworks%Conv_Ratio)/30.d0)  ?
        data%State%Drawworks%w_drum = (pi*(data%State%Drawworks%Speed/data%State%Drawworks%Conv_Ratio)/30.d0)         ![rad/s]
        data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height-(((data%State%Drawworks%Diameter/2.0)*(data%State%Drawworks%time_step*0.5d0*(data%State%Drawworks%w_drum+data%State%Drawworks%w_old_drum)))/data%State%Drawworks%NumberOfLine)    ![m]
    !else if (data%State%Drawworks%Switch==0) then      !Off
    !    data%State%Drawworks%motion = 0
    !    data%State%Drawworks%w_old_drum = 0.d0
    !    data%State%Drawworks%w_drum = 0.d0
    !    data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height
    end if
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    !if (data%State%Drawworks%Conv_Ratio==1.d0) then
    !    
    !    
    !    IF (data%State%Drawworks%motion==+1) THEN
    !        Call Drawworks_Free_Traction_motor_Dir
    !        if (data%State%Drawworks%w_drum_Dir<=0.) then
    !            data%State%Drawworks%motion = 0
    !        else
    !            data%State%Drawworks%motion = +1
    !            Call Drawworks_Free_Traction_motor
    !            data%State%Drawworks%w      = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%w_old  = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio
    !        end if
    !    ELSE
    !         if (((data%State%Drawworks%F_fastline*(data%State%Drawworks%Diameter/2.0d0))-(((data%State%Drawworks%Diameter/2.0d0)*data%State%Drawworks%BreakLoad)*(data%State%Drawworks%ManualBreak/100.0d0)))<=0.) then
    !            data%State%Drawworks%motion      = 0
    !            data%State%Drawworks%w_drum      = 0.0d0
    !            data%State%Drawworks%w_old_drum  = 0.0d0
    !            data%State%Drawworks%w           = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%w_old       = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height
    !            
    !            data%State%Drawworks%ia          = 0.
    !            data%State%Drawworks%ia_old      = 0.
    !            data%State%Drawworks%x           = 0.
    !            data%State%Drawworks%x_old       = 0.
    !            data%State%Drawworks%y           = 0.
    !            data%State%Drawworks%y_old       = 0.
    !        else
    !            data%State%Drawworks%motion      = -1
    !            Call Drawworks_Free_Traction_motor_dawn_motion
    !            data%State%Drawworks%w           = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%w_old       = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio
    !        end if
    !        
    !    END IF
    !     
    !    
    !else
    !    
    !    IF (data%State%Drawworks%motion==-1) THEN
    !        data%State%Drawworks%w          = -data%State%Drawworks%w
    !        data%State%Drawworks%w_old      = -data%State%Drawworks%w_old
    !        data%State%Drawworks%w_drum     = -data%State%Drawworks%w_drum
    !        data%State%Drawworks%w_old_drum = -data%State%Drawworks%w_old_drum
    !    END IF
    !    Call Drawworks_Traction_motor_ClutchMode_Dir
    !    IF (data%State%Drawworks%w_Dir>0.d0) then
    !        
    !        data%State%Drawworks%motion     = +1
    !        Call Drawworks_Traction_motor_ClutchMode
    !        data%State%Drawworks%w_drum     = data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio
    !        data%State%Drawworks%w_old_drum = data%State%Drawworks%w_old/data%State%Drawworks%Conv_Ratio
    !    ELSE
    !        data%State%Drawworks%EddyTorque   = (1.039d5*exp(4.343d-4*(30.0d0*(data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio)/pi)))+(-1.036d5*exp(-.047920d0*(30.0d0*(data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio)/pi)))   !Lbf.ft
    !        if (data%State%Drawworks%EddyTorque>115000.) then
    !          data%State%Drawworks%EddyTorque = 115000.0d0
    !        end if
    !        data%State%Drawworks%EddyTorque   = 1.355817948*data%State%Drawworks%EddyTorque           ![N.m]
    !        if ((data%State%Drawworks%F_fastline*(data%State%Drawworks%Diameter/2.0d0))>((((data%State%Drawworks%Diameter/2.0d0)*data%State%Drawworks%BreakLoad)*(data%State%Drawworks%ManualBreak/100.0d0))+(data%State%Drawworks%EddyTorque*(data%State%Drawworks%EddyBreak/100.0d0)))) then
    !            data%State%Drawworks%motion   = -1
    !            
    !            IF (data%State%Drawworks%w_drum<0.) THEN
    !                data%State%Drawworks%w          = -data%State%Drawworks%w
    !                data%State%Drawworks%w_old      = -data%State%Drawworks%w_old
    !                !data%State%Drawworks%w         = 0.        !???????????????
    !                !data%State%Drawworks%w_old     = 0.        !???????????????
    !                data%State%Drawworks%w_drum     = -data%State%Drawworks%w_drum
    !                data%State%Drawworks%w_old_drum = -data%State%Drawworks%w_old_drum
    !            END IF
    !            
    !            data%State%Drawworks%Conv_Ratio  = 1.
    !            Call Drawworks_Free_Traction_motor_dawn_motion
    !            data%State%Drawworks%w           = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%w_old       = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio
    !            !data%State%Drawworks%w_drum     = data%State%Drawworks%w/data%State%Drawworks%Conv_Ratio
    !            !data%State%Drawworks%w_old_drum = data%State%Drawworks%w_old/data%State%Drawworks%Conv_Ratio
    !        else
    !            data%State%Drawworks%motion      = 0
    !            data%State%Drawworks%w_drum      = 0.0d0
    !            data%State%Drawworks%w_old_drum  = 0.0d0
    !            data%State%Drawworks%w           = data%State%Drawworks%w_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%w_old       = data%State%Drawworks%w_old_drum*data%State%Drawworks%Conv_Ratio
    !            data%State%Drawworks%Hook_Height = data%State%Drawworks%Hook_Height
    !            
    !            data%State%Drawworks%ia     = 0.
    !            data%State%Drawworks%ia_old = 0.
    !            data%State%Drawworks%x      = 0.
    !            data%State%Drawworks%x_old  = 0.
    !            data%State%Drawworks%y      = 0.
    !            data%State%Drawworks%y_old  = 0.
    !        end if
    !
    !    END IF
    !    
    !end if
    
    
    
    !Call DWBrakeSound
    
  

end subroutine Drawworks_Direction