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.

NotificationVariables.f90 16 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. module NotificationVariables
  2. use CVoidEventHandlerCollection
  3. implicit none
  4. type::NotificationType
  5. logical :: CloseKellyCockLed = .false.
  6. type(VoidEventHandlerCollection) :: OnCloseKellyCockLedChange
  7. logical :: CloseSafetyValveLed = .false.
  8. integer :: operation_CloseSafetyValveLed = 0
  9. type(VoidEventHandlerCollection) :: OnCloseSafetyValveLedChange
  10. logical :: FillMouseHoleLed = .false.
  11. type(VoidEventHandlerCollection) :: OnFillMouseHoleLedChange
  12. logical :: IrIBopLed = .false.
  13. type(VoidEventHandlerCollection) :: OnIrIBopLedChange
  14. logical :: IrSafetyValveLed = .false.
  15. integer :: operation_IrSafetyValveLed = 0
  16. type(VoidEventHandlerCollection) :: OnIrSafetyValveLedChange
  17. logical :: LatchLed = .false.
  18. type(VoidEventHandlerCollection) :: OnLatchLedChange
  19. logical :: OpenKellyCockLed = .false.
  20. type(VoidEventHandlerCollection) :: OnOpenKellyCockLedChange
  21. logical :: OpenSafetyValveLed = .false.
  22. integer :: operation_OpenSafetyValveLed = 0
  23. type(VoidEventHandlerCollection) :: OnOpenSafetyValveLedChange
  24. logical :: SlipsNotification = .false.
  25. ! procedure (ActionBool), pointer :: SlipsNotificationPtr
  26. type(VoidEventHandlerCollection) :: OnSlipsNotificationChange
  27. logical :: SwingLed = .false.
  28. type(VoidEventHandlerCollection) :: OnSwingLedChange
  29. logical :: IbopLed = .false.
  30. type(VoidEventHandlerCollection) :: OnIbopLedChange
  31. logical :: PowerLed = .false.
  32. type(VoidEventHandlerCollection) :: OnPowerLedChange
  33. integer :: TorqueWrenchLed = 0
  34. type(VoidEventHandlerCollection) :: OnTorqueWrenchLedChange
  35. logical :: TongNotification = .false.
  36. ! procedure (ActionBool), pointer :: TongNotificationPtr
  37. type(VoidEventHandlerCollection) :: OnTongNotificationChange
  38. logical :: UnlatchLed = .false.
  39. type(VoidEventHandlerCollection) :: OnUnlatchLedChange
  40. end type NotificationType
  41. type(NotificationType)::notifications
  42. contains
  43. subroutine Set_UnlatchLed(v)
  44. use CDrillingConsoleVariables!, only: DrillingConsole%UnlatchPipeLED
  45. !use CLatchLedNotification
  46. implicit none
  47. logical , intent(in) :: v
  48. #ifdef ExcludeExtraChanges
  49. if(notifications%UnlatchLed == v) return
  50. #endif
  51. notifications%UnlatchLed = v
  52. if(notifications%UnlatchLed) then
  53. DrillingConsole%UnlatchPipeLED = 1
  54. !call Set_LatchLed(.false.)
  55. else
  56. DrillingConsole%UnlatchPipeLED = 0
  57. endif
  58. call notifications%OnUnlatchLedChange%RunAll()
  59. end subroutine
  60. logical function Get_UnlatchLed()
  61. implicit none
  62. Get_UnlatchLed = notifications%UnlatchLed
  63. end function
  64. subroutine Set_TongNotification(v)
  65. implicit none
  66. logical , intent(in) :: v
  67. #ifdef ExcludeExtraChanges
  68. if(notifications%TongNotification == v) return
  69. #endif
  70. notifications%TongNotification = v
  71. ! if(associated(notifications%TongNotificationPtr)) call notifications%TongNotificationPtr(notifications%TongNotification)
  72. #ifdef deb
  73. print*, 'notifications%TongNotification=', notifications%TongNotification
  74. #endif
  75. call notifications%OnTongNotificationChange%RunAll()
  76. end subroutine
  77. logical function Get_TongNotification()
  78. implicit none
  79. Get_TongNotification = notifications%TongNotification
  80. end function
  81. subroutine Set_TorqueWrenchLed(v)
  82. use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveTorqueWrenchLed
  83. implicit none
  84. integer , intent(in) :: v
  85. #ifdef ExcludeExtraChanges
  86. if(notifications%TorqueWrenchLed == v) return
  87. #endif
  88. notifications%TorqueWrenchLed = v
  89. TopDrivePanel%TopDriveTorqueWrenchLed = v
  90. call notifications%OnTorqueWrenchLedChange%RunAll()
  91. end subroutine
  92. logical function Get_TorqueWrenchLed()
  93. implicit none
  94. Get_TorqueWrenchLed = notifications%TorqueWrenchLed
  95. end function
  96. subroutine Set_PowerLed(v)
  97. use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveTdsPowerLed
  98. !use CLatchLedNotification
  99. implicit none
  100. logical , intent(in) :: v
  101. #ifdef ExcludeExtraChanges
  102. if(notifications%PowerLed == v) return
  103. #endif
  104. notifications%PowerLed = v
  105. if(notifications%PowerLed) then
  106. TopDrivePanel%TopDriveTdsPowerLed = 1
  107. !call Set_LatchLed(.false.)
  108. else
  109. TopDrivePanel%TopDriveTdsPowerLed = 0
  110. endif
  111. call notifications%OnPowerLedChange%RunAll()
  112. end subroutine
  113. logical function Get_PowerLed()
  114. implicit none
  115. Get_PowerLed = notifications%PowerLed
  116. end function
  117. subroutine Set_IbopLed(v)
  118. use CTopDrivePanelVariables!, only: TopDrivePanel%TopDriveIbopLed
  119. use CManifolds, Only: OpenTopDriveIBop, CloseTopDriveIBop
  120. !use CLatchLedNotification
  121. implicit none
  122. logical , intent(in) :: v
  123. #ifdef ExcludeExtraChanges
  124. if(notifications%IbopLed == v) return
  125. #endif
  126. notifications%IbopLed = v
  127. if(notifications%IbopLed) then
  128. TopDrivePanel%TopDriveIbopLed = 1
  129. call CloseTopDriveIBop()
  130. else
  131. TopDrivePanel%TopDriveIbopLed = 0
  132. call OpenTopDriveIBop()
  133. endif
  134. call notifications%OnIbopLedChange%RunAll()
  135. end subroutine
  136. logical function Get_IbopLed()
  137. implicit none
  138. Get_IbopLed = notifications%IbopLed
  139. end function
  140. subroutine Set_SwingLed(v)
  141. use CDrillingConsoleVariables!, only: SwingLedHw => SwingLed
  142. implicit none
  143. logical , intent(in) :: v
  144. #ifdef ExcludeExtraChanges
  145. if(notifications%SwingLed == v) return
  146. #endif
  147. notifications%SwingLed = v
  148. if(notifications%SwingLed) then
  149. DrillingConsole%SwingLed = 1
  150. else
  151. DrillingConsole%SwingLed = 0
  152. endif
  153. call notifications%OnSwingLedChange%RunAll()
  154. end subroutine
  155. logical function Get_SwingLed()
  156. implicit none
  157. Get_SwingLed = notifications%SwingLed
  158. end function
  159. subroutine Set_SlipsNotification(v)
  160. implicit none
  161. logical , intent(in) :: v
  162. #ifdef ExcludeExtraChanges
  163. if(notifications%SlipsNotification == v) return
  164. #endif
  165. notifications%SlipsNotification = v
  166. ! if(associated(notifications%SlipsNotificationPtr)) call notifications%SlipsNotificationPtr(notifications%SlipsNotification)
  167. #ifdef deb
  168. print*, 'notifications%SlipsNotification=', notifications%SlipsNotification
  169. #endif
  170. call notifications%OnSlipsNotificationChange%RunAll()
  171. end subroutine
  172. logical function Get_SlipsNotification()
  173. implicit none
  174. Get_SlipsNotification = notifications%SlipsNotification
  175. end function
  176. subroutine Set_OpenSafetyValveLed(v)
  177. use CDrillingConsoleVariables!, only: OpenSafetyValveLedHw => OpenSafetyValveLed
  178. use CManifolds, only: OpenSafetyValve_TopDrive, OpenSafetyValve_KellyMode, OpenSafetyValve_TripMode
  179. use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType
  180. implicit none
  181. logical , intent(in) :: v
  182. #ifdef ExcludeExtraChanges
  183. if(notifications%OpenSafetyValveLed == v) return
  184. #endif
  185. notifications%OpenSafetyValveLed = v
  186. if(notifications%OpenSafetyValveLed) then
  187. !!call OpenSafetyValve()
  188. if(Hoisting%DriveType == TopDrive_DriveType) call OpenSafetyValve_TopDrive()
  189. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_OpenSafetyValveLed == 0) call OpenSafetyValve_KellyMode()
  190. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_OpenSafetyValveLed == 1) call OpenSafetyValve_TripMode()
  191. endif
  192. call notifications%OnOpenSafetyValveLedChange%RunAll()
  193. end subroutine
  194. logical function Get_OpenSafetyValveLed()
  195. implicit none
  196. Get_OpenSafetyValveLed = notifications%OpenSafetyValveLed
  197. end function
  198. subroutine Set_OpenKellyCockLed(v)
  199. ! use CDrillingConsoleVariables!, only: OpenKellyCockLedHw => OpenKellyCockLed
  200. use CManifolds, only: OpenKellyCock
  201. implicit none
  202. logical , intent(in) :: v
  203. #ifdef ExcludeExtraChanges
  204. if(notifications%OpenKellyCockLed == v) return
  205. #endif
  206. notifications%OpenKellyCockLed = v
  207. if(notifications%OpenKellyCockLed) then
  208. call OpenKellyCock()
  209. endif
  210. ! HAS BEEN IMPLEMENTED IN CMANIFOLD
  211. !if(OpenKellyCockLed) then
  212. ! OpenKellyCockLedHw = 1
  213. !else
  214. ! OpenKellyCockLedHw = 0
  215. !endif
  216. call notifications%OnOpenKellyCockLedChange%RunAll()
  217. end subroutine
  218. logical function Get_OpenKellyCockLed()
  219. implicit none
  220. Get_OpenKellyCockLed = notifications%OpenKellyCockLed
  221. end function
  222. subroutine Set_LatchLed(v)
  223. use CDrillingConsoleVariables!, only: DrillingConsole%LatchPipeLED
  224. !use CUnlatchLedNotification
  225. implicit none
  226. logical , intent(in) :: v
  227. #ifdef ExcludeExtraChanges
  228. if(notifications%LatchLed == v) return
  229. #endif
  230. notifications%LatchLed = v
  231. if(notifications%LatchLed) then
  232. DrillingConsole%LatchPipeLED = 1
  233. !call Set_UnlatchLed(.false.)
  234. else
  235. DrillingConsole%LatchPipeLED = 0
  236. endif
  237. call notifications%OnLatchLedChange%RunAll()
  238. end subroutine
  239. logical function Get_LatchLed()
  240. implicit none
  241. Get_LatchLed = notifications%LatchLed
  242. end function
  243. subroutine Set_IrSafetyValveLed(v)
  244. use CDrillingConsoleVariables!, only: DrillingConsole%CloseKellyCockLed => IRSafetyValveLed
  245. use CManifolds, only: &
  246. InstallSafetyValve_TopDrive, &
  247. InstallSafetyValve_KellyMode, &
  248. InstallSafetyValve_TripMode, &
  249. RemoveSafetyValve_TopDrive, &
  250. RemoveSafetyValve_KellyMode, &
  251. RemoveSafetyValve_TripMode
  252. use UnitySignalVariables, only: Set_SafetyValve_Install, Set_SafetyValve_Remove
  253. use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType
  254. implicit none
  255. logical , intent(in) :: v
  256. #ifdef ExcludeExtraChanges
  257. if(notifications%IrSafetyValveLed == v) return
  258. #endif
  259. notifications%IrSafetyValveLed = v
  260. if(notifications%IrSafetyValveLed) then
  261. DrillingConsole%IRSafetyValveLed = 1
  262. if(Hoisting%DriveType == TopDrive_DriveType) call InstallSafetyValve_TopDrive()
  263. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 0) call InstallSafetyValve_KellyMode()
  264. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 1) call InstallSafetyValve_TripMode()
  265. call Set_SafetyValve_Install()
  266. else
  267. DrillingConsole%IRSafetyValveLed = 0
  268. if(Hoisting%DriveType == TopDrive_DriveType) call RemoveSafetyValve_TopDrive()
  269. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 0) call RemoveSafetyValve_KellyMode()
  270. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_IrSafetyValveLed == 1) call RemoveSafetyValve_TripMode()
  271. call Set_SafetyValve_Remove()
  272. endif
  273. call notifications%OnIrSafetyValveLedChange%RunAll()
  274. end subroutine
  275. logical function Get_IrSafetyValveLed()
  276. implicit none
  277. Get_IrSafetyValveLed = notifications%IrSafetyValveLed
  278. end function
  279. subroutine Set_IrIBopLed(v)
  280. use CDrillingConsoleVariables!, only: IRIBopLedHw => IRIBopLed
  281. use CManifolds, only: InstallIBop, RemoveIBop
  282. use UnitySignalVariables, only: Set_Ibop_Install, Set_Ibop_Remove
  283. implicit none
  284. logical , intent(in) :: v
  285. #ifdef ExcludeExtraChanges
  286. if(notifications%IrIBopLed == v) return
  287. #endif
  288. notifications%IrIBopLed = v
  289. if(notifications%IrIBopLed) then
  290. DrillingConsole%IRIBopLed = 1
  291. call InstallIBop()
  292. call Set_Ibop_Install()
  293. else
  294. DrillingConsole%IRIBopLed = 0
  295. call RemoveIBop()
  296. call Set_Ibop_Remove()
  297. endif
  298. call notifications%OnIrIBopLedChange%RunAll()
  299. end subroutine
  300. logical function Get_IrIBopLed()
  301. implicit none
  302. Get_IrIBopLed = notifications%IrIBopLed
  303. end function
  304. subroutine Set_FillMouseHoleLed(v)
  305. use CDrillingConsoleVariables!, only: FillMouseHoleLedHw => FillMouseHoleLed
  306. ! use CMouseHoleEnumVariables
  307. use UnitySignalVariables
  308. implicit none
  309. logical , intent(in) :: v
  310. #ifdef ExcludeExtraChanges
  311. if(notifications%FillMouseHoleLed == v) return
  312. #endif
  313. notifications%FillMouseHoleLed = v
  314. if(notifications%FillMouseHoleLed) then
  315. DrillingConsole%FillMouseHoleLed = 1
  316. !call Set_MouseHole(MOUSE_HOLE_FILL)
  317. else
  318. DrillingConsole%FillMouseHoleLed = 0
  319. !call Set_MouseHole(MOUSE_HOLE_EMPTY)
  320. endif
  321. call notifications%OnFillMouseHoleLedChange%RunAll()
  322. end subroutine
  323. logical function Get_FillMouseHoleLed()
  324. implicit none
  325. Get_FillMouseHoleLed = notifications%FillMouseHoleLed
  326. end function
  327. subroutine Set_CloseKellyCockLed(v)
  328. use CDrillingConsoleVariables!, only: CloseKellyCockLedHw => CloseKellyCockLed
  329. use CManifolds, only: CloseKellyCock
  330. implicit none
  331. logical , intent(in) :: v
  332. #ifdef ExcludeExtraChanges
  333. if(notifications%CloseKellyCockLed == v) return
  334. #endif
  335. notifications%CloseKellyCockLed = v
  336. if(notifications%CloseKellyCockLed) then
  337. call CloseKellyCock()
  338. endif
  339. call notifications%OnCloseKellyCockLedChange%RunAll()
  340. end subroutine
  341. logical function Get_CloseKellyCockLed()
  342. implicit none
  343. Get_CloseKellyCockLed = notifications%CloseKellyCockLed
  344. end function
  345. subroutine Set_CloseSafetyValveLed(v)
  346. ! use CDrillingConsoleVariables, only: CloseSafetyValveLedHw => CloseSafetyValveLed
  347. use CManifolds, only: CloseSafetyValve_TopDrive, CloseSafetyValve_KellyMode, CloseSafetyValve_TripMode
  348. use CHoistingVariables!, only: Hoisting%DriveType, TopDrive_DriveType, Kelly_DriveType
  349. implicit none
  350. logical , intent(in) :: v
  351. #ifdef ExcludeExtraChanges
  352. if(notifications%CloseSafetyValveLed == v) return
  353. #endif
  354. notifications%CloseSafetyValveLed = v
  355. if(notifications%CloseSafetyValveLed) then
  356. !!call CloseSafetyValve()
  357. if(Hoisting%DriveType == TopDrive_DriveType) call CloseSafetyValve_TopDrive()
  358. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_CloseSafetyValveLed == 0) call CloseSafetyValve_KellyMode()
  359. if(Hoisting%DriveType == Kelly_DriveType .and. notifications%operation_CloseSafetyValveLed == 1) call CloseSafetyValve_TripMode()
  360. endif
  361. call notifications%OnCloseSafetyValveLedChange%RunAll()
  362. end subroutine
  363. logical function Get_CloseSafetyValveLed()
  364. implicit none
  365. Get_CloseSafetyValveLed = notifications%CloseSafetyValveLed
  366. end function
  367. end module NotificationVariables