Browse Source

before merge with najafi

master
mahmood19227 1 year ago
parent
commit
ced7b02378
4 changed files with 50 additions and 57 deletions
  1. +1
    -1
      CSharp/BasicInputs/Bha/CStringConfiguration.f90
  2. +1
    -1
      Simulator.f90
  3. +21
    -28
      helper.ipynb
  4. +27
    -27
      testjson.f90

+ 1
- 1
CSharp/BasicInputs/Bha/CStringConfiguration.f90 View File

@@ -48,7 +48,7 @@ module CStringConfiguration
call json%get(pval,val) call json%get(pval,val)
data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = val data%Configuration%StringConfiguration%StringConfigurations(i)%Grade = val
end do end do
call json%get(p,'StringConfigurationItems',pbit) call json%get(p,'BitDefenition',pbit)
call json%get(pbit,'BitType',pval) call json%get(pbit,'BitType',pval)
call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType) call json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType)
call json%get(pbit,'BitSize',pval) call json%get(pbit,'BitSize',pval)


+ 1
- 1
Simulator.f90 View File

@@ -491,7 +491,7 @@ module Simulator
call json%add(parent,p) call json%add(parent,p)
end subroutine end subroutine


subroutine ConfigurationFromJson(parent) subroutine ConfigurationFromJson(parent)
type(json_value),pointer :: parent type(json_value),pointer :: parent
type(json_core) :: json type(json_core) :: json
type(json_value),pointer :: p type(json_value),pointer :: p


+ 21
- 28
helper.ipynb View File

@@ -913,40 +913,33 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"\t\t\tcall json%get(pitem,\"ComponentType\",pval)\n", "\t\tcall json%get(pbit,'BitType',pval)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentType)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitType)\n",
"\n", "\t\tcall json%get(pbit,'BitSize',pval)\n",
"\t\t\tcall json%get(pitem,\"NumberOfJoint\",pval)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitSize)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NumberOfJoint)\n", "\t\tcall json%get(pbit,'BitCodeHundreds',pval)\n",
"\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeHundreds)\n",
"\t\t\tcall json%get(pitem,\"LengthPerJoint\",pval)\n", "\t\tcall json%get(pbit,'BitCodeTens',pval)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%LengthPerJoint)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeTens)\n",
"\n", "\t\tcall json%get(pbit,'BitCodeOnes',pval)\n",
"\t\t\tcall json%get(pitem,\"NominalOd\",pval)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitCodeOnes)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalOd)\n", "\t\tcall json%get(pbit,'BitNozzleSize',pval)\n",
"\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleSize)\n",
"\t\t\tcall json%get(pitem,\"NominalId\",pval)\n", "\t\tcall json%get(pbit,'BitLength',pval)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%NominalId)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitLength)\n",
"\n", "\t\tcall json%get(pbit,'BitWeightPerLength',pval)\n",
"\t\t\tcall json%get(pitem,\"WeightPerLength\",pval)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitWeightPerLength)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%WeightPerLength)\n", "\t\tcall json%get(pbit,'BitNozzleNo',pval)\n",
"\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%BitNozzleNo)\n",
"\t\t\tcall json%get(pitem,\"ComponentLength\",pval)\n", "\t\tcall json%get(pbit,'FloatValve',pval)\n",
"\t\t\tcall json%get(pval,data%Configuration%StringConfiguration%StringConfigurations(i)%ComponentLength)\n", "\t\tcall json%get(pval,data%Configuration%StringConfiguration%BitDefinition%FloatValve)\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"
] ]
} }
], ],


+ 27
- 27
testjson.f90 View File

@@ -1,28 +1,28 @@
program RedisInterface program RedisInterface
use json_module use json_module
use CStringConfigurationVariables use CStringConfigurationVariables
type(json_file) :: jsonfile
type(json_file) :: jsonfile type(json_value),pointer :: jsonvalue,jsonvalue2,child,child2,jsonvalue3
type(json_value),pointer :: jsonvalue,jsonvalue2,child,child2,jsonvalue3 type(json_core) :: jsoncore
type(json_core) :: jsoncore logical :: is_found
logical :: is_found integer ::n_children,i,j
integer ::n_children,i,j type(CStringItem), allocatable :: StringConfigurations(:)
type(CStringItem), allocatable :: StringConfigurations(:) call jsonfile%initialize()
call jsonfile%load_file('data-witharray.json'); if (jsonfile%failed()) stop
call jsonfile%initialize() call jsonfile%json_file_get_root(jsonvalue)
call jsonfile%load_file('data-witharray.json'); if (jsonfile%failed()) stop call jsoncore%get(jsonvalue,'Configuration',jsonvalue2)
call jsonfile%json_file_get_root(jsonvalue) call jsoncore%get(jsonvalue2,'StringConfiguration',jsonvalue)
call jsoncore%get(jsonvalue,'Configuration',jsonvalue2) call jsoncore%get(jsonvalue,'StringConfigurationItems',jsonvalue2)
call jsoncore%get(jsonvalue2,'StringConfiguration',jsonvalue) call jsoncore%info(jsonvalue2, n_children=n_children)
call jsoncore%get(jsonvalue,'StringConfigurationItems',jsonvalue2) do i=1,n_children
call jsoncore%info(jsonvalue2, n_children=n_children) call jsoncore%get_child(jsonvalue2, i, child, found=is_found)
do i=1,n_children if (.not. is_found) print *,"not found"
call jsoncore%get_child(jsonvalue2, i, child, found=is_found) call jsoncore%get(child,"BitCodeHundreds",child2)
if (.not. is_found) print *,"not found" call jsoncore%get(child2,j)
call jsoncore%get(child,"BitCodeHundreds",child2) print *,"BitCodeHundreds=",j
call jsoncore%get(child2,j) end do
print *,"BitCodeHundreds=",j print *,"n_children=",n_children
end do call jsonfile%destroy()
print *,"n_children=",n_children
call jsonfile%destroy()
end program end program

||||||
x
 
000:0
Loading…
Cancel
Save