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.

CStringConfiguration.i90 6.6 KiB

1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # 1 "/mnt/c/Projects/VSIM/SimulationCore2/CSharp/BasicInputs/Bha/CStringConfiguration.f90"
  2. module CStringConfiguration
  3. use CStringConfigurationVariables
  4. use SimulationVariables
  5. use json_module
  6. implicit none
  7. public
  8. contains
  9. subroutine StringConfigurationFromJson(parent)
  10. use json_module,IK =>json_ik
  11. type(json_value),pointer :: parent
  12. type(json_core) :: json
  13. type(json_value),pointer :: p,pitems,pitem,pval,pbit
  14. logical::is_found
  15. integer::i,n_children
  16. CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val
  17. call json%get(parent,'StringConfiguration',p)
  18. call json%get(p,'StringConfigurationItems',pitems)
  19. call json%info(pitems, n_children=n_children)
  20. if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations)) then
  21. ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
  22. endif
  23. if(size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then
  24. DEALLOCATE(data%Configuration%StringConfiguration%StringConfigurations)
  25. ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children))
  26. endif
  27. do i=1,n_children
  28. call json%get_child(pitems, i, pitem, found=is_found)
  29. call json%get(pitem,"ComponentType",pval)
  30. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType)
  31. call json%get(pitem,"NumberOfJoint",pval)
  32. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint)
  33. call json%get(pitem,"LengthPerJoint",pval)
  34. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint)
  35. call json%get(pitem,"NominalOd",pval)
  36. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd)
  37. call json%get(pitem,"NominalId",pval)
  38. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId)
  39. call json%get(pitem,"WeightPerLength",pval)
  40. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength)
  41. call json%get(pitem,"ComponentLength",pval)
  42. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength)
  43. call json%get(pitem,"NominalToolJointOd",pval)
  44. call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd)
  45. call json%get(pitem,"Grade",pval)
  46. call json%get(pval,val)
  47. data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = val
  48. end do
  49. call json%get(p,'BitDefenition',pbit)
  50. call json%get(pbit,'BitType',pval)
  51. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType)
  52. call json%get(pbit,'BitSize',pval)
  53. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitSize)
  54. call json%get(pbit,'BitCodeHundreds',pval)
  55. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds)
  56. call json%get(pbit,'BitCodeTens',pval)
  57. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeTens)
  58. call json%get(pbit,'BitCodeOnes',pval)
  59. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes)
  60. call json%get(pbit,'BitNozzleSize',pval)
  61. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize)
  62. call json%get(pbit,'BitLength',pval)
  63. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitLength)
  64. call json%get(pbit,'BitWeightPerLength',pval)
  65. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength)
  66. call json%get(pbit,'BitNozzleNo',pval)
  67. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo)
  68. call json%get(pbit,'FloatValve',pval)
  69. call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%FloatValve)
  70. end subroutine
  71. subroutine StringConfigurationToJson(parent)
  72. type(json_value),pointer :: parent
  73. type(json_core) :: json
  74. type(json_value),pointer :: pitems,pitem,pbit,p
  75. integer:: i,n
  76. ! 1. create new node
  77. call json%create_object(p,'StringConfiguration')
  78. call json%create_array(pitems,'StringConfigurationItems')
  79. ! 2. add member of data type to new node
  80. n = data%Configuration%StringConfiguration%StringConfigurationCount
  81. do i=1,n
  82. call json%create_object(pitem,'')
  83. call json%add(pitem,"ComponentLength",data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength)
  84. call json%add(pitem,"ComponentType",data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType)
  85. call json%add(pitem,"Grade",data%Configuration%StringConfiguration%StringConfigurations(i)%Grade)
  86. call json%add(pitem,"LengthPerJoint",data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint)
  87. call json%add(pitem,"NominalId",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId)
  88. call json%add(pitem,"NominalOd",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd)
  89. call json%add(pitem,"NominalToolJointOd",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd)
  90. call json%add(pitem,"NumberOfJoint",data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint)
  91. call json%add(pitem,"WeightPerLength",data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength)
  92. call json%add(pitems,pitem)
  93. end do
  94. call json%create_object(pbit,"BitDefenition")
  95. call json%add(pbit,"BitCodeHundreds",data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds)
  96. call json%add(pbit,"BitCodeOnes",data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes)
  97. call json%add(pbit,"BitCodeTens",data%Configuration%StringConfiguration%BitDefinition%BitCodeTens)
  98. call json%add(pbit,"BitLength",data%Configuration%StringConfiguration%BitDefinition%BitLength)
  99. call json%add(pbit,"BitNozzleNo",data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo)
  100. call json%add(pbit,"BitNozzleSize",data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize)
  101. call json%add(pbit,"BitSize",data%Configuration%StringConfiguration%BitDefinition%BitSize)
  102. call json%add(pbit,"BitType",data%Configuration%StringConfiguration%BitDefinition%BitType)
  103. call json%add(pbit,"BitWeightPerLength",data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength)
  104. call json%add(pbit,"FloatValve",data%Configuration%StringConfiguration%BitDefinition%FloatValve)
  105. ! call json%add(p,"StringConfigurationCount",dat%Configuration%StringConfiguration%StringConfigurationCount)
  106. ! 3. add new node to parent
  107. call json%add(p,pitems)
  108. call json%add(p,pbit)
  109. call json%add(parent,p)
  110. end subroutine
  111. end module CStringConfiguration