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.
 
 
 
 
 
 

263 lines
9.6 KiB

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