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.
 
 
 
 
 
 

288 lines
8.6 KiB

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