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.
 
 
 
 
 
 

464 lines
13 KiB

  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 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 CSwingEnumVariables
  142. ! use CSlipsEnumVariables
  143. use UnitySignalVariables
  144. use UnitySignalsModule
  145. use CHook
  146. use SimulationVariables
  147. implicit none
  148. call Set_HookHeight(75.0)
  149. call sleep(1)
  150. ! first wait for unity to get to starting point
  151. loop1: do
  152. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  153. call sleepqq(100)
  154. enddo loop1
  155. call sleep(1)
  156. !TODO: possibly goto a position to activate swing
  157. ! goto preferred swing position
  158. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  159. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  160. !@call UpdateUnity()
  161. loop2: do
  162. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  163. call sleepqq(100)
  164. enddo loop2
  165. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  166. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  167. !@call UpdateUnity()
  168. loop3: do
  169. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
  170. call sleepqq(100)
  171. enddo loop3
  172. !elseif (Swing_S == SWING_WELL_END) then
  173. ! call Set_Swing(SWING_WELL_BEGIN)
  174. ! !@call UpdateUnity()
  175. ! loop4: do
  176. ! if(Get_Swing() == SWING_WELL_END) exit loop4
  177. ! call sleepqq(100)
  178. ! enddo loop4
  179. endif
  180. call sleep(3)
  181. ! move to final hook height
  182. call Update_HookHeight_From_Snapshot()
  183. call sleep(3)
  184. end subroutine Kelly_ConnectionNothing
  185. subroutine Kelly_ConnectionString
  186. ! use CSwingEnumVariables
  187. ! use CSlipsEnumVariables
  188. use UnitySignalVariables
  189. use UnitySignalsModule
  190. use CHook
  191. use SimulationVariables
  192. ! use CTongEnumVariables
  193. implicit none
  194. call Set_HookHeight(75.0)
  195. call sleep(1)
  196. ! first wait for unity to get to starting point
  197. loop1: do
  198. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  199. call sleepqq(100)
  200. enddo loop1
  201. call sleep(1)
  202. ! goto connection to string position
  203. call Set_HookHeight_S(66.7)
  204. call sleep(1)
  205. ! start tong makeup
  206. call Set_Tong(TONG_MAKEUP_BEGIN)
  207. !@call UpdateUnity()
  208. loop2: do
  209. if(Get_Tong() == TONG_MAKEUP_END) exit loop2
  210. call sleepqq(100)
  211. enddo loop2
  212. call sleepqq(100)
  213. ! release slips
  214. call Set_Slips(SLIPS_UNSET_BEGIN)
  215. !@call UpdateUnity()
  216. loop3: do
  217. if(Get_Slips() == SLIPS_UNSET_END) exit loop3
  218. call sleepqq(100)
  219. enddo loop3
  220. call sleepqq(100)
  221. ! move to final hook height
  222. call Update_HookHeight_From_Snapshot()
  223. call sleep(3)
  224. ! put slips to saved position
  225. if(data%State%unitySignals%Slips_S == SLIPS_SET_END) then
  226. call Set_Slips(SLIPS_SET_BEGIN)
  227. !@call UpdateUnity()
  228. loop4: do
  229. if(Get_Slips() == SLIPS_SET_END) exit loop4
  230. call sleepqq(100)
  231. enddo loop4
  232. call sleep(1)
  233. endif
  234. end subroutine Kelly_ConnectionString
  235. subroutine Kelly_ConnectionSingle
  236. ! use CSwingEnumVariables
  237. ! use CSlipsEnumVariables
  238. ! use CTongEnumVariables
  239. use UnitySignalVariables
  240. use UnitySignalsModule
  241. use CHook
  242. use SimulationVariables
  243. implicit none
  244. call Set_HookHeight(75.0)
  245. call sleep(1)
  246. ! first wait for unity to get to starting point
  247. loop1: do
  248. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  249. call sleepqq(100)
  250. enddo loop1
  251. call sleep(1)
  252. ! goto swing mouse hole position
  253. call Set_HookHeight_S(70.0)
  254. call sleep(1)
  255. ! swing mouse hole
  256. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  257. !@call UpdateUnity()
  258. loop2: do
  259. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  260. call sleepqq(100)
  261. enddo loop2
  262. call sleepqq(100)
  263. ! goto makeup pipe location
  264. call Set_HookHeight_S(65.0)
  265. call sleep(1)
  266. ! start tong makeup
  267. call Set_Tong(TONG_MAKEUP_BEGIN)
  268. !@call UpdateUnity()
  269. loop3: do
  270. if(Get_Tong() == TONG_MAKEUP_END) exit loop3
  271. call sleepqq(100)
  272. enddo loop3
  273. call sleepqq(100)
  274. if (data%State%unitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole
  275. ! goto swing location
  276. call Set_HookHeight_S(98.0)
  277. call sleep(1)
  278. ! goto preferred swing position
  279. call Set_Swing(SWING_WELL_BEGIN)
  280. !@call UpdateUnity()
  281. loop4: do
  282. if(Get_Swing() == SWING_WELL_END) exit loop4
  283. call sleepqq(100)
  284. enddo loop4
  285. call sleep(2)
  286. endif
  287. ! move to final hook height
  288. call Update_HookHeight_From_Snapshot()
  289. call sleep(3)
  290. end subroutine Kelly_ConnectionSingle
  291. subroutine Elevator_ConnectionNothing
  292. ! use CSwingEnumVariables
  293. ! use CSlipsEnumVariables
  294. use UnitySignalVariables
  295. use UnitySignalsModule
  296. use CHook
  297. use SimulationVariables
  298. ! use CKellyEnumVariables
  299. implicit none
  300. call Set_HookHeight(75.0)
  301. call sleep(1)
  302. ! first wait for unity to get to starting point
  303. loop1: do
  304. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  305. call sleepqq(100)
  306. enddo loop1
  307. call sleep(1)
  308. !TODO: possibly goto a position to activate swing
  309. !! first goto mouse hole
  310. !call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  311. !!@call UpdateUnity()
  312. !loop2: do
  313. ! if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  314. ! call sleepqq(100)
  315. !enddo loop2
  316. !call sleep(1)
  317. !
  318. !! then goto rat hole
  319. !call Set_Swing(SWING_RAT_HOLE_BEGIN)
  320. !!@call UpdateUnity()
  321. !loop3: do
  322. ! if(Get_Swing() == SWING_RAT_HOLE_END) exit loop3
  323. ! call sleepqq(100)
  324. !enddo loop3
  325. !call sleep(1)
  326. ! kelly back
  327. call Set_Kelly(KELLY_REMOVE)
  328. call sleepqq(100)
  329. ! goto preferred swing position
  330. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  331. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  332. !@call UpdateUnity()
  333. loop4: do
  334. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4
  335. call sleepqq(100)
  336. enddo loop4
  337. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  338. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  339. !@call UpdateUnity()
  340. loop5: do
  341. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5
  342. call sleepqq(100)
  343. enddo loop5
  344. elseif (data%State%unitySignals%Swing_S == SWING_WELL_END) then
  345. call Set_Swing(SWING_WELL_BEGIN)
  346. !@call UpdateUnity()
  347. loop6: do
  348. if(Get_Swing() == SWING_WELL_END) exit loop6
  349. call sleepqq(100)
  350. enddo loop6
  351. endif
  352. call sleepqq(100)
  353. ! move to final hook height
  354. call Update_HookHeight_From_Snapshot()
  355. call sleep(3)
  356. end subroutine Elevator_ConnectionNothing
  357. subroutine Elevator_ConnectionString
  358. implicit none
  359. end subroutine Elevator_ConnectionString
  360. subroutine Elevator_ConnectionStand
  361. implicit none
  362. end subroutine Elevator_ConnectionStand
  363. subroutine Elevator_ConnectionSingle
  364. implicit none
  365. end subroutine Elevator_ConnectionSingle
  366. end module COperationScenariosMain