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.
 
 
 
 
 
 

278 lines
8.0 KiB

  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/OperationScenarios/Unity/UnityModule.f90"
  2. module UnityModule
  3. use SimulationVariables
  4. implicit none
  5. contains
  6. subroutine UnityInputsFromJson(parent)
  7. use json_module,IK =>json_ik
  8. type(json_value),pointer :: parent
  9. type(json_core) :: json
  10. type(json_value),pointer :: p,pval
  11. call json%get(parent,'Unity',p)
  12. call json%get(p,'ElevatorConnectionPossible',pval)
  13. call json%get(pval,data%Equipments%UnityInputs%ElevatorConnectionPossible)
  14. call json%get(p,'JointConnectionPossible',pval)
  15. call json%get(pval,data%Equipments%UnityInputs%JointConnectionPossible)
  16. call json%get(p,'IsKellyBushingSetInTable',pval)
  17. call json%get(pval,data%Equipments%UnityInputs%IsKellyBushingSetInTable)
  18. call json%get(p,'ElevatorPickup',pval)
  19. call json%get(pval,data%Equipments%UnityInputs%ElevatorPickup)
  20. call json%get(p,'NearFloorPosition',pval)
  21. call json%get(pval,data%Equipments%UnityInputs%NearFloorPosition)
  22. call json%get(p,'SingleSetInMouseHole',pval)
  23. call json%get(pval,data%Equipments%UnityInputs%SingleSetInMouseHole)
  24. call json%get(p,'TdsConnectionPossible',pval)
  25. call json%get(pval,data%Equipments%UnityInputs%TdsConnectionPossible)
  26. call json%get(p,'TdsStemIn',pval)
  27. call json%get(pval,data%Equipments%UnityInputs%TdsStemIn)
  28. end subroutine
  29. subroutine UnityOutputsToJson(parent)
  30. type(json_value),pointer :: parent
  31. type(json_core) :: json
  32. type(json_value),pointer :: p
  33. ! 1. create new node
  34. call json%create_object(p,'Unity')
  35. ! 2. add member of data type to new node
  36. call json%add(p,"KellyHoseVibrationRate",data%Equipments%UnityOutputs%KellyHoseVibrationRate)
  37. call json%add(p,"BlowoutFromStringPercent",data%Equipments%UnityOutputs%BlowoutFromStringPercent)
  38. call json%add(p,"Pedal",data%Equipments%UnityOutputs%Pedal)
  39. call json%add(p,"FlowRate",data%Equipments%UnityOutputs%FlowRate)
  40. call json%add(p,"RotaryRpm",data%Equipments%UnityOutputs%RotaryRpm)
  41. call json%add(p,"BlowoutFromString",data%Equipments%UnityOutputs%BlowoutFromString)
  42. call json%add(p,"BlowoutFromAnnular",data%Equipments%UnityOutputs%BlowoutFromAnnular)
  43. call json%add(p,"FlowFromReturnLine",data%Equipments%UnityOutputs%FlowFromReturnLine)
  44. call json%add(p,"FlowFromKelly",data%Equipments%UnityOutputs%FlowFromKelly)
  45. call json%add(p,"FlowFromFillupHead",data%Equipments%UnityOutputs%FlowFromFillupHead)
  46. call json%add(p,"FlowKellyDisconnect",data%Equipments%UnityOutputs%FlowKellyDisconnect)
  47. call json%add(p,"FlowPipeDisconnect",data%Equipments%UnityOutputs%FlowPipeDisconnect)
  48. ! 3. add new node to parent
  49. call json%add(parent,p)
  50. end subroutine
  51. logical function Get_ElevatorPickup()
  52. Get_ElevatorPickup = data%Equipments%UnityInputs%ElevatorPickup
  53. end function
  54. logical function Get_IsKellyBushingSetInTable()
  55. Get_IsKellyBushingSetInTable = data%Equipments%UnityInputs%IsKellyBushingSetInTable
  56. end function
  57. logical function Get_JointConnectionPossible()
  58. Get_JointConnectionPossible = data%Equipments%UnityInputs%JointConnectionPossible
  59. end function
  60. logical function Get_ElevatorConnectionPossible()
  61. implicit none
  62. Get_ElevatorConnectionPossible = data%Equipments%UnityInputs%ElevatorConnectionPossible
  63. end function
  64. logical function Get_NearFloorPosition()
  65. Get_NearFloorPosition = data%Equipments%UnityInputs%NearFloorPosition
  66. end function
  67. subroutine Set_NearFloorPosition(v)
  68. implicit none
  69. logical, intent(in) :: v
  70. ! #ifdef ExcludeExtraChanges
  71. ! if(data%Equipments%UnityInputs%NearFloorPosition == v) return
  72. ! #endif
  73. data%Equipments%UnityInputs%NearFloorPosition = v
  74. !**call data%Equipments%UnityInputs%OnNearFloorPositionChange%RunAll()
  75. if(logging>4) then
  76. print*, 'NearFloorPosition =', data%Equipments%UnityInputs%NearFloorPosition
  77. endif
  78. end subroutine
  79. logical function Get_SingleSetInMouseHole()
  80. Get_SingleSetInMouseHole = data%Equipments%UnityInputs%SingleSetInMouseHole
  81. end function
  82. logical function Get_TdsConnectionPossible()
  83. Get_TdsConnectionPossible = data%Equipments%UnityInputs%TdsConnectionPossible
  84. end function
  85. logical function Get_TdsStemIn()
  86. Get_TdsStemIn = data%Equipments%UnityInputs%TdsStemIn
  87. end function
  88. subroutine Set_BlowoutFromString(v)
  89. implicit none
  90. logical, intent (in) :: v
  91. data%Equipments%UnityOutputs%BlowoutFromString = v
  92. # 105
  93. end subroutine
  94. logical function Get_BlowoutFromString()
  95. implicit none
  96. Get_BlowoutFromString = data%Equipments%UnityOutputs%BlowoutFromString
  97. end function
  98. subroutine Set_BlowoutFromAnnular(v)
  99. implicit none
  100. logical, intent (in) :: v
  101. data%Equipments%UnityOutputs%BlowoutFromAnnular = v
  102. # 119
  103. end subroutine
  104. logical function Get_BlowoutFromAnnular()
  105. implicit none
  106. Get_BlowoutFromAnnular = data%Equipments%UnityOutputs%BlowoutFromAnnular
  107. end function
  108. subroutine Set_FlowFromReturnLine(v)
  109. implicit none
  110. logical, intent (in) :: v
  111. data%Equipments%UnityOutputs%FlowFromReturnLine = v
  112. # 137
  113. end subroutine
  114. logical function Get_FlowFromReturnLine()
  115. implicit none
  116. Get_FlowFromReturnLine = data%Equipments%UnityOutputs%FlowFromReturnLine
  117. end function
  118. subroutine Set_FlowFromKelly(v)
  119. implicit none
  120. real, intent (in) :: v
  121. data%Equipments%UnityOutputs%FlowFromKelly = v
  122. # 153
  123. end subroutine
  124. real function Get_FlowFromKelly()
  125. implicit none
  126. Get_FlowFromKelly = data%Equipments%UnityOutputs%FlowFromKelly
  127. end function
  128. subroutine Set_FlowFromFillupHead(v)
  129. implicit none
  130. real, intent (in) :: v
  131. data%Equipments%UnityOutputs%FlowFromFillupHead = v
  132. # 171
  133. end subroutine
  134. real function Get_FlowFromFillupHead()
  135. implicit none
  136. Get_FlowFromFillupHead = data%Equipments%UnityOutputs%FlowFromFillupHead
  137. end function
  138. subroutine Set_FlowKellyDisconnect(v)
  139. implicit none
  140. logical, intent (in) :: v
  141. data%Equipments%UnityOutputs%FlowKellyDisconnect = v
  142. # 190
  143. end subroutine
  144. logical function Get_FlowKellyDisconnect()
  145. implicit none
  146. Get_FlowKellyDisconnect = data%Equipments%UnityOutputs%FlowKellyDisconnect
  147. end function
  148. subroutine Set_FlowPipeDisconnect(v)
  149. implicit none
  150. logical, intent (in) :: v
  151. data%Equipments%UnityOutputs%FlowPipeDisconnect = v
  152. # 207
  153. end subroutine
  154. logical function Get_FlowPipeDisconnect()
  155. implicit none
  156. Get_FlowPipeDisconnect = data%Equipments%UnityOutputs%FlowPipeDisconnect
  157. end function
  158. subroutine Set_BlowoutFromStringPercent(v)
  159. implicit none
  160. real(8), intent (in) :: v
  161. data%Equipments%UnityOutputs%BlowoutFromStringPercent = v
  162. # 221
  163. end subroutine
  164. real(8) function GetBlowoutFromStringPercent()
  165. implicit none
  166. GetBlowoutFromStringPercent = data%Equipments%UnityOutputs%BlowoutFromStringPercent
  167. end function
  168. subroutine Calc_KellyHoseVibrationRate(spm1, spm2)
  169. use CScaleRange
  170. implicit none
  171. real(8), intent (in) :: spm1, spm2
  172. real :: total
  173. total = (spm1 + spm2)/2
  174. data%Equipments%UnityOutputs%KellyHoseVibrationRate = ScaleRange(total, 0.0, 10.0, 0.0, 120.0)
  175. # 238
  176. end subroutine
  177. real(8) function GetKellyHoseVibrationRate()
  178. implicit none
  179. GetKellyHoseVibrationRate = data%Equipments%UnityOutputs%KellyHoseVibrationRate
  180. end function
  181. subroutine Set_Pedal(v)
  182. implicit none
  183. real(8), intent (in) :: v
  184. data%Equipments%UnityOutputs%Pedal = v
  185. # 252
  186. end subroutine
  187. real(8) function GetPedal()
  188. implicit none
  189. GetPedal = data%Equipments%UnityOutputs%Pedal
  190. end function
  191. subroutine Set_FlowRate(v)
  192. implicit none
  193. real(8), intent (in) :: v
  194. data%Equipments%UnityOutputs%FlowRate = v
  195. # 266
  196. end subroutine
  197. real(8) function GetFlowRate()
  198. implicit none
  199. GetFlowRate = data%Equipments%UnityOutputs%FlowRate
  200. end function
  201. subroutine Set_RotaryRpm(v)
  202. implicit none
  203. real(8), intent (in) :: v
  204. data%Equipments%UnityOutputs%RotaryRpm = v
  205. # 280
  206. end subroutine
  207. real(8) function GetRotaryRpm()
  208. implicit none
  209. GetRotaryRpm = data%Equipments%UnityOutputs%RotaryRpm
  210. end function
  211. end module UnityModule