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.

COperationScenariosMain.f90 14 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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 CElevatorEnum
  47. ! use CHeadEnum
  48. use CIbopEnum
  49. use CKellyEnum
  50. use CMouseHoleEnum
  51. use UnitySignalsModule
  52. use CSafetyValveEnum
  53. use CSlipsEnum
  54. use CSwingEnum
  55. use CTongEnum
  56. ! use CStringUpdate
  57. use CFlowPipeDisconnectEnum
  58. use CFlowKellyDisconnectEnum
  59. use CFillupHeadPermission
  60. use CSwingDrillPermission
  61. use CSwingOffPermission
  62. use CSwingTiltPermission
  63. ! use CTdsStemJointHeight
  64. ! use UnitySignalsModule !for CTdsConnectionModesEnum
  65. use CTdsElevatorModesEnum
  66. use CTdsSpineEnum
  67. use CTdsSwingEnum
  68. use CTdsTongEnum
  69. use CTdsBackupClamp
  70. use CTdsIbopLedNotification
  71. use CTdsPowerLedNotification
  72. use CTdsTorqueWrenchLedNotification
  73. implicit none
  74. call Evaluate_KellyConnection()
  75. call Evaluate_ElevatorConnection()
  76. call Evaluate_CloseKellyCockLed()
  77. call Evaluate_CloseSafetyValveLed()
  78. call Evaluate_FillMouseHoleLed()
  79. call Evaluate_IrIBopLed()
  80. call Evaluate_IrSafetyValveLed()
  81. call Evaluate_LatchLed()
  82. call Evaluate_OpenKellyCockLed()
  83. call Evaluate_OpenSafetyValveLed()
  84. call Evaluate_SlipsNotification()
  85. call Evaluate_SwingLed()
  86. call Evaluate_TongNotification()
  87. call Evaluate_UnlatchLed()
  88. call Evaluate_InstallFillupHeadPermission()
  89. call Evaluate_InstallMudBucketPermission()
  90. call Evaluate_IrIbopPermission()
  91. call Evaluate_IrSafetyValvePermission()
  92. call Evaluate_RemoveFillupHeadPermission()
  93. call Evaluate_RemoveMudBucketPermission()
  94. call Evaluate_MudBucket()
  95. call Evaluate_Elevator()
  96. call Evaluate_FillupHead()
  97. call Evaluate_Ibop()
  98. call Evaluate_Kelly()
  99. call Evaluate_MouseHole()
  100. call Evaluate_MouseHole()
  101. call Evaluate_OperationCondition()
  102. call Evaluate_SafetyValve()
  103. call Evaluate_Slips()
  104. call Evaluate_Swing()
  105. call Evaluate_Tong()
  106. ! call Evaluate_StringUpdate()
  107. call Evaluate_FlowKellyDisconnect()
  108. call Evaluate_FlowPipeDisconnect()
  109. !if(Get_FillMouseHoleLed()) then
  110. ! call Set_MouseHole(MOUSE_HOLE_FILL)
  111. !else
  112. ! if((Get_KellyConnection() == KELLY_CONNECTION_SINGLE .or.&
  113. ! Get_ElevatorConnection() == ELEVATOR_CONNECTION_SINGLE) .and.&
  114. ! Get_HookHeight() >= 95.0 ) then
  115. ! call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  116. ! else
  117. ! call Set_MouseHole(MOUSE_HOLE_EMPTY)
  118. ! endif
  119. !endif
  120. !topdrive
  121. call Evaluate_TdsElevatorModes()
  122. call Evaluate_TdsConnectionModes()
  123. call Evaluate_SwingTiltPermission()
  124. call Evaluate_SwingOffPermission()
  125. call Evaluate_SwingDrillPermission()
  126. call Evaluate_FillupHeadPermission()
  127. call Evaluate_TdsTong()
  128. call Evaluate_TdsBackupClamp()
  129. call Evaluate_TdsSwing()
  130. call Evaluate_TdsSpine()
  131. call Evaluate_PowerLed()
  132. call Evaluate_IbopLed()
  133. call Evaluate_TorqueWrenchLed()
  134. end subroutine OperationScenarios_Step
  135. ! subroutine UpdateUnity()
  136. ! implicit none
  137. ! if(associated(UpdateUnityPtr)) call UpdateUnityPtr()
  138. ! end subroutine
  139. subroutine Kelly_ConnectionNothing
  140. ! use CSwingEnumVariables
  141. ! use CSlipsEnumVariables
  142. use UnitySignalVariables
  143. use UnitySignalsModule
  144. use CHook
  145. use SimulationVariables
  146. implicit none
  147. call Set_HookHeight(75.0)
  148. call sleep(1)
  149. ! first wait for unity to get to starting point
  150. loop1: do
  151. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  152. call sleepqq(100)
  153. enddo loop1
  154. call sleep(1)
  155. !TODO: possibly goto a position to activate swing
  156. ! goto preferred swing position
  157. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  158. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  159. !@call UpdateUnity()
  160. loop2: do
  161. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  162. call sleepqq(100)
  163. enddo loop2
  164. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  165. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  166. !@call UpdateUnity()
  167. loop3: do
  168. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
  169. call sleepqq(100)
  170. enddo loop3
  171. !elseif (Swing_S == SWING_WELL_END) then
  172. ! call Set_Swing(SWING_WELL_BEGIN)
  173. ! !@call UpdateUnity()
  174. ! loop4: do
  175. ! if(Get_Swing() == SWING_WELL_END) exit loop4
  176. ! call sleepqq(100)
  177. ! enddo loop4
  178. endif
  179. call sleep(3)
  180. ! move to final hook height
  181. call Update_HookHeight_From_Snapshot()
  182. call sleep(3)
  183. end subroutine Kelly_ConnectionNothing
  184. subroutine Kelly_ConnectionString
  185. ! use CSwingEnumVariables
  186. ! use CSlipsEnumVariables
  187. use UnitySignalVariables
  188. use UnitySignalsModule
  189. use CHook
  190. use SimulationVariables
  191. ! use CTongEnumVariables
  192. implicit none
  193. call Set_HookHeight(75.0)
  194. call sleep(1)
  195. ! first wait for unity to get to starting point
  196. loop1: do
  197. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  198. call sleepqq(100)
  199. enddo loop1
  200. call sleep(1)
  201. ! goto connection to string position
  202. call Set_HookHeight_S(66.7)
  203. call sleep(1)
  204. ! start tong makeup
  205. call Set_Tong(TONG_MAKEUP_BEGIN)
  206. !@call UpdateUnity()
  207. loop2: do
  208. if(Get_Tong() == TONG_MAKEUP_END) exit loop2
  209. call sleepqq(100)
  210. enddo loop2
  211. call sleepqq(100)
  212. ! release slips
  213. call Set_Slips(SLIPS_UNSET_BEGIN)
  214. !@call UpdateUnity()
  215. loop3: do
  216. if(Get_Slips() == SLIPS_UNSET_END) exit loop3
  217. call sleepqq(100)
  218. enddo loop3
  219. call sleepqq(100)
  220. ! move to final hook height
  221. call Update_HookHeight_From_Snapshot()
  222. call sleep(3)
  223. ! put slips to saved position
  224. if(data%State%unitySignals%Slips_S == SLIPS_SET_END) then
  225. call Set_Slips(SLIPS_SET_BEGIN)
  226. !@call UpdateUnity()
  227. loop4: do
  228. if(Get_Slips() == SLIPS_SET_END) exit loop4
  229. call sleepqq(100)
  230. enddo loop4
  231. call sleep(1)
  232. endif
  233. end subroutine Kelly_ConnectionString
  234. subroutine Kelly_ConnectionSingle
  235. ! use CSwingEnumVariables
  236. ! use CSlipsEnumVariables
  237. ! use CTongEnumVariables
  238. use UnitySignalVariables
  239. use UnitySignalsModule
  240. use CHook
  241. use SimulationVariables
  242. implicit none
  243. call Set_HookHeight(75.0)
  244. call sleep(1)
  245. ! first wait for unity to get to starting point
  246. loop1: do
  247. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  248. call sleepqq(100)
  249. enddo loop1
  250. call sleep(1)
  251. ! goto swing mouse hole position
  252. call Set_HookHeight_S(70.0)
  253. call sleep(1)
  254. ! swing mouse hole
  255. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  256. !@call UpdateUnity()
  257. loop2: do
  258. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  259. call sleepqq(100)
  260. enddo loop2
  261. call sleepqq(100)
  262. ! goto makeup pipe location
  263. call Set_HookHeight_S(65.0)
  264. call sleep(1)
  265. ! start tong makeup
  266. call Set_Tong(TONG_MAKEUP_BEGIN)
  267. !@call UpdateUnity()
  268. loop3: do
  269. if(Get_Tong() == TONG_MAKEUP_END) exit loop3
  270. call sleepqq(100)
  271. enddo loop3
  272. call sleepqq(100)
  273. if (data%State%unitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole
  274. ! goto swing location
  275. call Set_HookHeight_S(98.0)
  276. call sleep(1)
  277. ! goto preferred swing position
  278. call Set_Swing(SWING_WELL_BEGIN)
  279. !@call UpdateUnity()
  280. loop4: do
  281. if(Get_Swing() == SWING_WELL_END) exit loop4
  282. call sleepqq(100)
  283. enddo loop4
  284. call sleep(2)
  285. endif
  286. ! move to final hook height
  287. call Update_HookHeight_From_Snapshot()
  288. call sleep(3)
  289. end subroutine Kelly_ConnectionSingle
  290. subroutine Elevator_ConnectionNothing
  291. ! use CSwingEnumVariables
  292. ! use CSlipsEnumVariables
  293. use UnitySignalVariables
  294. use UnitySignalsModule
  295. use CHook
  296. use SimulationVariables
  297. ! use CKellyEnumVariables
  298. implicit none
  299. call Set_HookHeight(75.0)
  300. call sleep(1)
  301. ! first wait for unity to get to starting point
  302. loop1: do
  303. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  304. call sleepqq(100)
  305. enddo loop1
  306. call sleep(1)
  307. !TODO: possibly goto a position to activate swing
  308. !! first goto mouse hole
  309. !call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  310. !!@call UpdateUnity()
  311. !loop2: do
  312. ! if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  313. ! call sleepqq(100)
  314. !enddo loop2
  315. !call sleep(1)
  316. !
  317. !! then goto rat hole
  318. !call Set_Swing(SWING_RAT_HOLE_BEGIN)
  319. !!@call UpdateUnity()
  320. !loop3: do
  321. ! if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
  322. ! call sleepqq(100)
  323. !enddo loop3
  324. !call sleep(1)
  325. ! kelly back
  326. call Set_Kelly(KELLY_REMOVE)
  327. call sleepqq(100)
  328. ! goto preferred swing position
  329. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  330. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  331. !@call UpdateUnity()
  332. loop4: do
  333. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4
  334. call sleepqq(100)
  335. enddo loop4
  336. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  337. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  338. !@call UpdateUnity()
  339. loop5: do
  340. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5
  341. call sleepqq(100)
  342. enddo loop5
  343. elseif (data%State%unitySignals%Swing_S == SWING_WELL_END) then
  344. call Set_Swing(SWING_WELL_BEGIN)
  345. !@call UpdateUnity()
  346. loop6: do
  347. if(Get_Swing() == SWING_WELL_END) exit loop6
  348. call sleepqq(100)
  349. enddo loop6
  350. endif
  351. call sleepqq(100)
  352. ! move to final hook height
  353. call Update_HookHeight_From_Snapshot()
  354. call sleep(3)
  355. end subroutine Elevator_ConnectionNothing
  356. subroutine Elevator_ConnectionString
  357. implicit none
  358. end subroutine Elevator_ConnectionString
  359. subroutine Elevator_ConnectionStand
  360. implicit none
  361. end subroutine Elevator_ConnectionStand
  362. subroutine Elevator_ConnectionSingle
  363. implicit none
  364. end subroutine Elevator_ConnectionSingle
  365. end module COperationScenariosMain