module CStringConfiguration use CStringConfigurationVariables use SimulationVariables use json_module implicit none public contains subroutine StringConfigurationFromJson(parent) use json_module,IK =>json_ik type(json_value),pointer :: parent type(json_core) :: json type(json_value),pointer :: p,pitems,pitem,pval,pbit logical::is_found integer::i,n_children CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val call json%get(parent,'StringConfiguration',p) call json%get(p,'StringConfigurationItems',pitems) call json%info(pitems, n_children=n_children) if (.not. allocated(data%Configuration%StringConfiguration%StringConfigurations)) then ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children)) endif if(size(data%Configuration%StringConfiguration%StringConfigurations)/=n_children) then DEALLOCATE(data%Configuration%StringConfiguration%StringConfigurations) ALLOCATE(data%Configuration%StringConfiguration%StringConfigurations(n_children)) endif data%Configuration%StringConfiguration%StringConfigurationCount = n_children do i=1,n_children call json%get_child(pitems, i, pitem, found=is_found) call json%get(pitem,"ComponentType",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType) call json%get(pitem,"NumberOfJoint",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint) call json%get(pitem,"LengthPerJoint",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint) call json%get(pitem,"NominalOd",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd) call json%get(pitem,"NominalId",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId) call json%get(pitem,"WeightPerLength",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength) call json%get(pitem,"ComponentLength",pval) call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength) ! call json%get(pitem,"NominalToolJointOd",pval) ! call json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd) ! call json%get(pitem,"Grade",pval) ! call json%get(pval,val) ! data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = val end do call json%get(p,'BitDefenition',pbit) call json%get(pbit,'BitType',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType) call json%get(pbit,'BitSize',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitSize) call json%get(pbit,'BitCodeHundreds',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds) call json%get(pbit,'BitCodeTens',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeTens) call json%get(pbit,'BitCodeOnes',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes) call json%get(pbit,'BitNozzleSize',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize) call json%get(pbit,'BitLength',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitLength) call json%get(pbit,'BitWeightPerLength',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength) call json%get(pbit,'BitNozzleNo',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo) call json%get(pbit,'FloatValve',pval) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%FloatValve) end subroutine subroutine StringConfigurationToJson(parent) type(json_value),pointer :: parent type(json_core) :: json type(json_value),pointer :: pitems,pitem,pbit,p integer:: i,n ! 1. create new node call json%create_object(p,'StringConfiguration') call json%create_array(pitems,'StringConfigurationItems') ! 2. add member of data type to new node n = data%Configuration%StringConfiguration%StringConfigurationCount do i=1,n call json%create_object(pitem,'') call json%add(pitem,"ComponentLength",data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength) call json%add(pitem,"ComponentType",data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType) ! call json%add(pitem,"Grade",data%Configuration%StringConfiguration%StringConfigurations(i)%Grade) call json%add(pitem,"LengthPerJoint",data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint) call json%add(pitem,"NominalId",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId) call json%add(pitem,"NominalOd",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd) ! call json%add(pitem,"NominalToolJointOd",data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd) call json%add(pitem,"NumberOfJoint",data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint) call json%add(pitem,"WeightPerLength",data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength) call json%add(pitems,pitem) end do call json%create_object(pbit,"BitDefenition") call json%add(pbit,"BitCodeHundreds",data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds) call json%add(pbit,"BitCodeOnes",data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes) call json%add(pbit,"BitCodeTens",data%Configuration%StringConfiguration%BitDefinition%BitCodeTens) call json%add(pbit,"BitLength",data%Configuration%StringConfiguration%BitDefinition%BitLength) call json%add(pbit,"BitNozzleNo",data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo) call json%add(pbit,"BitNozzleSize",data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize) call json%add(pbit,"BitSize",data%Configuration%StringConfiguration%BitDefinition%BitSize) call json%add(pbit,"BitType",data%Configuration%StringConfiguration%BitDefinition%BitType) call json%add(pbit,"BitWeightPerLength",data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength) call json%add(pbit,"FloatValve",data%Configuration%StringConfiguration%BitDefinition%FloatValve) ! call json%add(p,"StringConfigurationCount",dat%Configuration%StringConfiguration%StringConfigurationCount) ! 3. add new node to parent call json%add(p,pitems) call json%add(p,pbit) call json%add(parent,p) end subroutine end module CStringConfiguration