From ced7b02378acb770215ba9c2ad8aa15fe5d0f3f0 Mon Sep 17 00:00:00 2001 From: mahmood19227 Date: Sat, 8 Jul 2023 12:05:04 +0330 Subject: [PATCH] before merge with najafi --- .../BasicInputs/Bha/CStringConfiguration.f90 | 2 +- Simulator.f90 | 2 +- helper.ipynb | 49 ++++++++--------- testjson.f90 | 54 +++++++++---------- 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/CSharp/BasicInputs/Bha/CStringConfiguration.f90 b/CSharp/BasicInputs/Bha/CStringConfiguration.f90 index 4155cf2..a4f9955 100644 --- a/CSharp/BasicInputs/Bha/CStringConfiguration.f90 +++ b/CSharp/BasicInputs/Bha/CStringConfiguration.f90 @@ -48,7 +48,7 @@ module CStringConfiguration call json%get(pval,val) data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = val end do - call json%get(p,'StringConfigurationItems',pbit) + 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) diff --git a/Simulator.f90 b/Simulator.f90 index 57f64d5..79d1702 100644 --- a/Simulator.f90 +++ b/Simulator.f90 @@ -491,7 +491,7 @@ module Simulator call json%add(parent,p) end subroutine - subroutine ConfigurationFromJson(parent) + subroutine ConfigurationFromJson(parent) type(json_value),pointer :: parent type(json_core) :: json type(json_value),pointer :: p diff --git a/helper.ipynb b/helper.ipynb index 0cce7f0..204f6c1 100644 --- a/helper.ipynb +++ b/helper.ipynb @@ -913,40 +913,33 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "\t\t\tcall json%get(pitem,\"ComponentType\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType)\n", - "\n", - "\t\t\tcall json%get(pitem,\"NumberOfJoint\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint)\n", - "\n", - "\t\t\tcall json%get(pitem,\"LengthPerJoint\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint)\n", - "\n", - "\t\t\tcall json%get(pitem,\"NominalOd\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd)\n", - "\n", - "\t\t\tcall json%get(pitem,\"NominalId\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId)\n", - "\n", - "\t\t\tcall json%get(pitem,\"WeightPerLength\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength)\n", - "\n", - "\t\t\tcall json%get(pitem,\"ComponentLength\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength)\n", - "\n", - "\t\t\tcall json%get(pitem,\"NominalToolJointOd\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalToolJointOd)\n", - "\n", - "\t\t\tcall json%get(pitem,\"Grade\",pval)\n", - "\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%Grade)\n", - "\n" + "\t\tcall json%get(pbit,'BitType',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType)\n", + "\t\tcall json%get(pbit,'BitSize',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitSize)\n", + "\t\tcall json%get(pbit,'BitCodeHundreds',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds)\n", + "\t\tcall json%get(pbit,'BitCodeTens',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeTens)\n", + "\t\tcall json%get(pbit,'BitCodeOnes',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes)\n", + "\t\tcall json%get(pbit,'BitNozzleSize',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize)\n", + "\t\tcall json%get(pbit,'BitLength',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitLength)\n", + "\t\tcall json%get(pbit,'BitWeightPerLength',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength)\n", + "\t\tcall json%get(pbit,'BitNozzleNo',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo)\n", + "\t\tcall json%get(pbit,'FloatValve',pval)\n", + "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%FloatValve)\n" ] } ], diff --git a/testjson.f90 b/testjson.f90 index 1219d82..ec62b75 100644 --- a/testjson.f90 +++ b/testjson.f90 @@ -1,28 +1,28 @@ -program RedisInterface - use json_module - use CStringConfigurationVariables - - type(json_file) :: jsonfile - type(json_value),pointer :: jsonvalue,jsonvalue2,child,child2,jsonvalue3 - type(json_core) :: jsoncore - logical :: is_found - integer ::n_children,i,j - type(CStringItem), allocatable :: StringConfigurations(:) - - call jsonfile%initialize() - call jsonfile%load_file('data-witharray.json'); if (jsonfile%failed()) stop - call jsonfile%json_file_get_root(jsonvalue) - call jsoncore%get(jsonvalue,'Configuration',jsonvalue2) - call jsoncore%get(jsonvalue2,'StringConfiguration',jsonvalue) - call jsoncore%get(jsonvalue,'StringConfigurationItems',jsonvalue2) - call jsoncore%info(jsonvalue2, n_children=n_children) - do i=1,n_children - call jsoncore%get_child(jsonvalue2, i, child, found=is_found) - if (.not. is_found) print *,"not found" - call jsoncore%get(child,"BitCodeHundreds",child2) - call jsoncore%get(child2,j) - print *,"BitCodeHundreds=",j - end do - print *,"n_children=",n_children - call jsonfile%destroy() +program RedisInterface + use json_module + use CStringConfigurationVariables + + type(json_file) :: jsonfile + type(json_value),pointer :: jsonvalue,jsonvalue2,child,child2,jsonvalue3 + type(json_core) :: jsoncore + logical :: is_found + integer ::n_children,i,j + type(CStringItem), allocatable :: StringConfigurations(:) + + call jsonfile%initialize() + call jsonfile%load_file('data-witharray.json'); if (jsonfile%failed()) stop + call jsonfile%json_file_get_root(jsonvalue) + call jsoncore%get(jsonvalue,'Configuration',jsonvalue2) + call jsoncore%get(jsonvalue2,'StringConfiguration',jsonvalue) + call jsoncore%get(jsonvalue,'StringConfigurationItems',jsonvalue2) + call jsoncore%info(jsonvalue2, n_children=n_children) + do i=1,n_children + call jsoncore%get_child(jsonvalue2, i, child, found=is_found) + if (.not. is_found) print *,"not found" + call jsoncore%get(child,"BitCodeHundreds",child2) + call jsoncore%get(child2,j) + print *,"BitCodeHundreds=",j + end do + print *,"n_children=",n_children + call jsonfile%destroy() end program \ No newline at end of file