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.
 
 
 
 
 
 

490 lines
14 KiB

  1. module UnitySignalsModule
  2. use UnitySignalVariables
  3. use SimulationVariables
  4. contains
  5. subroutine Set_TdsElevatorModes(v)
  6. implicit none
  7. integer , intent(in) :: v
  8. #ifdef ExcludeExtraChanges
  9. if(data%State%unitySignals%TdsElevatorModes == v) return
  10. #endif
  11. data%State%unitySignals%TdsElevatorModes = v
  12. !**call TdsElevatorModesEnum%OnTdsElevatorModesChange%RunAll()
  13. end subroutine
  14. integer function Get_TdsElevatorModes()
  15. implicit none
  16. Get_TdsElevatorModes = data%State%unitySignals%TdsElevatorModes
  17. end function
  18. subroutine Set_Ibop_Install()
  19. implicit none
  20. call Set_Ibop(IBOP_INSTALL)
  21. end subroutine
  22. subroutine Set_Ibop_Remove()
  23. implicit none
  24. call Set_Ibop(IBOP_REMOVE)
  25. end subroutine
  26. subroutine Set_Tong(v)
  27. implicit none
  28. integer , intent(in) :: v
  29. #ifdef ExcludeExtraChanges
  30. if(data%State%unitySignals%Tong == v) return
  31. #endif
  32. data%State%unitySignals%Tong = v
  33. #ifdef deb
  34. print*, 'Tong=', data%State%unitySignals%Tong
  35. #endif
  36. !**call data%State%unitySignals%OnTongChange%RunAll()
  37. end subroutine
  38. integer function Get_Tong()
  39. implicit none
  40. Get_Tong = data%State%unitySignals%Tong
  41. end function
  42. subroutine Set_TdsTong(v)
  43. implicit none
  44. integer , intent(in) :: v
  45. #ifdef ExcludeExtraChanges
  46. if(data%State%unitySignals%TdsTong == v) return
  47. #endif
  48. data%State%unitySignals%TdsTong = v
  49. #ifdef deb
  50. print*, 'TdsTong=', data%State%unitySignals%TdsTong
  51. #endif
  52. !**call data%State%unitySignals%OnTdsTongChange%RunAll()
  53. end subroutine
  54. integer function Get_TdsTong()
  55. implicit none
  56. Get_TdsTong = data%State%unitySignals%TdsTong
  57. end function
  58. subroutine Set_TdsSwing(v)
  59. implicit none
  60. integer , intent(in) :: v
  61. #ifdef ExcludeExtraChanges
  62. if(data%State%unitySignals%TdsSwing == v) return
  63. #endif
  64. data%State%unitySignals%TdsSwing = v
  65. #ifdef deb
  66. print*, 'TdsSwing=', data%State%unitySignals%TdsSwing
  67. #endif
  68. !**call data%State%unitySignals%OnTdsSwingChange%RunAll()
  69. end subroutine
  70. integer function Get_TdsSwing()
  71. implicit none
  72. Get_TdsSwing = data%State%unitySignals%TdsSwing
  73. end function
  74. subroutine Set_TdsSpine(v)
  75. implicit none
  76. integer , intent(in) :: v
  77. #ifdef ExcludeExtraChanges
  78. if(data%State%unitySignals%TdsSpine == v) return
  79. #endif
  80. data%State%unitySignals%TdsSpine = v
  81. #ifdef deb
  82. print*, 'TdsSpine=', data%State%unitySignals%TdsSpine
  83. #endif
  84. !**call data%State%unitySignals%OnTdsSpineChange%RunAll()
  85. end subroutine
  86. integer function Get_TdsSpine()
  87. implicit none
  88. Get_TdsSpine = data%State%unitySignals%TdsSpine
  89. end function
  90. subroutine Set_TdsBackupClamp(v)
  91. implicit none
  92. integer , intent(in) :: v
  93. #ifdef ExcludeExtraChanges
  94. if(data%State%unitySignals%TdsBackupClamp == v) return
  95. #endif
  96. data%State%unitySignals%TdsBackupClamp = v
  97. #ifdef deb
  98. print*, 'TdsBackupClamp=', data%State%unitySignals%TdsBackupClamp
  99. #endif
  100. !**call data%State%unitySignals%OnTdsBackupClampChange%RunAll()
  101. end subroutine
  102. integer function Get_TdsBackupClamp()
  103. implicit none
  104. Get_TdsBackupClamp = data%State%unitySignals%TdsBackupClamp
  105. end function
  106. subroutine Set_Swing(v)
  107. implicit none
  108. integer , intent(in) :: v
  109. #ifdef ExcludeExtraChanges
  110. if(data%State%unitySignals%Swing == v) return
  111. #endif
  112. data%State%unitySignals%Swing = v
  113. #ifdef deb
  114. print*, 'Swing=', data%State%unitySignals%Swing
  115. #endif
  116. !**call data%State%unitySignals%OnSwingChange%RunAll()
  117. end subroutine
  118. integer function Get_Swing()
  119. implicit none
  120. Get_Swing = data%State%unitySignals%Swing
  121. end function
  122. subroutine Set_Slips(v)
  123. implicit none
  124. integer , intent(in) :: v
  125. #ifdef ExcludeExtraChanges
  126. if(data%State%unitySignals%Slips == v) return
  127. #endif
  128. data%State%unitySignals%Slips = v
  129. #ifdef deb
  130. print*, 'Slips=', data%State%unitySignals%Slips
  131. #endif
  132. !**call data%State%unitySignals%OnSlipsChange%RunAll()
  133. end subroutine
  134. integer function Get_Slips()
  135. implicit none
  136. Get_Slips = data%State%unitySignals%Slips
  137. end function
  138. subroutine Set_Operation(i)
  139. implicit none
  140. integer, intent (in) :: i
  141. data%State%unitySignals%operation = i
  142. end subroutine
  143. subroutine Set_SafetyValve(v)
  144. implicit none
  145. integer , intent(in) :: v
  146. #ifdef ExcludeExtraChanges
  147. if(data%State%unitySignals%SafetyValve == v) return
  148. #endif
  149. data%State%unitySignals%SafetyValve = v
  150. #ifdef deb
  151. if(data%State%unitySignals%SafetyValve == SAFETY_VALVE_NEUTRAL) then
  152. print*, 'SafetyValve=SAFETY_VALVE_NEUTRAL'
  153. else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then
  154. print*, 'SafetyValve=SAFETY_VALVE_INSTALL'
  155. else if (data%State%unitySignals%SafetyValve == SAFETY_VALVE_INSTALL) then
  156. print*, 'SafetyValve=SAFETY_VALVE_REMOVE'
  157. endif
  158. #endif
  159. !**call data%State%unitySignals%OnSafetyValveChange%RunAll()
  160. end subroutine
  161. integer function Get_SafetyValve()
  162. implicit none
  163. Get_SafetyValve = data%State%unitySignals%SafetyValve
  164. end function
  165. subroutine Set_SafetyValve_Install()
  166. implicit none
  167. call Set_SafetyValve(SAFETY_VALVE_INSTALL)
  168. end subroutine
  169. subroutine Set_SafetyValve_Remove()
  170. implicit none
  171. call Set_SafetyValve(SAFETY_VALVE_REMOVE)
  172. end subroutine
  173. subroutine Set_OperationCondition(v)
  174. ! use CKellyEnumVariables
  175. implicit none
  176. integer , intent(in) :: v
  177. #ifdef ExcludeExtraChanges
  178. if(data%State%unitySignals%OperationCondition == v) return
  179. #endif
  180. data%State%unitySignals%OperationCondition = v
  181. #ifdef deb
  182. print*, 'OperationCondition=', data%State%unitySignals%OperationCondition
  183. #endif
  184. !**call data%State%unitySignals%OnOperationConditionChange%RunAll()
  185. !**call data%State%unitySignals%OnOperationConditionChangeInt%RunAll(data%State%unitySignals%OperationCondition)
  186. end subroutine
  187. integer function Get_OperationCondition()
  188. implicit none
  189. Get_OperationCondition = data%State%unitySignals%OperationCondition
  190. end function
  191. subroutine Evaluate_OperationCondition()
  192. implicit none
  193. end subroutine
  194. subroutine Set_MouseHole(v)
  195. implicit none
  196. integer , intent(in) :: v
  197. #ifdef ExcludeExtraChanges
  198. if(data%State%unitySignals%MouseHole == v) return
  199. #endif
  200. !call sleep(2)
  201. data%State%unitySignals%MouseHole = v
  202. #ifdef deb
  203. print*, 'MouseHole=', data%State%unitySignals%MouseHole
  204. #endif
  205. !**call data%State%unitySignals%OnMouseHoleChange%RunAll()
  206. end subroutine
  207. integer function Get_MouseHole()
  208. implicit none
  209. Get_MouseHole = data%State%unitySignals%MouseHole
  210. end function
  211. subroutine Set_Kelly(v)
  212. implicit none
  213. integer , intent(in) :: v
  214. #ifdef ExcludeExtraChanges
  215. if(data%State%unitySignals%Kelly == v) return
  216. #endif
  217. data%State%unitySignals%Kelly = v
  218. #ifdef deb
  219. print*, 'Kelly=', data%State%unitySignals%Kelly
  220. #endif
  221. !**call data%State%unitySignals%OnKellyChange%RunAll()
  222. end subroutine
  223. integer function Get_Kelly()
  224. implicit none
  225. Get_Kelly = data%State%unitySignals%Kelly
  226. end function
  227. subroutine Set_Ibop(v)
  228. implicit none
  229. integer , intent(in) :: v
  230. #ifdef ExcludeExtraChanges
  231. if(data%State%unitySignals%Ibop == v) return
  232. #endif
  233. data%State%unitySignals%Ibop = v
  234. #ifdef deb
  235. print*, 'Ibop=', data%State%unitySignals%Ibop
  236. #endif
  237. !**call data%State%unitySignals%OnIbopChange%RunAll()
  238. end subroutine
  239. integer function Get_Ibop()
  240. implicit none
  241. Get_Ibop = data%State%unitySignals%Ibop
  242. end function
  243. subroutine Set_FillupHead(v)
  244. use CManifolds, only: ToggleFillupHead
  245. implicit none
  246. integer , intent(in) :: v
  247. #ifdef ExcludeExtraChanges
  248. if(data%State%unitySignals%FillupHead == v) return
  249. #endif
  250. data%State%unitySignals%FillupHead = v
  251. if (data%State%unitySignals%FillupHead == FILLUP_HEAD_INSTALL) then
  252. call ToggleFillupHead(.true.)
  253. else if (data%State%unitySignals%FillupHead == FILLUP_HEAD_REMOVE) then
  254. call ToggleFillupHead(.false.)
  255. endif
  256. #ifdef deb
  257. print*, 'FillupHead=', data%State%unitySignals%FillupHead
  258. #endif
  259. !**call data%State%unitySignals%OnFillupHeadChange%RunAll()
  260. end subroutine
  261. integer function Get_FillupHead()
  262. implicit none
  263. Get_FillupHead = data%State%unitySignals%FillupHead
  264. end function
  265. subroutine Evaluate_FillupHead()
  266. use CHoistingVariables
  267. use SimulationVariables
  268. use CStudentStationVariables!, only: data%State%StudentStation%FillupHeadInstallation
  269. implicit none
  270. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  271. #ifdef OST
  272. print*, 'Evaluate_FillupHead=TopDrive'
  273. #endif
  274. endif
  275. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  276. #ifdef OST
  277. print*, 'Evaluate_FillupHead=Kelly'
  278. #endif
  279. endif
  280. if (Get_FillupHead() == FILLUP_HEAD_INSTALL) then
  281. data%State%StudentStation%FillupHeadInstallation = .true.
  282. else if (Get_FillupHead() == FILLUP_HEAD_REMOVE) then
  283. data%State%StudentStation%FillupHeadInstallation = .false.
  284. endif
  285. end subroutine
  286. subroutine Set_Elevator(v)
  287. implicit none
  288. integer , intent(in) :: v
  289. #ifdef ExcludeExtraChanges
  290. if(data%State%unitySignals%Elevator == v) return
  291. #endif
  292. data%State%unitySignals%Elevator = v
  293. #ifdef deb
  294. print*, 'Elevator=', data%State%unitySignals%Elevator
  295. #endif
  296. !**call data%State%unitySignals%OnElevatorChange%RunAll()
  297. end subroutine
  298. integer function Get_Elevator()
  299. implicit none
  300. Get_Elevator = data%State%unitySignals%Elevator
  301. end function
  302. subroutine Set_MudBucket(v)
  303. use CManifolds, only: ToggleMudBox
  304. implicit none
  305. integer , intent(in) :: v
  306. #ifdef ExcludeExtraChanges
  307. if(data%State%unitySignals%MudBucket == v) return
  308. #endif
  309. data%State%unitySignals%MudBucket = v
  310. if (data%State%unitySignals%MudBucket == MUD_BUCKET_INSTALL) then
  311. call ToggleMudBox(.true.)
  312. else if (data%State%unitySignals%MudBucket == MUD_BUCKET_REMOVE) then
  313. call ToggleMudBox(.false.)
  314. endif
  315. #ifdef deb
  316. print*, 'MudBucket=', data%State%unitySignals%MudBucket
  317. #endif
  318. !**call data%State%unitySignals%OnMudBucketChange%RunAll()
  319. end subroutine
  320. integer function Get_MudBucket()
  321. implicit none
  322. Get_MudBucket = data%State%unitySignals%MudBucket
  323. end function
  324. subroutine Evaluate_MudBucket()
  325. use CStudentStationVariables!, only: data%State%StudentStation%MudBoxInstallation
  326. implicit none
  327. if (Get_MudBucket() == MUD_BUCKET_INSTALL) then
  328. data%State%StudentStation%MudBoxInstallation = .true.
  329. else if (Get_MudBucket() == MUD_BUCKET_REMOVE) then
  330. data%State%StudentStation%MudBoxInstallation = .false.
  331. endif
  332. end subroutine
  333. !! Moved from CTdsConnectionModeEnum
  334. subroutine Set_TdsConnectionModes(v)
  335. use CManifolds, Only: KellyConnected, KellyDisconnected
  336. implicit none
  337. integer , intent(in) :: v
  338. #ifdef ExcludeExtraChanges
  339. if(data%State%unitySignals%TdsConnectionModes == v) return
  340. #endif
  341. data%State%unitySignals%TdsConnectionModes = v
  342. if(data%State%unitySignals%TdsConnectionModes == TDS_CONNECTION_NOTHING) then
  343. call KellyDisconnected()
  344. else
  345. call KellyConnected()
  346. endif
  347. #ifdef deb
  348. print*, 'data%State%unitySignals%TdsConnectionModes=', data%State%unitySignals%TdsConnectionModes
  349. #endif
  350. !**call data%State%unitySignals%OnTdsConnectionModesChange%RunAll()
  351. end subroutine
  352. integer function Get_TdsConnectionModes()
  353. use SimulationVariables
  354. implicit none
  355. Get_TdsConnectionModes = data%State%unitySignals%TdsConnectionModes
  356. end function
  357. subroutine Evaluate_TdsConnectionModes()
  358. use CUnityInputs
  359. use SimulationVariables
  360. implicit none
  361. if (data%Configuration%Hoisting%DriveType == TopDrive_DriveType) then
  362. #ifdef OST
  363. print*, 'Evaluate_TdsConnectionModes=TopDrive'
  364. #endif
  365. !TOPDRIVE-CODE=3
  366. if (Get_TdsStemIn() .and.&
  367. Get_TdsSpine() == TDS_SPINE_CONNECT_END .and.&
  368. !TopDriveDrillTorqueState == TdsMu_SPINE
  369. Get_TdsConnectionModes() == TDS_CONNECTION_NOTHING) then
  370. call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
  371. return
  372. end if
  373. !TOPDRIVE-CODE=4
  374. if (Get_TdsTong() == TDS_TONG_MAKEUP_END .and.&
  375. Get_TdsConnectionModes() == TDS_CONNECTION_SPINE ) then
  376. call Set_TdsConnectionModes(TDS_CONNECTION_STRING)
  377. data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
  378. return
  379. end if
  380. !TOPDRIVE-CODE=5
  381. if (Get_TdsTong() == TDS_TONG_BREAKOUT_END .and.&
  382. Get_TdsConnectionModes() == TDS_CONNECTION_STRING ) then
  383. call Set_TdsConnectionModes(TDS_CONNECTION_SPINE)
  384. data%EquipmentControl%TopDrivePanel%TopDriveTorqueWrenchLed = LED_OFF
  385. return
  386. end if
  387. !TOPDRIVE-CODE=6
  388. if (Get_TdsSpine() == TDS_SPINE_DISCONNECT_END .and.&
  389. !Get_TdsStemIn() == .false. .and.&
  390. Get_TdsConnectionModes() == TDS_CONNECTION_SPINE) then
  391. call Set_TdsConnectionModes(TDS_CONNECTION_NOTHING)
  392. return
  393. end if
  394. endif
  395. if (data%Configuration%Hoisting%DriveType == Kelly_DriveType) then
  396. #ifdef OST
  397. print*, 'Evaluate_TdsConnectionModes=Kelly'
  398. #endif
  399. endif
  400. end subroutine
  401. end module UnitySignalsModule