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.i90 13 KiB

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