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.i90 2.8 KiB

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