module CPower
    use SimulationVariables
    use json_module
    implicit none    
    public    
    contains   
    
    subroutine PowerToJson(parent)

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

        ! 1. create new node
        call json%create_object(p,'Power')
        
        ! 2. add member of data type to new node
        ! call StringConfigurationToJson(p) 
        ! call FormationToJson(p) 
        call json%add(p,"CementPump",data%Configuration%Power%CementPump)
        call json%add(p,"Drawworks",data%Configuration%Power%Drawworks)
        call json%add(p,"GeneratorPowerRating",data%Configuration%Power%GeneratorPowerRating)
        call json%add(p,"MudPump1",data%Configuration%Power%MudPump1)
        call json%add(p,"MudPump2",data%Configuration%Power%MudPump2)
        call json%add(p,"NumberOfgenerators",data%Configuration%Power%NumberOfgenerators)
        call json%add(p,"RotaryTable",data%Configuration%Power%RotaryTable)
        call json%add(p,"TopDrive",data%Configuration%Power%TopDrive)        
        ! 3. add new node to parent
        call json%add(parent,p)
    end subroutine

    
end module CPower