Simulation Core
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

203 lines
13 KiB

  1. module CDrillingConsole
  2. use CDrillingConsoleVariables
  3. use SimulationVariables
  4. ! use CSimulationVariables
  5. use CLog4
  6. use CLog3
  7. implicit none
  8. public
  9. contains
  10. subroutine DrillingConsoleFromJson(jsonfile)
  11. type(json_value),pointer :: parent
  12. type(json_core) :: json
  13. type(json_value),pointer :: p,pval
  14. type(json_file)::jsonfile
  15. logical::found
  16. integer :: i
  17. call jsonfile%get('Equipments.Drilling.AssignmentSwitch',data%Equipments%DrillingConsole%AssignmentSwitch,found)
  18. if ( .not. found ) call logg(4,"Not found: AssignmentSwitch")
  19. call jsonfile%get('Equipments.Drilling.EmergencySwitch',data%Equipments%DrillingConsole%EmergencySwitch,found)
  20. if ( .not. found ) call logg(4,"Not found: EmergencySwitch")
  21. call jsonfile%get('Equipments.Drilling.RTTorqueLimitKnob',data%Equipments%DrillingConsole%RTTorqueLimitKnob,found)
  22. if ( .not. found ) call logg(4,"Not found: RTTorqueLimitKnob")
  23. call jsonfile%get('Equipments.Drilling.MP1CPSwitch',data%Equipments%DrillingConsole%MP1CPSwitch,found)
  24. if ( .not. found ) call logg(4,"Not found: MP1CPSwitch")
  25. call jsonfile%get('Equipments.Drilling.MP1ThrottleUpdate',data%Equipments%DrillingConsole%MP1ThrottleUpdate,found)
  26. if ( .not. found ) call logg(4,"Not found: MP1ThrottleUpdate")
  27. call jsonfile%get('Equipments.Drilling.MP1Throttle',data%Equipments%DrillingConsole%MP1Throttle,found)
  28. if ( .not. found ) then
  29. call logg(4,"Not found: MP1Throttle")
  30. endif
  31. call jsonfile%get('Equipments.Drilling.MP2Switch',data%Equipments%DrillingConsole%MP2Switch,found)
  32. if ( .not. found ) call logg(4,"Not found: MP2Switch")
  33. call jsonfile%get('Equipments.Drilling.MP2ThrottleUpdate',data%Equipments%DrillingConsole%MP2ThrottleUpdate,found)
  34. if ( .not. found ) call logg(4,"Not found: MP2ThrottleUpdate")
  35. call jsonfile%get('Equipments.Drilling.MP2Throttle',data%Equipments%DrillingConsole%MP2Throttle,found)
  36. if ( .not. found ) then
  37. call logg(4,"Not found: MP2Throttle")
  38. endif
  39. call jsonfile%get('Equipments.Drilling.DWSwitch',data%Equipments%DrillingConsole%DWSwitch,found)
  40. if ( .not. found ) call logg(4,"Not found: DWSwitch")
  41. call jsonfile%get('Equipments.Drilling.DWThrottle',data%Equipments%DrillingConsole%DWThrottle,found)
  42. if ( .not. found ) call logg(4,"Not found: DWThrottle")
  43. if (print_log .and. abs(data%Equipments%DrillingConsole%DWThrottle)>0) print *,"data%Equipments%DrillingConsole%DWThrottle = ",data%Equipments%DrillingConsole%DWThrottle
  44. call jsonfile%get('Equipments.Drilling.RTSwitch',data%Equipments%DrillingConsole%RTSwitch,found)
  45. if ( .not. found ) call logg(4,"Not found: RTSwitch")
  46. call jsonfile%get('Equipments.Drilling.RTThrottle',i,found)
  47. data%Equipments%DrillingConsole%RTThrottle = real(i)
  48. if ( .not. found ) then
  49. call logg(4,"Not found: RTThrottle")
  50. endif
  51. call jsonfile%get('Equipments.Drilling.DWBreak',data%Equipments%DrillingConsole%DWBreak,found)
  52. if ( .not. found ) call logg(4,"Not found: DWBreak")
  53. call jsonfile%get('Equipments.Drilling.PreviousDWBreak',data%Equipments%DrillingConsole%PreviousDWBreak,found)
  54. if ( .not. found ) call logg(4,"Not found: PreviousDWBreak")
  55. call jsonfile%get('Equipments.Drilling.ForceBreak',data%Equipments%DrillingConsole%ForceBreak,found)
  56. if ( .not. found ) call logg(4,"Not found: ForceBreak")
  57. call jsonfile%get('Equipments.Drilling.DWAcceleretor',data%Equipments%DrillingConsole%DWAcceleretor,found)
  58. if ( .not. found ) call logg(4,"Not found: DWAcceleretor")
  59. call jsonfile%get('Equipments.Drilling.DWTransmisionLever',data%Equipments%DrillingConsole%DWTransmisionLever,found)
  60. if ( .not. found ) call logg(4,"Not found: DWTransmisionLever")
  61. call jsonfile%get('Equipments.Drilling.DWPowerLever',data%Equipments%DrillingConsole%DWPowerLever,found)
  62. if ( .not. found ) call logg(4,"Not found: DWPowerLever")
  63. ! call jsonfile%get('Equipments.Drilling.TongLever',data%Equipments%DrillingConsole%TongLever,found)
  64. ! if ( .not. found ) call logg(4,"Not found: TongLever")
  65. call jsonfile%get('Equipments.Drilling.RTTransmissionLever',data%Equipments%DrillingConsole%RTTransmissionLever,found)
  66. if ( .not. found ) call logg(4,"Not found: RTTransmissionLever")
  67. call jsonfile%get('Equipments.Drilling.DWClutchLever',data%Equipments%DrillingConsole%DWClutchLever,found)
  68. if ( .not. found ) call logg(4,"Not found: DWClutchLever")
  69. call jsonfile%get('Equipments.Drilling.EddyBreakLever',data%Equipments%DrillingConsole%EddyBreakLever,found)
  70. if ( .not. found ) call logg(4,"Not found: EddyBreakLever")
  71. call jsonfile%get('Equipments.Drilling.AutoDW',data%Equipments%DrillingConsole%AutoDW,found)
  72. if ( .not. found ) call logg(4,"Not found: AutoDW")
  73. call jsonfile%get('Equipments.Drilling.GEN1',data%Equipments%DrillingConsole%GEN1,found)
  74. if ( .not. found ) call logg(4,"Not found: GEN1")
  75. call jsonfile%get('Equipments.Drilling.GEN2',data%Equipments%DrillingConsole%GEN2,found)
  76. if ( .not. found ) call logg(4,"Not found: GEN2")
  77. call jsonfile%get('Equipments.Drilling.GEN3',data%Equipments%DrillingConsole%GEN3,found)
  78. if ( .not. found ) call logg(4,"Not found: GEN3")
  79. call jsonfile%get('Equipments.Drilling.GEN4',data%Equipments%DrillingConsole%GEN4,found)
  80. if ( .not. found ) call logg(4,"Not found: GEN4")
  81. call jsonfile%get('Equipments.Drilling.Permission_OpenKellyCock',data%Equipments%DrillingConsole%Permission_OpenKellyCock,found)
  82. if ( .not. found ) call logg(4,"Not found: Permission_OpenKellyCock")
  83. call jsonfile%get('Equipments.Drilling.OpenKellyCock',data%Equipments%DrillingConsole%OpenKellyCock,found)
  84. if ( .not. found ) call logg(4,"Not found: OpenKellyCock")
  85. call jsonfile%get('Equipments.Drilling.Permission_CloseKellyCock',data%Equipments%DrillingConsole%Permission_CloseKellyCock,found)
  86. if ( .not. found ) call logg(4,"Not found: Permission_CloseKellyCock")
  87. call jsonfile%get('Equipments.Drilling.CloseKellyCock',data%Equipments%DrillingConsole%CloseKellyCock,found)
  88. if ( .not. found ) call logg(4,"Not found: CloseKellyCock")
  89. call jsonfile%get('Equipments.Drilling.Permission_OpenSafetyValve',data%Equipments%DrillingConsole%Permission_OpenSafetyValve,found)
  90. if ( .not. found ) call logg(4,"Not found: Permission_OpenSafetyValve")
  91. call jsonfile%get('Equipments.Drilling.OpenSafetyValve',data%Equipments%DrillingConsole%OpenSafetyValve,found)
  92. if ( .not. found ) call logg(4,"Not found: OpenSafetyValve")
  93. call jsonfile%get('Equipments.Drilling.Permission_CloseSafetyValve',data%Equipments%DrillingConsole%Permission_CloseSafetyValve,found)
  94. if ( .not. found ) call logg(4,"Not found: Permission_CloseSafetyValve")
  95. call jsonfile%get('Equipments.Drilling.CloseSafetyValve',data%Equipments%DrillingConsole%CloseSafetyValve,found)
  96. if ( .not. found ) call logg(4,"Not found: CloseSafetyValve")
  97. call jsonfile%get('Equipments.Drilling.Permission_IRSafetyValve',data%Equipments%DrillingConsole%Permission_IRSafetyValve,found)
  98. if ( .not. found ) call logg(4,"Not found: Permission_IRSafetyValve")
  99. call jsonfile%get('Equipments.Drilling.IRSafetyValve',data%Equipments%DrillingConsole%IRSafetyValve,found)
  100. if ( .not. found ) call logg(4,"Not found: IRSafetyValve")
  101. call jsonfile%get('Equipments.Drilling.Permission_IRIBop',data%Equipments%DrillingConsole%Permission_IRIBop,found)
  102. if ( .not. found ) call logg(4,"Not found: Permission_IRIBop")
  103. call jsonfile%get('Equipments.Drilling.IRIBop',data%Equipments%DrillingConsole%IRIBop,found)
  104. if ( .not. found ) call logg(4,"Not found: IRIBop")
  105. call jsonfile%get('Equipments.Drilling.LatchPipe',data%Equipments%DrillingConsole%LatchPipe,found)
  106. if ( .not. found ) call logg(4,"Not found: LatchPipe")
  107. call jsonfile%get('Equipments.Drilling.UnlatchPipe',data%Equipments%DrillingConsole%UnlatchPipe,found)
  108. if ( .not. found ) call logg(4,"Not found: UnlatchPipe")
  109. call jsonfile%get('Equipments.Drilling.Swing',data%Equipments%DrillingConsole%Swing,found)
  110. if ( .not. found ) call logg(4,"Not found: Swing")
  111. call jsonfile%get('Equipments.Drilling.FillMouseHole',data%Equipments%DrillingConsole%FillMouseHole,found)
  112. if ( .not. found ) call logg(4,"Not found: FillMouseHole")
  113. call jsonfile%get('Equipments.Drilling.Slips',data%Equipments%DrillingConsole%Slips,found)
  114. if ( .not. found ) call logg(4,"Not found: Slips")
  115. call jsonfile%get('Equipments.Drilling.BrakeLeverCoefficient',data%Equipments%DrillingConsole%BrakeLeverCoefficient,found)
  116. if ( .not. found ) call logg(4,"Not found: BrakeLeverCoefficient")
  117. call jsonfile%get('Equipments.Drilling.HideDrillingBrake',data%Equipments%DrillingConsole%HideDrillingBrake,found)
  118. if ( .not. found ) call logg(4,"Not found: HideDrillingBrake")
  119. call jsonfile%get('Equipments.Drilling.ParkingBrakeBtn',data%Equipments%DrillingConsole%ParkingBrakeBtn,found)
  120. if ( .not. found ) call logg(4,"Not found: ParkingBrakeBtn")
  121. ! call jsonfile%destroy()
  122. ! data%Equipments%DrillingConsole%DWSwitch = -1
  123. data%Equipments%DrillingConsole%AssignmentSwitch = 1
  124. ! data%Equipments%DrillingConsole%MP1CPSwitch = -1
  125. ! data%Equipments%DrillingConsole%MP2Switch = -1
  126. ! data%Equipments%DrillingConsole%RTSwitch = -1
  127. end subroutine
  128. subroutine DrillingConsoleToJson(parent)
  129. type(json_value),pointer :: parent
  130. type(json_core) :: json
  131. type(json_value),pointer :: p
  132. ! 1. create new node
  133. call json%create_object(p,'Drilling')
  134. call json%add(p,"ParkingBrakeLed",data%Equipments%DrillingConsole%ParkingBrakeLed)
  135. call json%add(p,"GEN1LED",data%Equipments%DrillingConsole%GEN1LED)
  136. call json%add(p,"GEN2LED",data%Equipments%DrillingConsole%GEN2LED)
  137. call json%add(p,"GEN3LED",data%Equipments%DrillingConsole%GEN3LED)
  138. call json%add(p,"GEN4LED",data%Equipments%DrillingConsole%GEN4LED)
  139. call json%add(p,"SCR1LED",data%Equipments%DrillingConsole%SCR1LED)
  140. call json%add(p,"SCR2LED",data%Equipments%DrillingConsole%SCR2LED)
  141. call json%add(p,"SCR3LED",data%Equipments%DrillingConsole%SCR3LED)
  142. call json%add(p,"SCR4LED",data%Equipments%DrillingConsole%SCR4LED)
  143. call json%add(p,"MP1BLWR",data%Equipments%DrillingConsole%MP1BLWR)
  144. call json%add(p,"MP2BLWR",data%Equipments%DrillingConsole%MP2BLWR)
  145. call json%add(p,"DWBLWR",data%Equipments%DrillingConsole%DWBLWR)
  146. call json%add(p,"RTBLWR",data%Equipments%DrillingConsole%RTBLWR)
  147. call json%add(p,"PWRLIM",data%Equipments%DrillingConsole%PWRLIM)
  148. call json%add(p,"PWRLIMMTR",data%Equipments%DrillingConsole%PWRLIMMTR)
  149. call json%add(p,"RTTorqueLimitGauge",data%Equipments%DrillingConsole%RTTorqueLimitGauge)
  150. call json%add(p,"AutoDWLED",data%Equipments%DrillingConsole%AutoDWLED)
  151. call json%add(p,"GEN1BTNLED",data%Equipments%DrillingConsole%GEN1BTNLED)
  152. call json%add(p,"GEN2BTNLED",data%Equipments%DrillingConsole%GEN2BTNLED)
  153. call json%add(p,"GEN3BTNLED",data%Equipments%DrillingConsole%GEN3BTNLED)
  154. call json%add(p,"GEN4BTNLED",data%Equipments%DrillingConsole%GEN4BTNLED)
  155. call json%add(p,"OpenKellyCockLed",data%Equipments%DrillingConsole%OpenKellyCockLed)
  156. call json%add(p,"CloseKellyCockLed",data%Equipments%DrillingConsole%CloseKellyCockLed)
  157. call json%add(p,"OpenSafetyValveLed",data%Equipments%DrillingConsole%OpenSafetyValveLed)
  158. call json%add(p,"CloseSafetyValveLed",data%Equipments%DrillingConsole%CloseSafetyValveLed)
  159. call json%add(p,"IRSafetyValveLed",data%Equipments%DrillingConsole%IRSafetyValveLed)
  160. call json%add(p,"IRIBopLed",data%Equipments%DrillingConsole%IRIBopLed)
  161. call json%add(p,"LatchPipeLED",data%Equipments%DrillingConsole%LatchPipeLED)
  162. call json%add(p,"UnlatchPipeLED",data%Equipments%DrillingConsole%UnlatchPipeLED)
  163. call json%add(p,"SwingLed",data%Equipments%DrillingConsole%SwingLed)
  164. call json%add(p,"FillMouseHoleLed",data%Equipments%DrillingConsole%FillMouseHoleLed)
  165. call json%add(p,"MP1CPSwitch",data%Equipments%DrillingConsole%MP1CPSwitch)
  166. call json%add(p,"MP2Switch",data%Equipments%DrillingConsole%MP2Switch)
  167. call json%add(p,"DWSwitch",data%Equipments%DrillingConsole%DWSwitch)
  168. call json%add(p,"RTSwitch",data%Equipments%DrillingConsole%RTSwitch)
  169. call json%add(p,"RTSwitch",data%Equipments%DrillingConsole%RTSwitch)
  170. ! Trottle -------------
  171. call json%add(p,"MP1Throttle",data%Equipments%DrillingConsole%MP1Throttle)
  172. call json%add(p,"MP2Throttle",data%Equipments%DrillingConsole%MP2Throttle)
  173. call json%add(p,"RTThrottle",data%Equipments%DrillingConsole%RTThrottle)
  174. call json%add(p,"DWThrottle",data%Equipments%DrillingConsole%DWThrottle)
  175. call json%add(parent,p)
  176. end subroutine
  177. subroutine SetTongLever(v) bind(C,name="setTongLever")
  178. use CTongEnum
  179. use ISO_C_BINDING, only:c_int
  180. integer(c_int), intent(in) :: v
  181. if(v == 1) then
  182. call ButtonPress_Breakout_TongNotification()
  183. if(print_log) print*, 'BreakoutLeverPress'
  184. endif
  185. if(v == -1) then
  186. call ButtonPress_Makeup_TongNotification()
  187. if(print_log) print*, 'MakeupLeverPress'
  188. endif
  189. if(print_log) print*, 'TongLever=', v
  190. end subroutine
  191. end module CDrillingConsole