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.
 
 
 
 
 
 

427 lines
12 KiB

  1. # 1 "/home/admin/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 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 UnitySignalVariables
  186. use UnitySignalsModule
  187. use CHook
  188. use SimulationVariables
  189. implicit none
  190. call Set_HookHeight(75.0)
  191. call sleep(1)
  192. ! first wait for unity to get to starting point
  193. loop1: do
  194. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  195. call sleepqq(100)
  196. enddo loop1
  197. call sleep(1)
  198. ! goto connection to string position
  199. call Set_HookHeight_S(66.7)
  200. call sleep(1)
  201. ! start tong makeup
  202. call Set_Tong(TONG_MAKEUP_BEGIN)
  203. !@call UpdateUnity()
  204. loop2: do
  205. if(Get_Tong() == TONG_MAKEUP_END) exit loop2
  206. call sleepqq(100)
  207. enddo loop2
  208. call sleepqq(100)
  209. ! release slips
  210. call Set_Slips(SLIPS_UNSET_BEGIN)
  211. !@call UpdateUnity()
  212. loop3: do
  213. if(Get_Slips() == SLIPS_UNSET_END) exit loop3
  214. call sleepqq(100)
  215. enddo loop3
  216. call sleepqq(100)
  217. ! move to final hook height
  218. call Update_HookHeight_From_Snapshot()
  219. call sleep(3)
  220. ! put slips to saved position
  221. if(data%State%unitySignals%Slips_S == SLIPS_SET_END) then
  222. call Set_Slips(SLIPS_SET_BEGIN)
  223. !@call UpdateUnity()
  224. loop4: do
  225. if(Get_Slips() == SLIPS_SET_END) exit loop4
  226. call sleepqq(100)
  227. enddo loop4
  228. call sleep(1)
  229. endif
  230. end subroutine Kelly_ConnectionString
  231. subroutine Kelly_ConnectionSingle
  232. ! use CSwingEnumVariables
  233. ! use CSlipsEnumVariables
  234. ! use CTongEnumVariables
  235. use UnitySignalVariables
  236. use UnitySignalsModule
  237. use CHook
  238. use SimulationVariables
  239. implicit none
  240. call Set_HookHeight(75.0)
  241. call sleep(1)
  242. ! first wait for unity to get to starting point
  243. loop1: do
  244. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  245. call sleepqq(100)
  246. enddo loop1
  247. call sleep(1)
  248. ! goto swing mouse hole position
  249. call Set_HookHeight_S(70.0)
  250. call sleep(1)
  251. ! swing mouse hole
  252. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  253. !@call UpdateUnity()
  254. loop2: do
  255. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop2
  256. call sleepqq(100)
  257. enddo loop2
  258. call sleepqq(100)
  259. ! goto makeup pipe location
  260. call Set_HookHeight_S(65.0)
  261. call sleep(1)
  262. ! start tong makeup
  263. call Set_Tong(TONG_MAKEUP_BEGIN)
  264. !@call UpdateUnity()
  265. loop3: do
  266. if(Get_Tong() == TONG_MAKEUP_END) exit loop3
  267. call sleepqq(100)
  268. enddo loop3
  269. call sleepqq(100)
  270. if (data%State%unitySignals%Swing_S == SWING_WELL_END) then ! already in mouse hole
  271. ! goto swing location
  272. call Set_HookHeight_S(98.0)
  273. call sleep(1)
  274. ! goto preferred swing position
  275. call Set_Swing(SWING_WELL_BEGIN)
  276. !@call UpdateUnity()
  277. loop4: do
  278. if(Get_Swing() == SWING_WELL_END) exit loop4
  279. call sleepqq(100)
  280. enddo loop4
  281. call sleep(2)
  282. endif
  283. ! move to final hook height
  284. call Update_HookHeight_From_Snapshot()
  285. call sleep(3)
  286. end subroutine Kelly_ConnectionSingle
  287. subroutine Elevator_ConnectionNothing
  288. use UnitySignalVariables
  289. use UnitySignalsModule
  290. use CHook
  291. use SimulationVariables
  292. implicit none
  293. call Set_HookHeight(75.0)
  294. call sleep(1)
  295. ! first wait for unity to get to starting point
  296. loop1: do
  297. if(Get_Swing() == SWING_WELL_END .and. Get_Slips() == SLIPS_SET_END) exit loop1
  298. call sleepqq(100)
  299. enddo loop1
  300. call sleep(1)
  301. call Set_Kelly(KELLY_REMOVE)
  302. call sleepqq(100)
  303. ! goto preferred swing position
  304. if(data%State%unitySignals%Swing_S == SWING_MOUSE_HOLE_END) then
  305. call Set_Swing(SWING_MOUSE_HOLE_BEGIN)
  306. !@call UpdateUnity()
  307. loop4: do
  308. if(Get_Swing() == SWING_MOUSE_HOLE_END) exit loop4
  309. call sleepqq(100)
  310. enddo loop4
  311. elseif (data%State%unitySignals%Swing_S == SWING_RAT_HOLE_END) then
  312. call Set_Swing(SWING_RAT_HOLE_BEGIN)
  313. !@call UpdateUnity()
  314. loop5: do
  315. if(Get_Swing() == SWING_RAT_HOLE_END) exit loop5
  316. call sleepqq(100)
  317. enddo loop5
  318. elseif (data%State%unitySignals%Swing_S == SWING_WELL_END) then
  319. call Set_Swing(SWING_WELL_BEGIN)
  320. !@call UpdateUnity()
  321. loop6: do
  322. if(Get_Swing() == SWING_WELL_END) exit loop6
  323. call sleepqq(100)
  324. enddo loop6
  325. endif
  326. call sleepqq(100)
  327. ! move to final hook height
  328. call Update_HookHeight_From_Snapshot()
  329. call sleep(3)
  330. end subroutine Elevator_ConnectionNothing
  331. subroutine Elevator_ConnectionString
  332. implicit none
  333. end subroutine Elevator_ConnectionString
  334. subroutine Elevator_ConnectionStand
  335. implicit none
  336. end subroutine Elevator_ConnectionStand
  337. subroutine Elevator_ConnectionSingle
  338. implicit none
  339. end subroutine Elevator_ConnectionSingle
  340. end module COperationScenariosMain