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.
 
 
 
 
 
 

305 lines
9.8 KiB

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