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.

CTongNotification.f90 11 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. module CTongNotification
  2. use COperationScenariosVariables
  3. implicit none
  4. contains
  5. subroutine Evaluate_TongNotification()
  6. implicit none
  7. if (Hoisting%DriveType == TopDrive_DriveType) then
  8. #ifdef OST
  9. print*, 'Evaluate_TongNotification=TopDrive'
  10. #endif
  11. !TOPDRIVE-CODE=50
  12. if (((Get_HookHeight() >= (TL() + OperationScenario%PL - OperationScenario%ECG + NFC() - OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + OperationScenario%PL - OperationScenario%ECG + OperationScenario%TG)) .or.&
  13. (Get_HookHeight() >= (TL() + OperationScenario%SL - OperationScenario%ECG + NFC() - OperationScenario%RE) .and. Get_HookHeight() <= (TL() + NFC() + OperationScenario%SL - OperationScenario%ECG + OperationScenario%TG))).and.&
  14. GetRotaryRpm() == 0.0d0 .and.&
  15. Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
  16. ((Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  17. Get_Tong() /= TONG_MAKEUP_BEGIN) .or.&
  18. Get_Tong() == TONG_NEUTRAL ) .and.&
  19. (Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STRING .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING) .and.&
  20. Get_TdsSwing() == TDS_SWING_OFF_END .and.&
  21. Get_Slips() == SLIPS_SET_END) then
  22. call Set_TongNotification(.true.)
  23. return
  24. end if
  25. !TOPDRIVE-CODE=51
  26. if (GetRotaryRpm() == 0.0d0 .and.&
  27. Get_JointConnectionPossible() .and.&
  28. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  29. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  30. (Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_SINGLE .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_SINGLE) .and.&
  31. Get_TdsSwing() == TDS_SWING_OFF_END .and.&
  32. Get_Slips() == SLIPS_SET_END) then
  33. call Set_TongNotification(.true.)
  34. return
  35. end if
  36. !TOPDRIVE-CODE=52
  37. if (GetRotaryRpm() == 0.0d0 .and.&
  38. Get_JointConnectionPossible() .and.&
  39. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  40. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  41. (Get_TdsElevatorModes() == TDS_ELEVATOR_LATCH_STAND .or. Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STAND) .and.&
  42. Get_TdsSwing() == TDS_SWING_OFF_END .and.&
  43. Get_Slips() == SLIPS_SET_END) then
  44. call Set_TongNotification(.true.)
  45. return
  46. end if
  47. endif
  48. if (Hoisting%DriveType == Kelly_DriveType) then
  49. #ifdef OST
  50. print*, 'Evaluate_TongNotification=Kelly'
  51. #endif
  52. !OPERATION-CODE=44
  53. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  54. !((Get_HookHeight() >= 65.0 .and. Get_HookHeight() <= 70.0) .or.&
  55. ! (Get_HookHeight() >= 96.0 .and. Get_HookHeight() <= 101.0)).and.&
  56. ((Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%TG)) .or.&
  57. (Get_HookHeight() >= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%PL -OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HKL + Get_NearFloorConnection() + OperationScenario%TG + OperationScenario%PL))).and.&
  58. GetRotaryRpm() == 0.0d0 .and.&
  59. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  60. Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
  61. Get_Swing() == SWING_WELL_END .and.&
  62. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  63. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  64. Get_Slips() == SLIPS_SET_END) then
  65. call Set_TongNotification(.true.)
  66. return
  67. end if
  68. !OPERATION-CODE=45
  69. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  70. Get_HookHeight() >= 66 .and. Get_HookHeight() <= 69 .and.&
  71. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  72. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  73. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  74. Get_Swing() == SWING_MOUSE_HOLE_END) then
  75. call Set_TongNotification(.true.)
  76. return
  77. end if
  78. !OPERATION-CODE=46
  79. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  80. Get_JointConnectionPossible() .and.&
  81. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  82. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  83. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  84. Get_Swing() == SWING_MOUSE_HOLE_END) then
  85. call Set_TongNotification(.true.)
  86. return
  87. end if
  88. !OPERATION-CODE=47
  89. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  90. GetRotaryRpm() == 0.0d0 .and.&
  91. Get_JointConnectionPossible() .and.&
  92. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  93. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  94. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  95. Get_Swing() == SWING_WELL_END .and.&
  96. Get_Slips() == SLIPS_SET_END) then
  97. call Set_TongNotification(.true.)
  98. return
  99. end if
  100. !OPERATION-CODE=48
  101. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  102. GetRotaryRpm() == 0.0d0 .and.&
  103. Get_JointConnectionPossible() .and.&
  104. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  105. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  106. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  107. Get_Swing() == SWING_WELL_END .and.&
  108. Get_Slips() == SLIPS_SET_END) then
  109. call Set_TongNotification(.true.)
  110. return
  111. end if
  112. !OPERATION-CODE=50
  113. if (Get_OperationCondition() == OPERATION_TRIP .and.&
  114. ((Get_HookHeight() >= (OperationScenario%HL + OperationScenario%PL - OperationScenario%ECG + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%PL - OperationScenario%ECG + OperationScenario%TG)) .or.&
  115. (Get_HookHeight() >= (OperationScenario%HL + OperationScenario%SL - OperationScenario%ECG + Get_NearFloorConnection() - OperationScenario%RE) .and. Get_HookHeight() <= (OperationScenario%HL + Get_NearFloorConnection() + OperationScenario%TG - OperationScenario%ECG + OperationScenario%SL))).and.&
  116. Get_NearFloorConnection() >= 3.0 .and. Get_NearFloorConnection() <= 6.0 .and.&
  117. GetRotaryRpm() == 0.0d0 .and.&
  118. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.&
  119. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  120. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  121. Get_Swing() == SWING_WELL_END .and.&
  122. Get_Slips() == SLIPS_SET_END) then
  123. call Set_TongNotification(.true.)
  124. return
  125. end if
  126. !OPERATION-CODE=51
  127. if (Get_OperationCondition() == OPERATION_TRIP .and.&
  128. GetRotaryRpm() == 0.0d0 .and.&
  129. Get_JointConnectionPossible() .and.&
  130. Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE .and.&
  131. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  132. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  133. Get_Swing() == SWING_WELL_END .and.&
  134. Get_Slips() == SLIPS_SET_END) then
  135. call Set_TongNotification(.true.)
  136. return
  137. end if
  138. !OPERATION-CODE=52
  139. if (Get_OperationCondition() == OPERATION_TRIP .and.&
  140. GetRotaryRpm() == 0.0d0 .and.&
  141. Get_JointConnectionPossible() .and.&
  142. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STAND .and.&
  143. (Get_Tong() /= TONG_BREAKOUT_BEGIN .and.&
  144. Get_Tong() /= TONG_MAKEUP_BEGIN) .and.&
  145. Get_Swing() == SWING_WELL_END .and.&
  146. Get_Slips() == SLIPS_SET_END) then
  147. call Set_TongNotification(.true.)
  148. return
  149. end if
  150. !if (Get_OperationCondition() == OPERATION_DRILL .and.&
  151. ! Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  152. ! Get_Swing() == SWING_WELL_END .and.&
  153. ! Get_Slips() == SLIPS_SET_END) then
  154. !
  155. ! call Set_TongNotification(.true.)
  156. ! return
  157. !end if
  158. !
  159. call Set_TongNotification(.false.)
  160. endif
  161. end subroutine
  162. subroutine Subscribe_TongNotification()
  163. implicit none
  164. call UnitySignals%OnOperationConditionChange%Add(Evaluate_TongNotification)
  165. call SoftwareInputs%OnHookHeightChange%Add(Evaluate_TongNotification)
  166. call UnityInputs%OnJointConnectionPossibleChange%Add(Evaluate_TongNotification)
  167. call UnityInputs%OnSingleSetInMouseHoleChange%Add(Evaluate_TongNotification)
  168. call OperationScenario%OnElevatorConnectionChange%Add(Evaluate_TongNotification)
  169. call KellyConnectionEnum%OnKellyConnectionChange%Add(Evaluate_TongNotification)
  170. call UnitySignals%OnSwingChange%Add(Evaluate_TongNotification)
  171. call UnitySignals%OnSlipsChange%Add(Evaluate_TongNotification)
  172. end subroutine
  173. end module CTongNotification