Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

181 lines
5.4 KiB

  1. module COperationConditionEnum
  2. use CLog4
  3. use OperationScenariosModule
  4. use SimulationVariables
  5. implicit none
  6. ! enum, bind(c)
  7. ! enumerator OPERATION_DRILL
  8. ! enumerator OPERATION_TRIP
  9. ! end enum
  10. contains
  11. subroutine Set_OperationCondition(v)
  12. ! use CKellyEnumVariables
  13. implicit none
  14. integer , intent(in) :: v
  15. #ifdef ExcludeExtraChanges
  16. if(data%State%unitySignals%OperationCondition == v) return
  17. #endif
  18. data%State%unitySignals%OperationCondition = v
  19. #ifdef deb
  20. if(print_log) print*, 'data%State%unitySignals%OperationCondition=', data%State%unitySignals%OperationCondition
  21. #endif
  22. ! call OnOperationConditionChange%RunAll()
  23. ! call OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition)
  24. end subroutine
  25. integer function Get_OperationCondition()
  26. implicit none
  27. Get_OperationCondition = data%State%unitySignals%OperationCondition
  28. end function
  29. subroutine Evaluate_OperationCondition()
  30. implicit none
  31. ! if (DriveType == TopDrive_DriveType) then
  32. !#ifdef OST
  33. ! if(print_log) print*, 'Evaluate_OperationCondition=TopDrive'
  34. !#endif
  35. ! endif
  36. !
  37. !
  38. !
  39. !
  40. !
  41. !
  42. !
  43. !
  44. ! if (DriveType == Kelly_DriveType) then
  45. !#ifdef OST
  46. ! if(print_log) print*, 'Evaluate_OperationCondition=Kelly'
  47. !#endif
  48. ! endif
  49. end subroutine
  50. ! subroutine Subscribe_OperationCondition()
  51. ! use CDrillingConsoleVariables
  52. !@ use ConfigurationVariables
  53. !@ use ConfigurationVariables
  54. ! implicit none
  55. ! call OnLatchPipePress%Add(ButtonPress_Latch_OperationCondition)
  56. ! call OnUnlatchPipePress%Add(ButtonPress_Unlatch_OperationCondition)
  57. ! end subroutine
  58. subroutine ButtonPress_Latch_OperationCondition()
  59. ! use ConfigurationVariables
  60. use CHoistingVariables
  61. use SimulationVariables!, only: data%Configuration%Hoisting%DriveType, Kelly_DriveType
  62. use CManifolds, only: InstallKellyCock
  63. implicit none
  64. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  65. #ifdef OST
  66. if(print_log) print*, 'ButtonPress_Latch_OperationCondition=TopDrive'
  67. #endif
  68. endif
  69. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  70. #ifdef OST
  71. if(print_log) print*, 'ButtonPress_Latch_OperationCondition=Kelly'
  72. #endif
  73. !OPERATION-CODE=17
  74. if (Get_OperationCondition() == OPERATION_TRIP .and.&
  75. Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.&
  76. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  77. Get_Swing() == SWING_RAT_HOLE_END .and.&
  78. Get_LatchLed() .and.&
  79. Get_UnlatchLed() == .false.) then
  80. call Set_OperationCondition(OPERATION_DRILL)
  81. call Set_LatchLed(.false.)
  82. call Set_UnlatchLed(.true.)
  83. call Set_Kelly(KELLY_INSTALL)
  84. if(data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  85. call InstallKellyCock() !drill mode
  86. endif
  87. return
  88. end if
  89. endif
  90. end subroutine
  91. subroutine ButtonPress_Unlatch_OperationCondition()
  92. use CHoistingVariables
  93. use SimulationVariables!, only: data%Configuration%Hoisting%DriveType, Kelly_DriveType
  94. use CManifolds, only: RemoveKellyCock
  95. implicit none
  96. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  97. #ifdef OST
  98. if(print_log) print*, 'ButtonPress_Unlatch_OperationCondition=TopDrive'
  99. #endif
  100. endif
  101. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  102. #ifdef OST
  103. if(print_log) print*, 'ButtonPress_Unlatch_OperationConditions=Kelly'
  104. #endif
  105. !OPERATION-CODE=18
  106. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  107. Get_ElevatorConnection() == ELEVATOR_CONNECTION_NOTHING .and.&
  108. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  109. Get_Swing() == SWING_RAT_HOLE_END .and.&
  110. Get_LatchLed() == .false. .and.&
  111. Get_UnlatchLed()) then
  112. call Set_Kelly(KELLY_REMOVE)
  113. call Set_Swing(SWING_WELL_BEGIN)
  114. call Set_OperationCondition(OPERATION_TRIP)
  115. call Set_LatchLed(.true.)
  116. call Set_UnlatchLed(.false.)
  117. call Set_IrSafetyValveLed(.false.)
  118. if(data%Configuration%Hoisting%DriveType == Kelly_DriveType) then ! top drive mode
  119. call RemoveKellyCock() !trip mode
  120. endif
  121. return
  122. end if
  123. endif
  124. end subroutine
  125. end module COperationConditionEnum