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.
 
 
 
 
 
 

261 lines
8.7 KiB

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