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.
 
 
 
 
 
 

401 lines
12 KiB

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