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.
 
 
 
 
 
 

96 lines
4.0 KiB

  1. module CPathGeneration
  2. use SimulationVariables !@
  3. use json_module
  4. implicit none
  5. public
  6. contains
  7. subroutine PathGenerationToJson(parent)
  8. type(json_value),pointer :: parent
  9. type(json_core) :: json
  10. type(json_value),pointer :: ppath,pitems,pdp,p
  11. integer::i
  12. ! 1. create new node
  13. call json%create_object(ppath,'Path')
  14. call json%create_array(pitems,'Items')
  15. do i=1,data%Configuration%Path%ItemCount
  16. call json%create_object(p,'')
  17. call json%add(p,"HoleType",data%Configuration%Path%items(i)%HoleType)
  18. call json%add(p,"Angle",data%Configuration%Path%items(i)%Angle)
  19. call json%add(p,"Length",data%Configuration%Path%items(i)%Length)
  20. call json%add(p,"FinalAngle",data%Configuration%Path%items(i)%FinalAngle)
  21. call json%add(p,"TotalLength",data%Configuration%Path%items(i)%TotalLength)
  22. call json%add(p,"MeasuredDepth",data%Configuration%Path%items(i)%MeasuredDepth)
  23. call json%add(p,"TotalVerticalDepth",data%Configuration%Path%items(i)%TotalVerticalDepth)
  24. call json%add(pitems,p)
  25. end do
  26. call json%create_array(pdp,'DataPoints')
  27. do i=1,data%Configuration%Path%DataPointsCount
  28. call json%create_object(p,'')
  29. call json%add(p,"X",data%Configuration%Path%DataPoints(i)%X)
  30. call json%add(p,"Y",data%Configuration%Path%DataPoints(i)%Y)
  31. call json%add(pdp,p)
  32. end do
  33. ! 3. add new node to parent
  34. call json%add(ppath,pitems)
  35. call json%add(ppath,pdp)
  36. call json%add(parent,ppath)
  37. end subroutine
  38. subroutine PathGenerationFromJson(parent)
  39. use json_module,IK =>json_ik
  40. type(json_value),pointer :: parent
  41. type(json_core) :: json
  42. type(json_value),pointer :: p,pitems,pitem,pval,pbit,dpoints,dpoint
  43. logical::is_found
  44. type(CStringItem) :: item
  45. integer::i,n_children
  46. CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val
  47. call json%get(parent,'Path',p)
  48. call json%get(p,'Items',pitems)
  49. call json%info(pitems, n_children=n_children)
  50. if (.not. allocated(data%Configuration%Path%Items) .or. size(data%Configuration%Configuration%Path%Items)/=n_children) then
  51. ALLOCATE(data%Configuration%Configuration%Path%Items(n_children))
  52. endif
  53. do i=1,n_children
  54. call json%get_child(pitems, i, pitem, found=is_found)
  55. call json%get(pitem,"HoleType",pval)
  56. call json%get(pval,data%Configuration%Path%Items(i)%HoleType)
  57. call json%get(pitem,"Angle",pval)
  58. call json%get(pval,data%Configuration%Path%Items(i)%Angle)
  59. call json%get(pitem,"Length",pval)
  60. call json%get(pval,data%Configuration%Path%Items(i)%Length)
  61. call json%get(pitem,"FinalAngle",pval)
  62. call json%get(pval,data%Configuration%Path%Items(i)%FinalAngle)
  63. call json%get(pitem,"TotalLength",pval)
  64. call json%get(pval,data%Configuration%Path%Items(i)%TotalLength)
  65. call json%get(pitem,"MeasuredDepth",pval)
  66. call json%get(pval,data%Configuration%Path%Items(i)%MeasuredDepth)
  67. call json%get(pitem,"TotalVerticalDepth",pval)
  68. call json%get(pval,data%Configuration%Path%Items(i)%TotalVerticalDepth)
  69. end do
  70. call json%get(p,'DataPoints',dpoints)
  71. call json%info(dpoints, n_children=n_children)
  72. if (.not. allocated(data%Configuration%Path%DataPoints) .or. size(data%Configuration%Configuration%Path%DataPoints)/=n_children) then
  73. ALLOCATE(data%Configuration%Configuration%Path%DataPoints(n_children))
  74. endif
  75. do i=1,n_children
  76. call json%get_child(dpoints, i, dpoint, found=is_found)
  77. call json%get(dpoint,"X",pval)
  78. call json%get(pval,data%Configuration%Path%DataPoints(i)%X)
  79. call json%get(dpoint,"Y",pval)
  80. call json%get(pval,data%Configuration%Path%DataPoints(i)%Y)
  81. end do
  82. end subroutine
  83. end module CPathGeneration