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.

CHook.f90 2.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. module CHook
  2. use CHookVariables
  3. use SimulationVariables
  4. implicit none
  5. public
  6. contains
  7. subroutine HookFromJson(parent)
  8. type(json_value),pointer :: parent
  9. type(json_core) :: json
  10. type(json_value),pointer :: p,pval
  11. ! 1. get related root
  12. ! call json%get(parent,'Hook',p)
  13. ! ! 2. get member of data type from node
  14. ! call json%get(p,'HookHeight_S',pval)
  15. ! call json%get(pval,data%Equipments%Hook%HookHeight_S)
  16. ! call json%get(p,'HookHeight',pval)
  17. ! call json%get(pval,data%Equipments%Hook%HookHeight)
  18. end subroutine
  19. subroutine HookToJson(parent)
  20. type(json_value),pointer :: parent
  21. type(json_core) :: json
  22. type(json_value),pointer :: p
  23. ! 1. create new node
  24. call json%create_object(p,'Hook')
  25. call json%add(p,"HookHeight_S",data%Equipments%Hook%HookHeight_S)
  26. call json%add(p,"HookHeight",data%Equipments%Hook%HookHeight)
  27. call json%add(parent,p)
  28. end subroutine
  29. subroutine Set_HookHeight(v)
  30. use CDrillingConsoleVariables
  31. use SimulationVariables
  32. implicit none
  33. real , intent(in) :: v
  34. #ifdef ExcludeExtraChanges
  35. if(data%Equipments%Hook%HookHeight == v) return
  36. #endif
  37. data%Equipments%Hook%HookHeight = v
  38. ! if(associated(HookHeightPtr)) then
  39. ! call HookHeightPtr(data%Equipments%Hook%HookHeight)
  40. ! end if
  41. #ifdef deb
  42. print*, 'HookHeight=', data%Equipments%Hook%HookHeight
  43. #endif
  44. !**call data%Equipments%Hook%OnHookHeightChange%RunAll(data%Equipments%Hook%HookHeight)
  45. end subroutine
  46. subroutine Set_HookHeight_S(v)
  47. implicit none
  48. real , intent(in) :: v
  49. if(v == data%Equipments%Hook%HookHeight) then
  50. return
  51. elseif (v > data%Equipments%Hook%HookHeight) then
  52. loop1: do
  53. call Set_HookHeight(data%Equipments%Hook%HookHeight + 0.2)
  54. if(abs(v - data%Equipments%Hook%HookHeight) <= 0.1) then
  55. call Set_HookHeight(v)
  56. exit loop1
  57. endif
  58. call sleepqq(100)
  59. enddo loop1
  60. else ! v < HookHeight
  61. loop2: do
  62. call Set_HookHeight(data%Equipments%Hook%HookHeight - 0.2)
  63. if(abs(data%Equipments%Hook%HookHeight - v) <= 0.1) then
  64. call Set_HookHeight(v)
  65. exit loop2
  66. endif
  67. call sleepqq(100)
  68. enddo loop2
  69. endif
  70. end subroutine
  71. subroutine Update_HookHeight_From_Snapshot()
  72. implicit none
  73. call Set_HookHeight_S(data%Equipments%Hook%HookHeight_S)
  74. end subroutine
  75. end module CHook