# 1 "/home/admin/SimulationCore2/CSharp/BasicInputs/RigSpecifications/CHoisting.f90"
module CHoisting
    use SimulationVariables
    use json_module
    implicit none 
    public    
    contains

	subroutine HoistingFromJson(parent)
	
        use json_module,IK =>json_ik
        type(json_value),pointer :: parent
        type(json_core) :: json
        type(json_value),pointer :: p,pitem,pval
		logical::is_found
		integer::i,n_children
		CHARACTER(KIND=JSON_CK, LEN=:), ALLOCATABLE :: val

        call json%get(parent,'Hoisting',p)
		call json%get(p,'DriveType',pval)
		call json%get(pval,data%Configuration%Hoisting%DriveType)
		call json%get(p,'TravelingBlockWeight',pval)
		call json%get(pval,data%Configuration%Hoisting%TravelingBlockWeight)
		call json%get(p,'TopDriveWeight',pval)
		call json%get(pval,data%Configuration%Hoisting%TopDriveWeight)
		call json%get(p,'KellyWeight',pval)
		call json%get(pval,data%Configuration%Hoisting%KellyWeight)
		call json%get(p,'NumberOfLine',pval)
		call json%get(pval,data%Configuration%Hoisting%NumberOfLine)
		call json%get(p,'DrillingLineBreakingLoad',pval)
		call json%get(pval,data%Configuration%Hoisting%DrillingLineBreakingLoad)

!@@@
        data%Configuration%Hoisting%NumberOfLine = 10
    end subroutine

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

! 1. create new node
        call json%create_object(p,'Hoisting')
        
! 2. add member of data type to new node
! call StringConfigurationToJson(p)
! call FormationToJson(p)
        call json%add(p,"DrillingLineBreakingLoad",data%Configuration%Hoisting%DrillingLineBreakingLoad)
        call json%add(p,"DriveType",data%Configuration%Hoisting%DriveType)
        call json%add(p,"KellyWeight",data%Configuration%Hoisting%KellyWeight)
        call json%add(p,"NumberOfLine",data%Configuration%Hoisting%NumberOfLine)
        call json%add(p,"TopDriveWeight",data%Configuration%Hoisting%TopDriveWeight)
        call json%add(p,"TravelingBlockWeight",data%Configuration%Hoisting%TravelingBlockWeight)
! 3. add new node to parent
        call json%add(parent,p)
    end subroutine

end module CHoisting