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.6 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. data%Equipments%Hook%HookHeight = v
  35. ! if(associated(HookHeightPtr)) then
  36. ! call HookHeightPtr(data%Equipments%Hook%HookHeight)
  37. ! end if
  38. !**call data%Equipments%Hook%OnHookHeightChange%RunAll(data%Equipments%Hook%HookHeight)
  39. end subroutine
  40. subroutine Set_HookHeight_S(v)
  41. implicit none
  42. real , intent(in) :: v
  43. if(v == data%Equipments%Hook%HookHeight) then
  44. return
  45. elseif (v > data%Equipments%Hook%HookHeight) then
  46. loop1: do
  47. call Set_HookHeight(data%Equipments%Hook%HookHeight + 0.2)
  48. if(abs(v - data%Equipments%Hook%HookHeight) <= 0.1) then
  49. call Set_HookHeight(v)
  50. exit loop1
  51. endif
  52. call sleepqq(100)
  53. enddo loop1
  54. else ! v < HookHeight
  55. loop2: do
  56. call Set_HookHeight(data%Equipments%Hook%HookHeight - 0.2)
  57. if(abs(data%Equipments%Hook%HookHeight - v) <= 0.1) then
  58. call Set_HookHeight(v)
  59. exit loop2
  60. endif
  61. call sleepqq(100)
  62. enddo loop2
  63. endif
  64. end subroutine
  65. subroutine Update_HookHeight_From_Snapshot()
  66. implicit none
  67. call Set_HookHeight_S(data%Equipments%Hook%HookHeight_S)
  68. end subroutine
  69. end module CHook