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.
 
 
 
 
 
 

199 lines
13 KiB

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