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.
 
 
 
 
 
 

403 lines
12 KiB

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