|
- module CDrillingConsole
- use CDrillingConsoleVariables
- use SimulationVariables
- ! use CSimulationVariables
- use CLog4
- use CLog3
- implicit none
- public
- contains
-
-
- subroutine DrillingConsoleFromJson(jsonfile)
- type(json_value),pointer :: parent
- type(json_core) :: json
- type(json_value),pointer :: p,pval
- type(json_file)::jsonfile
- logical::found
- integer :: i
-
- ! call jsonfile%get('Equipments.Drilling.AssignmentSwitch',data%Equipments%DrillingConsole%AssignmentSwitch,found)
- ! if ( .not. found ) call logg(4,"Not found: AssignmentSwitch")
- ! call jsonfile%get('Equipments.Drilling.EmergencySwitch',data%Equipments%DrillingConsole%EmergencySwitch,found)
- ! if ( .not. found ) call logg(4,"Not found: EmergencySwitch")
- ! call jsonfile%get('Equipments.Drilling.RTTorqueLimitKnob',data%Equipments%DrillingConsole%RTTorqueLimitKnob,found)
- ! if ( .not. found ) call logg(4,"Not found: RTTorqueLimitKnob")
- call jsonfile%get('Equipments.Drilling.MP1CPSwitch',data%Equipments%DrillingConsole%MP1CPSwitch,found)
- if ( .not. found ) call logg(4,"Not found: MP1CPSwitch")
- ! call jsonfile%get('Equipments.Drilling.MP1ThrottleUpdate',data%Equipments%DrillingConsole%MP1ThrottleUpdate,found)
- ! if ( .not. found ) call logg(4,"Not found: MP1ThrottleUpdate")
- call jsonfile%get('Equipments.Drilling.MP1Throttle',data%Equipments%DrillingConsole%MP1Throttle,found)
- if ( .not. found ) call logg(4,"Not found: MP1Throttle")
- call jsonfile%get('Equipments.Drilling.MP2Switch',data%Equipments%DrillingConsole%MP2Switch,found)
- if ( .not. found ) call logg(4,"Not found: MP2Switch")
- ! call jsonfile%get('Equipments.Drilling.MP2ThrottleUpdate',data%Equipments%DrillingConsole%MP2ThrottleUpdate,found)
- ! if ( .not. found ) call logg(4,"Not found: MP2ThrottleUpdate")
- call jsonfile%get('Equipments.Drilling.MP2Throttle',data%Equipments%DrillingConsole%MP2Throttle,found)
- if ( .not. found ) call logg(4,"Not found: MP2Throttle")
- call jsonfile%get('Equipments.Drilling.DWSwitch',data%Equipments%DrillingConsole%DWSwitch,found)
- if ( .not. found ) call logg(4,"Not found: DWSwitch")
- call jsonfile%get('Equipments.Drilling.DWThrottle',data%Equipments%DrillingConsole%DWThrottle,found)
- if ( .not. found ) call logg(4,"Not found: DWThrottle")
- ! if (print_log .and. abs(data%Equipments%DrillingConsole%DWThrottle)>0) print *,"data%Equipments%DrillingConsole%DWThrottle = ",data%Equipments%DrillingConsole%DWThrottle
- call jsonfile%get('Equipments.Drilling.RTSwitch',data%Equipments%DrillingConsole%RTSwitch,found)
- if ( .not. found ) call logg(4,"Not found: RTSwitch")
- call jsonfile%get('Equipments.Drilling.RTThrottle',i,found)
- data%Equipments%DrillingConsole%RTThrottle = real(i)
- if ( .not. found ) call logg(4,"Not found: RTThrottle")
- ! call jsonfile%get('Equipments.Drilling.DWBreak',data%Equipments%DrillingConsole%DWBreak,found)
- ! if ( .not. found ) call logg(4,"Not found: DWBreak")
- ! call jsonfile%get('Equipments.Drilling.PreviousDWBreak',data%Equipments%DrillingConsole%PreviousDWBreak,found)
- ! if ( .not. found ) call logg(4,"Not found: PreviousDWBreak")
- ! call jsonfile%get('Equipments.Drilling.ForceBreak',data%Equipments%DrillingConsole%ForceBreak,found)
- ! if ( .not. found ) call logg(4,"Not found: ForceBreak")
- ! call jsonfile%get('Equipments.Drilling.DWAcceleretor',data%Equipments%DrillingConsole%DWAcceleretor,found)
- ! if ( .not. found ) call logg(4,"Not found: DWAcceleretor")
- ! call jsonfile%get('Equipments.Drilling.DWTransmisionLever',data%Equipments%DrillingConsole%DWTransmisionLever,found)
- ! if ( .not. found ) call logg(4,"Not found: DWTransmisionLever")
- ! call jsonfile%get('Equipments.Drilling.DWPowerLever',data%Equipments%DrillingConsole%DWPowerLever,found)
- ! if ( .not. found ) call logg(4,"Not found: DWPowerLever")
- ! call jsonfile%get('Equipments.Drilling.TongLever',data%Equipments%DrillingConsole%TongLever,found)
- ! if ( .not. found ) call logg(4,"Not found: TongLever")
- ! call jsonfile%get('Equipments.Drilling.RTTransmissionLever',data%Equipments%DrillingConsole%RTTransmissionLever,found)
- ! if ( .not. found ) call logg(4,"Not found: RTTransmissionLever")
- ! call jsonfile%get('Equipments.Drilling.DWClutchLever',data%Equipments%DrillingConsole%DWClutchLever,found)
- ! if ( .not. found ) call logg(4,"Not found: DWClutchLever")
- ! call jsonfile%get('Equipments.Drilling.EddyBreakLever',data%Equipments%DrillingConsole%EddyBreakLever,found)
- ! if ( .not. found ) call logg(4,"Not found: EddyBreakLever")
- ! call jsonfile%get('Equipments.Drilling.AutoDW',data%Equipments%DrillingConsole%AutoDW,found)
- ! if ( .not. found ) call logg(4,"Not found: AutoDW")
- ! call jsonfile%get('Equipments.Drilling.GEN1',data%Equipments%DrillingConsole%GEN1,found)
- ! if ( .not. found ) call logg(4,"Not found: GEN1")
- ! call jsonfile%get('Equipments.Drilling.GEN2',data%Equipments%DrillingConsole%GEN2,found)
- ! if ( .not. found ) call logg(4,"Not found: GEN2")
- ! call jsonfile%get('Equipments.Drilling.GEN3',data%Equipments%DrillingConsole%GEN3,found)
- ! if ( .not. found ) call logg(4,"Not found: GEN3")
- ! call jsonfile%get('Equipments.Drilling.GEN4',data%Equipments%DrillingConsole%GEN4,found)
- ! if ( .not. found ) call logg(4,"Not found: GEN4")
- ! call jsonfile%get('Equipments.Drilling.Permission_OpenKellyCock',data%Equipments%DrillingConsole%Permission_OpenKellyCock,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_OpenKellyCock")
- ! call jsonfile%get('Equipments.Drilling.OpenKellyCock',data%Equipments%DrillingConsole%OpenKellyCock,found)
- ! if ( .not. found ) call logg(4,"Not found: OpenKellyCock")
- ! call jsonfile%get('Equipments.Drilling.Permission_CloseKellyCock',data%Equipments%DrillingConsole%Permission_CloseKellyCock,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_CloseKellyCock")
- ! call jsonfile%get('Equipments.Drilling.CloseKellyCock',data%Equipments%DrillingConsole%CloseKellyCock,found)
- ! if ( .not. found ) call logg(4,"Not found: CloseKellyCock")
- ! call jsonfile%get('Equipments.Drilling.Permission_OpenSafetyValve',data%Equipments%DrillingConsole%Permission_OpenSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_OpenSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.OpenSafetyValve',data%Equipments%DrillingConsole%OpenSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: OpenSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.Permission_CloseSafetyValve',data%Equipments%DrillingConsole%Permission_CloseSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_CloseSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.CloseSafetyValve',data%Equipments%DrillingConsole%CloseSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: CloseSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.Permission_IRSafetyValve',data%Equipments%DrillingConsole%Permission_IRSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_IRSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.IRSafetyValve',data%Equipments%DrillingConsole%IRSafetyValve,found)
- ! if ( .not. found ) call logg(4,"Not found: IRSafetyValve")
- ! call jsonfile%get('Equipments.Drilling.Permission_IRIBop',data%Equipments%DrillingConsole%Permission_IRIBop,found)
- ! if ( .not. found ) call logg(4,"Not found: Permission_IRIBop")
- ! call jsonfile%get('Equipments.Drilling.IRIBop',data%Equipments%DrillingConsole%IRIBop,found)
- ! if ( .not. found ) call logg(4,"Not found: IRIBop")
- ! call jsonfile%get('Equipments.Drilling.LatchPipe',data%Equipments%DrillingConsole%LatchPipe,found)
- ! if ( .not. found ) call logg(4,"Not found: LatchPipe")
- ! call jsonfile%get('Equipments.Drilling.UnlatchPipe',data%Equipments%DrillingConsole%UnlatchPipe,found)
- ! if ( .not. found ) call logg(4,"Not found: UnlatchPipe")
- ! call jsonfile%get('Equipments.Drilling.Swing',data%Equipments%DrillingConsole%Swing,found)
- ! if ( .not. found ) call logg(4,"Not found: Swing")
- ! call jsonfile%get('Equipments.Drilling.FillMouseHole',data%Equipments%DrillingConsole%FillMouseHole,found)
- ! if ( .not. found ) call logg(4,"Not found: FillMouseHole")
- ! call jsonfile%get('Equipments.Drilling.Slips',data%Equipments%DrillingConsole%Slips,found)
- ! if ( .not. found ) call logg(4,"Not found: Slips")
- ! call jsonfile%get('Equipments.Drilling.BrakeLeverCoefficient',data%Equipments%DrillingConsole%BrakeLeverCoefficient,found)
- ! if ( .not. found ) call logg(4,"Not found: BrakeLeverCoefficient")
- ! call jsonfile%get('Equipments.Drilling.HideDrillingBrake',data%Equipments%DrillingConsole%HideDrillingBrake,found)
- ! if ( .not. found ) call logg(4,"Not found: HideDrillingBrake")
- ! call jsonfile%get('Equipments.Drilling.ParkingBrakeBtn',data%Equipments%DrillingConsole%ParkingBrakeBtn,found)
- ! if ( .not. found ) call logg(4,"Not found: ParkingBrakeBtn")
-
- ! call jsonfile%destroy()
-
- ! data%Equipments%DrillingConsole%DWSwitch = -1
- data%Equipments%DrillingConsole%AssignmentSwitch = 1
- ! data%Equipments%DrillingConsole%MP1CPSwitch = -1
- ! data%Equipments%DrillingConsole%MP2Switch = -1
- ! data%Equipments%DrillingConsole%RTSwitch = -1
- end subroutine
-
- subroutine DrillingConsoleToJson(parent)
-
- type(json_value),pointer :: parent
- type(json_core) :: json
- type(json_value),pointer :: p
-
- ! 1. create new node
- call json%create_object(p,'Drilling')
-
- call json%add(p,"ParkingBrakeLed",data%Equipments%DrillingConsole%ParkingBrakeLed)
- call json%add(p,"GEN1LED",data%Equipments%DrillingConsole%GEN1LED)
- call json%add(p,"GEN2LED",data%Equipments%DrillingConsole%GEN2LED)
- call json%add(p,"GEN3LED",data%Equipments%DrillingConsole%GEN3LED)
- call json%add(p,"GEN4LED",data%Equipments%DrillingConsole%GEN4LED)
- call json%add(p,"SCR1LED",data%Equipments%DrillingConsole%SCR1LED)
- call json%add(p,"SCR2LED",data%Equipments%DrillingConsole%SCR2LED)
- call json%add(p,"SCR3LED",data%Equipments%DrillingConsole%SCR3LED)
- call json%add(p,"SCR4LED",data%Equipments%DrillingConsole%SCR4LED)
- call json%add(p,"MP1BLWR",data%Equipments%DrillingConsole%MP1BLWR)
- call json%add(p,"MP2BLWR",data%Equipments%DrillingConsole%MP2BLWR)
- call json%add(p,"DWBLWR",data%Equipments%DrillingConsole%DWBLWR)
- call json%add(p,"RTBLWR",data%Equipments%DrillingConsole%RTBLWR)
- call json%add(p,"PWRLIM",data%Equipments%DrillingConsole%PWRLIM)
- call json%add(p,"PWRLIMMTR",data%Equipments%DrillingConsole%PWRLIMMTR)
- call json%add(p,"RTTorqueLimitGauge",data%Equipments%DrillingConsole%RTTorqueLimitGauge)
- call json%add(p,"AutoDWLED",data%Equipments%DrillingConsole%AutoDWLED)
- call json%add(p,"GEN1BTNLED",data%Equipments%DrillingConsole%GEN1BTNLED)
- call json%add(p,"GEN2BTNLED",data%Equipments%DrillingConsole%GEN2BTNLED)
- call json%add(p,"GEN3BTNLED",data%Equipments%DrillingConsole%GEN3BTNLED)
- call json%add(p,"GEN4BTNLED",data%Equipments%DrillingConsole%GEN4BTNLED)
- call json%add(p,"OpenKellyCockLed",data%Equipments%DrillingConsole%OpenKellyCockLed)
- call json%add(p,"CloseKellyCockLed",data%Equipments%DrillingConsole%CloseKellyCockLed)
- call json%add(p,"OpenSafetyValveLed",data%Equipments%DrillingConsole%OpenSafetyValveLed)
- call json%add(p,"CloseSafetyValveLed",data%Equipments%DrillingConsole%CloseSafetyValveLed)
- call json%add(p,"IRSafetyValveLed",data%Equipments%DrillingConsole%IRSafetyValveLed)
- call json%add(p,"IRIBopLed",data%Equipments%DrillingConsole%IRIBopLed)
- call json%add(p,"LatchPipeLED",data%Equipments%DrillingConsole%LatchPipeLED)
- call json%add(p,"UnlatchPipeLED",data%Equipments%DrillingConsole%UnlatchPipeLED)
- call json%add(p,"SwingLed",data%Equipments%DrillingConsole%SwingLed)
- call json%add(p,"FillMouseHoleLed",data%Equipments%DrillingConsole%FillMouseHoleLed)
- call json%add(p,"MP1CPSwitch",data%Equipments%DrillingConsole%MP1CPSwitch)
- call json%add(p,"MP2Switch",data%Equipments%DrillingConsole%MP2Switch)
- call json%add(p,"DWSwitch",data%Equipments%DrillingConsole%DWSwitch)
- call json%add(p,"RTSwitch",data%Equipments%DrillingConsole%RTSwitch)
-
- call json%add(p,"RTSwitch",data%Equipments%DrillingConsole%RTSwitch)
-
- ! Trottle -------------
- call json%add(p,"MP1Throttle",data%Equipments%DrillingConsole%MP1Throttle)
- call json%add(p,"MP2Throttle",data%Equipments%DrillingConsole%MP2Throttle)
- call json%add(p,"RTThrottle",data%Equipments%DrillingConsole%RTThrottle)
- call json%add(p,"DWThrottle",data%Equipments%DrillingConsole%DWThrottle)
- call json%add(parent,p)
- end subroutine
-
- subroutine SetTongLever(v) bind(C,name="setTongLever")
- use CTongEnum
- use ISO_C_BINDING, only:c_int
- integer(c_int), intent(in) :: v
- if(v == 1) then
- call ButtonPress_Breakout_TongNotification()
- if(print_log) print*, 'BreakoutLeverPress'
- endif
- if(v == -1) then
- call ButtonPress_Makeup_TongNotification()
- if(print_log) print*, 'MakeupLeverPress'
- endif
- if(print_log) print*, 'TongLever=', v
- end subroutine
- end module CDrillingConsole
|