Simulation Core
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

COperationScenariosMain.f90 12 KiB

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