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.
 
 
 
 
 
 

425 lines
13 KiB

  1. module COperationScenariosMain
  2. use CIActionReference
  3. implicit none
  4. public
  5. ! procedure (ActionVoid), pointer :: UpdateUnityPtr
  6. contains
  7. subroutine OperationScenarios_Step
  8. ! use CSimulationVariables
  9. use OperationScenariosModule
  10. use CElevatorConnectionEnum
  11. use CCloseKellyCockLedNotification
  12. use CCloseSafetyValveLedNotification
  13. use CFillMouseHoleLedNotification
  14. use CIrIBopLedNotification
  15. use CIrSafetyValveLedNotification
  16. use CLatchLedNotification
  17. use COpenKellyCockLedNotification
  18. use COpenSafetyValveLedNotification
  19. use CSlipsNotification
  20. use CSwingLedNotification
  21. use CTongNotification
  22. use CUnlatchLedNotification
  23. use CInstallFillupHeadPermission
  24. use CInstallMudBucketPermission
  25. use CIrIbopPermission
  26. use CIrSafetyValvePermission
  27. use CRemoveFillupHeadPermission
  28. use CRemoveMudBucketPermission
  29. use SoftwareInputsVariables
  30. ! use CHookHeight
  31. ! use CIbopHeight
  32. ! use CNearFloorConnection
  33. ! use CSafetyValveHeight
  34. ! use CSlackOff
  35. ! use CStandRack
  36. ! use CStringPressure
  37. ! use CZeroStringSpeed
  38. ! use CUnityInputs, only: &
  39. ! Get_ElevatorConnectionPossible, &
  40. ! Get_JointConnectionPossible, &
  41. ! Get_ElevatorPickup, &
  42. ! Get_NearFloorPosition, &
  43. ! Get_SingleSetInMouseHole
  44. ! use CBucketEnum
  45. ! use UnitySignalsModule
  46. use UnityModule
  47. use CElevatorEnum
  48. ! use CHeadEnum
  49. use CIbopEnum
  50. use CKellyEnum
  51. use CMouseHoleEnum
  52. use UnitySignalsModule
  53. use CSafetyValveEnum
  54. use CSlipsEnum
  55. use CSwingEnum
  56. use CTongEnum
  57. ! use CStringUpdate
  58. use CFlowPipeDisconnectEnum
  59. use CFlowKellyDisconnectEnum
  60. use CFillupHeadPermission
  61. use CSwingDrillPermission
  62. use CSwingOffPermission
  63. use CSwingTiltPermission
  64. ! use CTdsStemJointHeight
  65. ! use UnitySignalsModule !for CTdsConnectionModesEnum
  66. use CTdsElevatorModesEnum
  67. use CTdsSpineEnum
  68. use CTdsSwingEnum
  69. use CTdsTongEnum
  70. use CTdsBackupClamp
  71. use CTdsIbopLedNotification
  72. use CTdsPowerLedNotification
  73. use CTdsTorqueWrenchLedNotification
  74. implicit none
  75. call Evaluate_KellyConnection()
  76. call Evaluate_ElevatorConnection()
  77. call Evaluate_CloseKellyCockLed()
  78. call Evaluate_CloseSafetyValveLed()
  79. call Evaluate_FillMouseHoleLed()
  80. call Evaluate_IrIBopLed()
  81. call Evaluate_IrSafetyValveLed()
  82. call Evaluate_LatchLed()
  83. call Evaluate_OpenKellyCockLed()
  84. call Evaluate_OpenSafetyValveLed()
  85. call Evaluate_SlipsNotification()
  86. call Evaluate_SwingLed()
  87. call Evaluate_TongNotification()
  88. call Evaluate_UnlatchLed()
  89. call Evaluate_InstallFillupHeadPermission()
  90. call Evaluate_InstallMudBucketPermission()
  91. call Evaluate_IrIbopPermission()
  92. call Evaluate_IrSafetyValvePermission()
  93. call Evaluate_RemoveFillupHeadPermission()
  94. call Evaluate_RemoveMudBucketPermission()
  95. call Evaluate_MudBucket()
  96. call Evaluate_Elevator()
  97. call Evaluate_FillupHead()
  98. call Evaluate_Ibop()
  99. call Evaluate_Kelly()
  100. call Evaluate_MouseHole()
  101. call Evaluate_MouseHole()
  102. call Evaluate_OperationCondition()
  103. call Evaluate_SafetyValve()
  104. call Evaluate_Slips()
  105. call Evaluate_Swing()
  106. call Evaluate_Tong()
  107. ! call Evaluate_StringUpdate()
  108. call Evaluate_FlowKellyDisconnect()
  109. call Evaluate_FlowPipeDisconnect()
  110. !if(Get_FillMouseHoleLed()) then
  111. ! call Set_MouseHole(MOUSE_HOLE_FILL)
  112. !else
  113. ! if((Get_KellyConnection() == KELLY_CONNECTION_SINGLE .or.&
  114. ! Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) .and.&
  115. ! Get_HookHeight() >= 95.0 ) then
  116. ! call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  117. ! else
  118. ! call Set_MouseHole(MOUSE_HOLE_EMPTY)
  119. ! endif
  120. !endif
  121. !topdrive
  122. call Evaluate_TdsElevatorModes()
  123. call Evaluate_TdsConnectionModes()
  124. call Evaluate_SwingTiltPermission()
  125. call Evaluate_SwingOffPermission()
  126. call Evaluate_SwingDrillPermission()
  127. call Evaluate_FillupHeadPermission()
  128. call Evaluate_TdsTong()
  129. call Evaluate_TdsBackupClamp()
  130. call Evaluate_TdsSwing()
  131. call Evaluate_TdsSpine()
  132. call Evaluate_PowerLed()
  133. call Evaluate_IbopLed()
  134. call Evaluate_TorqueWrenchLed()
  135. end subroutine OperationScenarios_Step
  136. ! subroutine UpdateUnity()
  137. ! implicit none
  138. ! if(associated(UpdateUnityPtr)) call UpdateUnityPtr()
  139. ! end subroutine
  140. subroutine Kelly_ConnectionNothing
  141. use UnitySignalVariables
  142. use UnitySignalsModule
  143. use CHook
  144. use SimulationVariables
  145. implicit none
  146. call Set_HookHeight(75.0)
  147. call sleep(1)
  148. ! first wait for unity to get to starting point
  149. loop1: do
  150. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  151. call sleepqq(100)
  152. enddo loop1
  153. call sleep(1)
  154. !TODO: possibly goto a position to activate swing
  155. ! goto preferred swing position
  156. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  157. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  158. !@call UpdateUnity()
  159. loop2: do
  160. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  161. call sleepqq(100)
  162. enddo loop2
  163. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  164. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  165. !@call UpdateUnity()
  166. loop3: do
  167. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
  168. call sleepqq(100)
  169. enddo loop3
  170. !elseif (Swing_S == SWING_WELL_END) then
  171. ! call Set_Swing(SWING_WELL_BEGIN)
  172. ! !@call UpdateUnity()
  173. ! loop4: do
  174. ! if(Get_Swing() == SWING_WELL_END) exit loop4
  175. ! call sleepqq(100)
  176. ! enddo loop4
  177. endif
  178. call sleep(3)
  179. ! move to final hook height
  180. call Update_HookHeight_From_Snapshot()
  181. call sleep(3)
  182. end subroutine Kelly_ConnectionNothing
  183. subroutine Kelly_ConnectionString
  184. use UnitySignalVariables
  185. use UnitySignalsModule
  186. use CHook
  187. use SimulationVariables
  188. implicit none
  189. call Set_HookHeight(75.0)
  190. call sleep(1)
  191. ! first wait for unity to get to starting point
  192. loop1: do
  193. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  194. call sleepqq(100)
  195. enddo loop1
  196. call sleep(1)
  197. ! goto connection to string position
  198. call Set_HookHeight_S(66.7)
  199. call sleep(1)
  200. ! start tong makeup
  201. call Set_Tong(TONG_MAKEUP_BEGIN)
  202. !@call UpdateUnity()
  203. loop2: do
  204. if(Get_Tong() == TONG_MAKEUP_END) exit loop2
  205. call sleepqq(100)
  206. enddo loop2
  207. call sleepqq(100)
  208. ! release slips
  209. call Set_Slips(SLIPS_UNSET_BEGIN)
  210. !@call UpdateUnity()
  211. loop3: do
  212. if(Get_Slips() == SLIPS_UNSET_END) exit loop3
  213. call sleepqq(100)
  214. enddo loop3
  215. call sleepqq(100)
  216. ! move to final hook height
  217. call Update_HookHeight_From_Snapshot()
  218. call sleep(3)
  219. ! put slips to saved position
  220. if(data%State%unitySignals%Slips_S == SLIPS_SET_END) then
  221. call Set_Slips(SLIPS_SET_BEGIN)
  222. !@call UpdateUnity()
  223. loop4: do
  224. if(Get_Slips() == SLIPS_SET_END) exit loop4
  225. call sleepqq(100)
  226. enddo loop4
  227. call sleep(1)
  228. endif
  229. end subroutine Kelly_ConnectionString
  230. subroutine Kelly_ConnectionSingle
  231. ! use CSwingEnumVariables
  232. ! use CSlipsEnumVariables
  233. ! use CTongEnumVariables
  234. use UnitySignalVariables
  235. use UnitySignalsModule
  236. use CHook
  237. use SimulationVariables
  238. implicit none
  239. call Set_HookHeight(75.0)
  240. call sleep(1)
  241. ! first wait for unity to get to starting point
  242. loop1: do
  243. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  244. call sleepqq(100)
  245. enddo loop1
  246. call sleep(1)
  247. ! goto swing mouse hole position
  248. call Set_HookHeight_S(70.0)
  249. call sleep(1)
  250. ! swing mouse hole
  251. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  252. !@call UpdateUnity()
  253. loop2: do
  254. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  255. call sleepqq(100)
  256. enddo loop2
  257. call sleepqq(100)
  258. ! goto makeup pipe location
  259. call Set_HookHeight_S(65.0)
  260. call sleep(1)
  261. ! start tong makeup
  262. call Set_Tong(TONG_MAKEUP_BEGIN)
  263. !@call UpdateUnity()
  264. loop3: do
  265. if(Get_Tong() == TONG_MAKEUP_END) exit loop3
  266. call sleepqq(100)
  267. enddo loop3
  268. call sleepqq(100)
  269. if (data%State%unitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole
  270. ! goto swing location
  271. call Set_HookHeight_S(98.0)
  272. call sleep(1)
  273. ! goto preferred swing position
  274. call Set_Swing(SWING_WELL_BEGIN)
  275. !@call UpdateUnity()
  276. loop4: do
  277. if(Get_Swing() == SWING_WELL_END) exit loop4
  278. call sleepqq(100)
  279. enddo loop4
  280. call sleep(2)
  281. endif
  282. ! move to final hook height
  283. call Update_HookHeight_From_Snapshot()
  284. call sleep(3)
  285. end subroutine Kelly_ConnectionSingle
  286. subroutine Elevator_ConnectionNothing
  287. use UnitySignalVariables
  288. use UnitySignalsModule
  289. use CHook
  290. use SimulationVariables
  291. implicit none
  292. call Set_HookHeight(75.0)
  293. call sleep(1)
  294. ! first wait for unity to get to starting point
  295. loop1: do
  296. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  297. call sleepqq(100)
  298. enddo loop1
  299. call sleep(1)
  300. call Set_Kelly(KELLY_REMOVE)
  301. call sleepqq(100)
  302. ! goto preferred swing position
  303. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  304. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  305. !@call UpdateUnity()
  306. loop4: do
  307. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4
  308. call sleepqq(100)
  309. enddo loop4
  310. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  311. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  312. !@call UpdateUnity()
  313. loop5: do
  314. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5
  315. call sleepqq(100)
  316. enddo loop5
  317. elseif (data%State%unitySignals%Swing_S == SWING_WELL_END) then
  318. call Set_Swing(SWING_WELL_BEGIN)
  319. !@call UpdateUnity()
  320. loop6: do
  321. if(Get_Swing() == SWING_WELL_END) exit loop6
  322. call sleepqq(100)
  323. enddo loop6
  324. endif
  325. call sleepqq(100)
  326. ! move to final hook height
  327. call Update_HookHeight_From_Snapshot()
  328. call sleep(3)
  329. end subroutine Elevator_ConnectionNothing
  330. subroutine Elevator_ConnectionString
  331. implicit none
  332. end subroutine Elevator_ConnectionString
  333. subroutine Elevator_ConnectionStand
  334. implicit none
  335. end subroutine Elevator_ConnectionStand
  336. subroutine Elevator_ConnectionSingle
  337. implicit none
  338. end subroutine Elevator_ConnectionSingle
  339. end module COperationScenariosMain