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.
 
 
 
 
 
 

312 lines
12 KiB

  1. module OperationScenariosModule
  2. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  3. !! Paseted From ....Variables.f90
  4. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5. use SimulationVariables
  6. use PermissionsModule
  7. use UnityModule
  8. use UnitySignalVariables
  9. use UnitySignalsModule
  10. use PermissionsModule
  11. use CHoistingVariables
  12. use CTopDrivePanelVariables
  13. use NotificationModule
  14. use SoftwareInputsModule
  15. contains
  16. subroutine OperationScenariosToJson(parent)
  17. type(json_value),pointer :: parent
  18. type(json_core) :: json
  19. type(json_value),pointer :: p
  20. ! 1. create new node
  21. call json%create_object(p,'OperationScenarios')
  22. ! 2. add member of data type to new node
  23. call json%add(p,"ElevatorConnection",data%State%OperationScenario%ElevatorConnection)
  24. call json%add(p,"StringUpdate",data%State%OperationScenario%StringUpdate)
  25. call json%add(p,"KellyConnection",data%State%OperationScenario%KellyConnection)
  26. ! 3. add new node to parent
  27. call json%add(parent,p)
  28. end subroutine
  29. ! moved from kellyConnectionEnum
  30. subroutine Set_KellyConnection(v)
  31. use CManifolds, Only: KellyConnected, KellyDisconnected
  32. implicit none
  33. integer , intent(in) :: v
  34. #ifdef ExcludeExtraChanges
  35. if(data%State%OperationScenario%KellyConnection == v) return
  36. #endif
  37. data%State%OperationScenario%KellyConnection = v
  38. if(data%State%OperationScenario%KellyConnection /= KELLY_CONNECTION_STRING) then
  39. call KellyDisconnected()
  40. else
  41. call KellyConnected()
  42. endif
  43. #ifdef deb
  44. if(print_log) print*, 'data%State%OperationScenario%KellyConnection=', data%State%OperationScenario%KellyConnection
  45. #endif
  46. !**call data%State%OperationScenario%OnKellyConnectionChange%RunAll()
  47. end subroutine
  48. integer function Get_KellyConnection()
  49. implicit none
  50. Get_KellyConnection = data%State%OperationScenario%KellyConnection
  51. end function
  52. subroutine Evaluate_KellyConnection()
  53. implicit none
  54. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  55. #ifdef OST
  56. if(print_log) print*, 'Evaluate_KellyConnection=TopDrive'
  57. #endif
  58. endif
  59. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  60. #ifdef OST
  61. if(print_log) print*, 'Evaluate_KellyConnection=Kelly'
  62. #endif
  63. !OPERATION-CODE=1
  64. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  65. !Get_JointConnectionPossible() .and.&
  66. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  67. Get_Swing() == SWING_WELL_END .and.&
  68. !Get_TongNotification() .and.&
  69. Get_Tong() == TONG_MAKEUP_END) then
  70. !call Log_4('KELLY_CONNECTION_STRING')
  71. call Set_Tong(TONG_NEUTRAL)
  72. call Set_KellyConnection(KELLY_CONNECTION_STRING)
  73. return
  74. end if
  75. !OPERATION-CODE=2
  76. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  77. Get_StringPressure() == 0 .and.&
  78. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and.&
  79. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  80. Get_Swing() == SWING_WELL_END .and.&
  81. !Get_TongNotification() .and.&
  82. Get_Tong() == TONG_BREAKOUT_END) then
  83. call Set_Tong(TONG_NEUTRAL)
  84. call Set_KellyConnection(KELLY_CONNECTION_NOTHING)
  85. call Set_SwingLed(.true.)
  86. return
  87. end if
  88. !OPERATION-CODE=3
  89. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  90. !Get_JointConnectionPossible() .and.&
  91. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  92. Get_Swing() == SWING_MOUSE_HOLE_END .and.&
  93. !Get_TongNotification() .and.&
  94. Get_FillMouseHoleLed() .and.&
  95. Get_Tong() == TONG_MAKEUP_END) then
  96. call Set_Tong(TONG_NEUTRAL)
  97. call Set_KellyConnection(KELLY_CONNECTION_SINGLE)
  98. call Set_SwingLed(.false.)
  99. call Set_FillMouseHoleLed(.false.)
  100. call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  101. return
  102. end if
  103. !OPERATION-CODE=4
  104. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  105. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  106. Get_Swing() == SWING_MOUSE_HOLE_END .and.&
  107. !Get_TongNotification() .and.&
  108. Get_FillMouseHoleLed() == .false. .and.&
  109. Get_Tong() == TONG_BREAKOUT_END) then
  110. call Set_Tong(TONG_NEUTRAL)
  111. call Set_KellyConnection(KELLY_CONNECTION_NOTHING)
  112. call Set_FillMouseHoleLed(.true.)
  113. call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  114. return
  115. end if
  116. !OPERATION-CODE=5
  117. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  118. !Get_JointConnectionPossible() .and.&
  119. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  120. Get_Swing() == SWING_WELL_END .and.&
  121. !Get_TongNotification() .and.&
  122. Get_Tong() == TONG_MAKEUP_END) then
  123. call Set_Tong(TONG_NEUTRAL)
  124. call Set_KellyConnection(KELLY_CONNECTION_STRING)
  125. call Set_StringUpdate(STRING_UPDATE_ADD_SINGLE)
  126. call Set_SwingLed(.false.)
  127. return
  128. end if
  129. !OPERATION-CODE=6
  130. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  131. Get_StringPressure() == 0 .and.&
  132. Get_HookHeight() > 70.0 .and.&
  133. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  134. !Get_TongNotification() .and.&
  135. Get_Swing() == SWING_WELL_END .and.&
  136. Get_Tong() == TONG_BREAKOUT_END) then
  137. call Set_Tong(TONG_NEUTRAL)
  138. call Set_KellyConnection(KELLY_CONNECTION_SINGLE)
  139. call Set_StringUpdate(STRING_UPDATE_REMOVE_SINGLE)
  140. return
  141. end if
  142. endif
  143. end subroutine
  144. ! subroutine Subscribe_KellyConnection()
  145. ! use CDrillingConsoleVariables
  146. ! use ConfigurationVariables
  147. ! use ConfigurationVariables
  148. ! implicit none
  149. ! call OnBreakoutLeverPress%Add(ButtonPress_Breakout)
  150. ! call OnMakeupLeverPress%Add(ButtonPress_Makeup)
  151. ! end subroutine
  152. subroutine ButtonPress_Breakout()
  153. implicit none
  154. #ifdef deb
  155. if(print_log) print*, 'ButtonPress_Breakout on ======> CKellyConnectionEnum'
  156. #endif
  157. end subroutine
  158. subroutine ButtonPress_Makeup()
  159. implicit none
  160. #ifdef deb
  161. if(print_log) print*, 'ButtonPress_Makeup on ======> CKellyConnectionEnum'
  162. #endif
  163. end subroutine
  164. subroutine Set_StringUpdate(v)
  165. implicit none
  166. integer , intent(in) :: v
  167. #ifdef ExcludeExtraChanges
  168. if(data%State%OperationScenario%StringUpdate == v) return
  169. #endif
  170. data%State%OperationScenario%StringUpdate = v
  171. !**call data%State%OperationScenario%OnStringUpdateChange%RunAll(v)
  172. end subroutine
  173. integer function Get_StringUpdate()
  174. implicit none
  175. Get_StringUpdate = data%State%OperationScenario%StringUpdate
  176. end function
  177. real(8) function TJH()
  178. use TD_DrillStemComponents
  179. implicit none
  180. TJH = data%State%TD_String%TopJointHeight
  181. end function
  182. real function TL()
  183. implicit none
  184. TL = 26.97
  185. end function
  186. real function NFC()
  187. implicit none
  188. NFC = Get_NearFloorConnection()
  189. end function
  190. subroutine Set_ElevatorConnection(v)
  191. implicit none
  192. integer , intent(in) :: v
  193. #ifdef ExcludeExtraChanges
  194. if(data%State%OperationScenario%ElevatorConnection == v) return
  195. #endif
  196. data%State%OperationScenario%ElevatorConnection = v
  197. #ifdef deb
  198. if(print_log) print*, 'data%State%OperationScenario%ElevatorConnection=', data%State%OperationScenario%ElevatorConnection
  199. #endif
  200. !**call data%State%OperationScenario%OnElevatorConnectionChange%RunAll()
  201. end subroutine
  202. integer function Get_ElevatorConnection()
  203. implicit none
  204. Get_ElevatorConnection = data%State%OperationScenario%ElevatorConnection
  205. end function
  206. !//SLIPS: everythings start here
  207. subroutine ButtonPress_Slips() bind(C,name="ButtonPress_Slips")
  208. ! use NotificationModule
  209. use CUnityOutputs
  210. ! use UnitySignalsModule
  211. implicit none
  212. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  213. if(print_log) print*, 'ButtonPress_Slips=TopDrive'
  214. !TOPDRIVE-CODE=30
  215. if (Get_Slips() == SLIPS_UNSET_END .and.&
  216. Get_SlipsNotification()) then
  217. call Set_Slips(SLIPS_SET_BEGIN)
  218. return
  219. end if
  220. !TOPDRIVE-CODE=31
  221. if (Get_TdsConnectionModes() == TDS_CONNECTION_STRING .and.&
  222. Get_Slips() == SLIPS_SET_END .and.&
  223. Get_SlipsNotification()) then
  224. call Set_Slips(SLIPS_UNSET_BEGIN)
  225. return
  226. end if
  227. !TOPDRIVE-CODE=32
  228. if (Get_TdsElevatorModes() == TDS_ELEVATOR_CONNECTION_STRING .and.&
  229. Get_Slips() == SLIPS_SET_END .and.&
  230. Get_SlipsNotification()) then
  231. call Set_Slips(SLIPS_UNSET_BEGIN)
  232. return
  233. end if
  234. endif
  235. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  236. if(print_log) print*, 'ButtonPress_Slips=Kelly'
  237. !OPERATION-CODE=19
  238. if (Get_Slips() == SLIPS_UNSET_END .and.&
  239. Get_SlipsNotification()) then
  240. call Set_Slips(SLIPS_SET_BEGIN)
  241. return
  242. end if
  243. !OPERATION-CODE=20
  244. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  245. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  246. GetRotaryRpm() == 0.0d0 .and.&
  247. Get_SlipsNotification() .and.&
  248. Get_Slips() == SLIPS_SET_END) then
  249. call Set_Slips(SLIPS_UNSET_BEGIN)
  250. return
  251. end if
  252. !OPERATION-CODE=21
  253. if (Get_OperationCondition() == OPERATION_TRIP .and.&
  254. Get_ElevatorConnection() == ELEVATOR_CONNECTION_STRING .and.&
  255. GetRotaryRpm() == 0.0d0 .and.&
  256. Get_SlipsNotification() .and.&
  257. Get_Slips() == SLIPS_SET_END) then
  258. call Set_Slips(SLIPS_UNSET_BEGIN)
  259. return
  260. end if
  261. endif
  262. end subroutine
  263. end module OperationScenariosModule