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.

OperationScenarios.f90 9.1 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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=1
  70. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  71. !Get_JointConnectionPossible() .and.&
  72. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  73. Get_Swing() == SWING_WELL_END .and.&
  74. !Get_TongNotification() .and.&
  75. Get_Tong() == TONG_MAKEUP_END) then
  76. !call Log_4('KELLY_CONNECTION_STRING')
  77. call Set_Tong(TONG_NEUTRAL)
  78. call Set_KellyConnection(KELLY_CONNECTION_STRING)
  79. return
  80. end if
  81. !OPERATION-CODE=2
  82. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  83. Get_StringPressure() == 0 .and.&
  84. Get_HookHeight() <= (data%State%OperationScenario%HKL + Get_NearFloorConnection()) .and.&
  85. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  86. Get_Swing() == SWING_WELL_END .and.&
  87. !Get_TongNotification() .and.&
  88. Get_Tong() == TONG_BREAKOUT_END) then
  89. call Set_Tong(TONG_NEUTRAL)
  90. call Set_KellyConnection(KELLY_CONNECTION_NOTHING)
  91. call Set_SwingLed(.true.)
  92. return
  93. end if
  94. !OPERATION-CODE=3
  95. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  96. !Get_JointConnectionPossible() .and.&
  97. Get_KellyConnection() == KELLY_CONNECTION_NOTHING .and.&
  98. Get_Swing() == SWING_MOUSE_HOLE_END .and.&
  99. !Get_TongNotification() .and.&
  100. Get_FillMouseHoleLed() .and.&
  101. Get_Tong() == TONG_MAKEUP_END) then
  102. call Set_Tong(TONG_NEUTRAL)
  103. call Set_KellyConnection(KELLY_CONNECTION_SINGLE)
  104. call Set_SwingLed(.false.)
  105. call Set_FillMouseHoleLed(.false.)
  106. call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  107. return
  108. end if
  109. !OPERATION-CODE=4
  110. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  111. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  112. Get_Swing() == SWING_MOUSE_HOLE_END .and.&
  113. !Get_TongNotification() .and.&
  114. Get_FillMouseHoleLed() == .false. .and.&
  115. Get_Tong() == TONG_BREAKOUT_END) then
  116. call Set_Tong(TONG_NEUTRAL)
  117. call Set_KellyConnection(KELLY_CONNECTION_NOTHING)
  118. call Set_FillMouseHoleLed(.true.)
  119. call Set_MouseHole(MOUSE_HOLE_NEUTRAL)
  120. return
  121. end if
  122. !OPERATION-CODE=5
  123. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  124. !Get_JointConnectionPossible() .and.&
  125. Get_KellyConnection() == KELLY_CONNECTION_SINGLE .and.&
  126. Get_Swing() == SWING_WELL_END .and.&
  127. !Get_TongNotification() .and.&
  128. Get_Tong() == TONG_MAKEUP_END) then
  129. call Set_Tong(TONG_NEUTRAL)
  130. call Set_KellyConnection(KELLY_CONNECTION_STRING)
  131. call Set_StringUpdate(STRING_UPDATE_ADD_SINGLE)
  132. call Set_SwingLed(.false.)
  133. return
  134. end if
  135. !OPERATION-CODE=6
  136. if (Get_OperationCondition() == OPERATION_DRILL .and.&
  137. Get_StringPressure() == 0 .and.&
  138. Get_HookHeight() > 70.0 .and.&
  139. Get_KellyConnection() == KELLY_CONNECTION_STRING .and.&
  140. !Get_TongNotification() .and.&
  141. Get_Swing() == SWING_WELL_END .and.&
  142. Get_Tong() == TONG_BREAKOUT_END) then
  143. call Set_Tong(TONG_NEUTRAL)
  144. call Set_KellyConnection(KELLY_CONNECTION_SINGLE)
  145. call Set_StringUpdate(STRING_UPDATE_REMOVE_SINGLE)
  146. return
  147. end if
  148. endif
  149. end subroutine
  150. ! subroutine Subscribe_KellyConnection()
  151. ! use CDrillingConsoleVariables
  152. ! use ConfigurationVariables
  153. ! use ConfigurationVariables
  154. ! implicit none
  155. ! call OnBreakoutLeverPress%Add(ButtonPress_Breakout)
  156. ! call OnMakeupLeverPress%Add(ButtonPress_Makeup)
  157. ! end subroutine
  158. subroutine ButtonPress_Breakout()
  159. implicit none
  160. #ifdef deb
  161. print*, 'ButtonPress_Breakout on ======> CKellyConnectionEnum'
  162. #endif
  163. end subroutine
  164. subroutine ButtonPress_Makeup()
  165. implicit none
  166. #ifdef deb
  167. print*, 'ButtonPress_Makeup on ======> CKellyConnectionEnum'
  168. #endif
  169. end subroutine
  170. subroutine Set_StringUpdate(v)
  171. implicit none
  172. integer , intent(in) :: v
  173. #ifdef ExcludeExtraChanges
  174. if(data%State%OperationScenario%StringUpdate == v) return
  175. #endif
  176. data%State%OperationScenario%StringUpdate = v
  177. !**call data%State%OperationScenario%OnStringUpdateChange%RunAll(v)
  178. end subroutine
  179. integer function Get_StringUpdate()
  180. implicit none
  181. Get_StringUpdate = data%State%OperationScenario%StringUpdate
  182. end function
  183. real(8) function TJH()
  184. use TD_DrillStemComponents
  185. implicit none
  186. TJH = data%State%TD_String%TopJointHeight
  187. end function
  188. real function TL()
  189. implicit none
  190. TL = 26.97
  191. end function
  192. real function NFC()
  193. implicit none
  194. NFC = Get_NearFloorConnection()
  195. end function
  196. subroutine Set_ElevatorConnection(v)
  197. implicit none
  198. integer , intent(in) :: v
  199. #ifdef ExcludeExtraChanges
  200. if(data%State%OperationScenario%ElevatorConnection == v) return
  201. #endif
  202. data%State%OperationScenario%ElevatorConnection = v
  203. #ifdef deb
  204. print*, 'data%State%OperationScenario%ElevatorConnection=', data%State%OperationScenario%ElevatorConnection
  205. #endif
  206. !**call data%State%OperationScenario%OnElevatorConnectionChange%RunAll()
  207. end subroutine
  208. integer function Get_ElevatorConnection()
  209. implicit none
  210. Get_ElevatorConnection = data%State%OperationScenario%ElevatorConnection
  211. end function
  212. end module OperationScenariosModule