Simulation Core
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

PumpsMain.f90 28 KiB

hace 1 año
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. module PumpsMain
  2. use CPumpsVariables
  3. use CDrillingConsoleVariables
  4. use CDataDisplayConsoleVariables
  5. use CSimulationVariables
  6. use Pump_VARIABLES
  7. use CSounds
  8. implicit none
  9. public
  10. contains
  11. ! ****************************************
  12. ! ***** subroutine Pump1MainBody *****
  13. ! ****************************
  14. subroutine Pump1_Setup()
  15. use CSimulationVariables
  16. implicit none
  17. call OnSimulationInitialization%Add(Pump1_Init)
  18. call OnSimulationStop%Add(Pump1_Init)
  19. call OnPump1Step%Add(Pump1_Step)
  20. call OnPump1Output%Add(Pump1_Output)
  21. call OnPump1Main%Add(Pump1MainBody)
  22. end subroutine
  23. subroutine Pump1_Init
  24. implicit none
  25. end subroutine Pump1_Init
  26. !!Extracted from pump1MainBody
  27. subroutine Pump1_Step
  28. use CWarningsVariables
  29. integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  30. INTEGER :: MP_SolDuration
  31. if (PUMP(1)%PowerFailMalf==1) then
  32. !MP1BLWR=0
  33. Call Pump1_OffMode_Solver(1)
  34. Call ClosePump1()
  35. end if
  36. ! Pump1 Warning ----> Failure
  37. if (Pump1Failure==1) then
  38. !MP1BLWR=0
  39. Call Pump1_OffMode_Solver(1)
  40. Call ClosePump1()
  41. end if
  42. ! Pump3 Malfunction ----> Power Failure
  43. if (PUMP(3)%PowerFailMalf==1) then
  44. Call Pump3_OffMode_Solver
  45. !Call ClosePump3()
  46. end if
  47. ! Pump3 Warning ----> Failure
  48. if (Pump3Failure==1) then
  49. Call Pump3_OffMode_Solver
  50. !Call ClosePump3()
  51. end if
  52. !print*, 'MP1Throttle=', MP1Throttle
  53. if (IsPortable) then
  54. PUMP(1)%AssignmentSwitchh = 1
  55. else
  56. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  57. end if
  58. if((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (MP1CPSwitch==-1) .and. (MP1Throttle==0.) .and. (PUMP(1)%PowerFailMalf==0)) then
  59. !print*, 'pumps on'
  60. !print*, 'PUMP(1)%AssignmentSwitchh=' , PUMP(1)%AssignmentSwitchh
  61. PUMP(1)%SoundBlower = .true.
  62. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  63. MP1BLWR = 1
  64. loop2: do
  65. Call DrillingConsole_ScrLEDs
  66. Call Pump_Total_Counts
  67. Call DATE_AND_TIME(values=MP_START_TIME)
  68. ! Pump1 Malfunction ----> Power Failure
  69. if (PUMP(1)%PowerFailMalf==1) then
  70. !MP1BLWR=0
  71. Call Pump1_OffMode_Solver(1)
  72. Call ClosePump1()
  73. exit loop2
  74. end if
  75. ! Pump1 Warning ----> Failure
  76. if (Pump1Failure==1) then
  77. !MP1BLWR=0
  78. Call Pump1_OffMode_Solver(1)
  79. Call ClosePump1()
  80. exit loop2
  81. end if
  82. PUMP(1)%N_new = MP1Throttle
  83. if (((PUMP(1)%N_new-PUMP(1)%N_old)/PUMP(1)%time_step)>193.) then
  84. PUMP(1)%N_ref =(193.*PUMP(1)%time_step)+PUMP(1)%N_old
  85. else if (((PUMP(1)%N_old-PUMP(1)%N_new)/PUMP(1)%time_step)>193.) then
  86. PUMP(1)%N_ref = (-193.*PUMP(1)%time_step)+PUMP(1)%N_old
  87. else
  88. PUMP(1)%N_ref = PUMP(1)%N_new
  89. end if
  90. !print*, 'PUMP(1)%N_ref=' , PUMP(1)%N_ref , MP1Throttle
  91. Call Pump1_OnMode_Solver(1)
  92. !IF (PUMP(1)%Flow_Rate>0.) Then
  93. ! Call OpenPump1()
  94. !Else
  95. ! Call ClosePump1()
  96. !End if
  97. PUMP(1)%N_old = PUMP(1)%N_ref
  98. Call DATE_AND_TIME(values=MP_END_TIME)
  99. MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  100. !print*, 'MPtime=', MP_SolDuration
  101. if(MP_SolDuration > 0.0) then
  102. Call sleepqq(MP_SolDuration)
  103. end if
  104. if (IsPortable) then
  105. PUMP(1)%AssignmentSwitchh = 1
  106. else
  107. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  108. end if
  109. if ((any(PUMP(1)%AssignmentSwitchh==(/5,6,7,8,11,12/))) .or. (MP1CPSwitch/=-1) .or. (IsStopped == .true.)) then
  110. PUMP(1)%SoundBlower = .false.
  111. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  112. MP1BLWR = 0
  113. Call Pump1_OffMode_Solver(1)
  114. Call ClosePump1()
  115. exit loop2
  116. end if
  117. end do loop2
  118. else if( (MP1CPSwitch==1) .and. (MP1Throttle==0.) .and. (PUMP(3)%PowerFailMalf==0) ) then
  119. loop3: do
  120. Call DATE_AND_TIME(values=MP_START_TIME)
  121. !print*, 'PUMP(3) is on'
  122. ! Pump3 Malfunction ----> Power Failure
  123. if (PUMP(3)%PowerFailMalf==1) then
  124. Call Pump3_OffMode_Solver
  125. !Call ClosePump3()
  126. exit loop3
  127. end if
  128. ! Pump3 Warning ----> Failure
  129. if (Pump3Failure==1) then
  130. !MP1BLWR=0
  131. Call Pump3_OffMode_Solver
  132. !Call ClosePump3() !?????????????
  133. exit loop3
  134. end if
  135. PUMP(3)%N_new = MP1Throttle
  136. if (((PUMP(3)%N_new-PUMP(3)%N_old)/PUMP(3)%time_step)>193.) then
  137. PUMP(3)%N_ref =(193.*PUMP(3)%time_step)+PUMP(3)%N_old
  138. else if (((PUMP(3)%N_old-PUMP(3)%N_new)/PUMP(3)%time_step)>193.) then
  139. PUMP(3)%N_ref = (-193.*PUMP(3)%time_step)+PUMP(3)%N_old
  140. else
  141. PUMP(3)%N_ref = PUMP(3)%N_new
  142. end if
  143. Call Pump3_OnMode_Solver
  144. IF (PUMP(3)%Flow_Rate>0.) Then
  145. Call OpenCementPump()
  146. Else
  147. Call CloseCementPump()
  148. End if
  149. PUMP(3)%N_old = PUMP(3)%N_ref
  150. Call DATE_AND_TIME(values=MP_END_TIME)
  151. MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  152. !print*, 'MPtime=', MP_SolDuration
  153. if(MP_SolDuration > 0.0) then
  154. Call sleepqq(MP_SolDuration)
  155. end if
  156. if ((MP1CPSwitch/=1) .or. (IsStopped == .true.)) then
  157. Call Pump3_OffMode_Solver
  158. Call CloseCementPump()
  159. exit loop3
  160. end if
  161. end do loop3
  162. else
  163. !print*, 'pumps off'
  164. if (IsPortable) then
  165. PUMP(1)%AssignmentSwitchh = 1
  166. !print*, 'PUMP(1)%AssignmentSwitchh2=' , PUMP(1)%AssignmentSwitchh
  167. else
  168. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  169. !print*, 'PUMP(1)%AssignmentSwitchh22=' , PUMP(1)%AssignmentSwitchh , AssignmentSwitch
  170. end if
  171. if ((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (MP1CPSwitch==-1)) then
  172. PUMP(1)%SoundBlower = .true.
  173. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  174. MP1BLWR = 1
  175. else
  176. PUMP(1)%SoundBlower = .false.
  177. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  178. MP1BLWR = 0
  179. end if
  180. Call Pump1_OffMode_Solver(1)
  181. Call ClosePump1()
  182. Call Pump3_OffMode_Solver
  183. Call CloseCementPump()
  184. !print*, 'PUMP(1)%off=', PUMP(1)%dt , PUMP(1)%ia , PUMP(1)%w , PUMP(1)%n , PUMP(1)%x
  185. end if
  186. end subroutine Pump1_Step
  187. subroutine Pump1_Output
  188. implicit none
  189. end subroutine Pump1_Output
  190. subroutine Pump1MainBody
  191. use ifport
  192. use ifmt
  193. use CWarningsVariables
  194. !use equipments_PowerLimit
  195. implicit none
  196. integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  197. INTEGER :: MP_SolDuration
  198. Call Pump_StartUp
  199. loop1 : do
  200. Call sleepqq(10)
  201. Call DrillingConsole_ScrLEDs
  202. !Call Pump_Total_Counts
  203. ! Pump1 Malfunction ----> Power Failure
  204. if (PUMP(1)%PowerFailMalf==1) then
  205. !MP1BLWR=0
  206. Call Pump1_OffMode_Solver(1)
  207. Call ClosePump1()
  208. end if
  209. ! Pump1 Warning ----> Failure
  210. if (Pump1Failure==1) then
  211. !MP1BLWR=0
  212. Call Pump1_OffMode_Solver(1)
  213. Call ClosePump1()
  214. end if
  215. ! Pump3 Malfunction ----> Power Failure
  216. if (PUMP(3)%PowerFailMalf==1) then
  217. Call Pump3_OffMode_Solver
  218. !Call ClosePump3()
  219. end if
  220. ! Pump3 Warning ----> Failure
  221. if (Pump3Failure==1) then
  222. Call Pump3_OffMode_Solver
  223. !Call ClosePump3()
  224. end if
  225. !print*, 'MP1Throttle=', MP1Throttle
  226. if (IsPortable) then
  227. PUMP(1)%AssignmentSwitchh = 1
  228. else
  229. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  230. end if
  231. if((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (MP1CPSwitch==-1) .and. (MP1Throttle==0.) .and. (PUMP(1)%PowerFailMalf==0)) then
  232. !print*, 'pumps on'
  233. !print*, 'PUMP(1)%AssignmentSwitchh=' , PUMP(1)%AssignmentSwitchh
  234. PUMP(1)%SoundBlower = .true.
  235. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  236. MP1BLWR = 1
  237. loop2: do
  238. Call DrillingConsole_ScrLEDs
  239. Call Pump_Total_Counts
  240. Call DATE_AND_TIME(values=MP_START_TIME)
  241. ! Pump1 Malfunction ----> Power Failure
  242. if (PUMP(1)%PowerFailMalf==1) then
  243. !MP1BLWR=0
  244. Call Pump1_OffMode_Solver(1)
  245. Call ClosePump1()
  246. exit loop2
  247. end if
  248. ! Pump1 Warning ----> Failure
  249. if (Pump1Failure==1) then
  250. !MP1BLWR=0
  251. Call Pump1_OffMode_Solver(1)
  252. Call ClosePump1()
  253. exit loop2
  254. end if
  255. PUMP(1)%N_new = MP1Throttle
  256. if (((PUMP(1)%N_new-PUMP(1)%N_old)/PUMP(1)%time_step)>193.) then
  257. PUMP(1)%N_ref =(193.*PUMP(1)%time_step)+PUMP(1)%N_old
  258. else if (((PUMP(1)%N_old-PUMP(1)%N_new)/PUMP(1)%time_step)>193.) then
  259. PUMP(1)%N_ref = (-193.*PUMP(1)%time_step)+PUMP(1)%N_old
  260. else
  261. PUMP(1)%N_ref = PUMP(1)%N_new
  262. end if
  263. !print*, 'PUMP(1)%N_ref=' , PUMP(1)%N_ref , MP1Throttle
  264. Call Pump1_OnMode_Solver(1)
  265. !IF (PUMP(1)%Flow_Rate>0.) Then
  266. ! Call OpenPump1()
  267. !Else
  268. ! Call ClosePump1()
  269. !End if
  270. PUMP(1)%N_old = PUMP(1)%N_ref
  271. Call DATE_AND_TIME(values=MP_END_TIME)
  272. MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  273. !print*, 'MPtime=', MP_SolDuration
  274. if(MP_SolDuration > 0.0) then
  275. Call sleepqq(MP_SolDuration)
  276. end if
  277. if (IsPortable) then
  278. PUMP(1)%AssignmentSwitchh = 1
  279. else
  280. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  281. end if
  282. if ((any(PUMP(1)%AssignmentSwitchh==(/5,6,7,8,11,12/))) .or. (MP1CPSwitch/=-1) .or. (IsStopped == .true.)) then
  283. PUMP(1)%SoundBlower = .false.
  284. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  285. MP1BLWR = 0
  286. Call Pump1_OffMode_Solver(1)
  287. Call ClosePump1()
  288. exit loop2
  289. end if
  290. end do loop2
  291. else if( (MP1CPSwitch==1) .and. (MP1Throttle==0.) .and. (PUMP(3)%PowerFailMalf==0) ) then
  292. loop3: do
  293. Call DATE_AND_TIME(values=MP_START_TIME)
  294. !print*, 'PUMP(3) is on'
  295. ! Pump3 Malfunction ----> Power Failure
  296. if (PUMP(3)%PowerFailMalf==1) then
  297. Call Pump3_OffMode_Solver
  298. !Call ClosePump3()
  299. exit loop3
  300. end if
  301. ! Pump3 Warning ----> Failure
  302. if (Pump3Failure==1) then
  303. !MP1BLWR=0
  304. Call Pump3_OffMode_Solver
  305. !Call ClosePump3() !?????????????
  306. exit loop3
  307. end if
  308. PUMP(3)%N_new = MP1Throttle
  309. if (((PUMP(3)%N_new-PUMP(3)%N_old)/PUMP(3)%time_step)>193.) then
  310. PUMP(3)%N_ref =(193.*PUMP(3)%time_step)+PUMP(3)%N_old
  311. else if (((PUMP(3)%N_old-PUMP(3)%N_new)/PUMP(3)%time_step)>193.) then
  312. PUMP(3)%N_ref = (-193.*PUMP(3)%time_step)+PUMP(3)%N_old
  313. else
  314. PUMP(3)%N_ref = PUMP(3)%N_new
  315. end if
  316. Call Pump3_OnMode_Solver
  317. IF (PUMP(3)%Flow_Rate>0.) Then
  318. Call OpenCementPump()
  319. Else
  320. Call CloseCementPump()
  321. End if
  322. PUMP(3)%N_old = PUMP(3)%N_ref
  323. Call DATE_AND_TIME(values=MP_END_TIME)
  324. MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  325. !print*, 'MPtime=', MP_SolDuration
  326. if(MP_SolDuration > 0.0) then
  327. Call sleepqq(MP_SolDuration)
  328. end if
  329. if ((MP1CPSwitch/=1) .or. (IsStopped == .true.)) then
  330. Call Pump3_OffMode_Solver
  331. Call CloseCementPump()
  332. exit loop3
  333. end if
  334. end do loop3
  335. else
  336. !print*, 'pumps off'
  337. if (IsPortable) then
  338. PUMP(1)%AssignmentSwitchh = 1
  339. !print*, 'PUMP(1)%AssignmentSwitchh2=' , PUMP(1)%AssignmentSwitchh
  340. else
  341. PUMP(1)%AssignmentSwitchh = AssignmentSwitch
  342. !print*, 'PUMP(1)%AssignmentSwitchh22=' , PUMP(1)%AssignmentSwitchh , AssignmentSwitch
  343. end if
  344. if ((any(PUMP(1)%AssignmentSwitchh==(/1,2,3,4,9,10/))) .and. (MP1CPSwitch==-1)) then
  345. PUMP(1)%SoundBlower = .true.
  346. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  347. MP1BLWR = 1
  348. else
  349. PUMP(1)%SoundBlower = .false.
  350. Call SetSoundBlowerMP1(PUMP(1)%SoundBlower)
  351. MP1BLWR = 0
  352. end if
  353. Call Pump1_OffMode_Solver(1)
  354. Call ClosePump1()
  355. Call Pump3_OffMode_Solver
  356. Call CloseCementPump()
  357. !print*, 'PUMP(1)%off=', PUMP(1)%dt , PUMP(1)%ia , PUMP(1)%w , PUMP(1)%n , PUMP(1)%x
  358. end if
  359. if (IsStopped == .true.) then
  360. exit loop1
  361. end if
  362. end do loop1
  363. end subroutine Pump1MainBody
  364. ! ****************************************
  365. ! ***** subroutine Pump2MainBody *****
  366. ! ****************************
  367. subroutine Pump2_Setup()
  368. use CSimulationVariables
  369. implicit none
  370. call OnSimulationInitialization%Add(Pump2_Init)
  371. call OnSimulationStop%Add(Pump2_Init)
  372. call OnPump2Step%Add(Pump2_Step)
  373. call OnPump2Output%Add(Pump2_Output)
  374. call OnPump2Main%Add(Pump2MainBody)
  375. end subroutine
  376. subroutine Pump2_Init
  377. implicit none
  378. end subroutine Pump2_Init
  379. subroutine Pump2_Step
  380. implicit none
  381. end subroutine Pump2_Step
  382. subroutine Pump2_Output
  383. implicit none
  384. end subroutine Pump2_Output
  385. subroutine Pump2MainBody
  386. use ifport
  387. use ifmt
  388. use CWarningsVariables
  389. implicit none
  390. integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  391. INTEGER :: MP_SolDuration
  392. Call Pump_StartUp
  393. loop1 : do
  394. Call sleepqq(10)
  395. ! Pump2 Malfunction ----> Power Failure
  396. if (PUMP(2)%PowerFailMalf==1) then
  397. Call ClosePump2()
  398. !MP2BLWR=0
  399. Call Pump2_OffMode_Solver(2)
  400. end if
  401. ! Pump2 Warning ----> Failure
  402. if (Pump2Failure==1) then
  403. !MP1BLWR=0
  404. Call Pump2_OffMode_Solver(2)
  405. Call ClosePump2()
  406. end if
  407. if (IsPortable) then
  408. PUMP(2)%AssignmentSwitchh = 1
  409. else
  410. PUMP(2)%AssignmentSwitchh = AssignmentSwitch
  411. end if
  412. if((any(PUMP(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (MP2Switch==1) .and. (MP2Throttle==0.).and. (PUMP(2)%PowerFailMalf==0)) then
  413. PUMP(2)%SoundBlower = .true.
  414. Call SetSoundBlowerMP2(PUMP(2)%SoundBlower)
  415. MP2BLWR = 1
  416. loop2: do
  417. CALL DATE_AND_TIME(values=MP_START_TIME)
  418. ! Pump2 Malfunction ----> Power Failure
  419. if (PUMP(2)%PowerFailMalf==1) then
  420. Call ClosePump2()
  421. !MP2BLWR=0
  422. Call Pump2_OffMode_Solver(2)
  423. exit loop2
  424. end if
  425. ! Pump2 Warning ----> Failure
  426. if (Pump2Failure==1) then
  427. Call ClosePump2()
  428. !MP2BLWR=0
  429. Call Pump2_OffMode_Solver(2)
  430. exit loop2
  431. end if
  432. PUMP(2)%N_new = MP2Throttle
  433. if (((PUMP(2)%N_new-PUMP(2)%N_old)/PUMP(2)%time_step)>193.) then
  434. PUMP(2)%N_ref = (193.*PUMP(2)%time_step)+PUMP(2)%N_old
  435. else if (((PUMP(2)%N_old-PUMP(2)%N_new)/PUMP(2)%time_step)>193.) then
  436. PUMP(2)%N_ref = (-193.*PUMP(2)%time_step)+PUMP(2)%N_old
  437. else
  438. PUMP(2)%N_ref = PUMP(2)%N_new
  439. end if
  440. Call Pump2_OnMode_Solver(2)
  441. !IF (PUMP(2)%Flow_Rate>0.) Then
  442. ! Call OpenPump2()
  443. !Else
  444. ! Call ClosePump2()
  445. !End if
  446. PUMP(2)%N_old=PUMP(2)%N_ref
  447. Call DATE_AND_TIME(values=MP_END_TIME)
  448. MP_SolDuration = 100-(MP_END_TIME(5)*3600000+MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(5)*3600000-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  449. !print*, 'MPtime=', MP_SolDuration
  450. if(MP_SolDuration > 0.0d0) then
  451. CALL sleepqq(MP_SolDuration)
  452. end if
  453. if (IsPortable) then
  454. PUMP(2)%AssignmentSwitchh = 1
  455. else
  456. PUMP(2)%AssignmentSwitchh = AssignmentSwitch
  457. end if
  458. if ((any(PUMP(2)%AssignmentSwitchh==(/6,9,10,12/))) .or. (MP2Switch==0) .or. (IsStopped == .true.)) then
  459. Call ClosePump2()
  460. PUMP(2)%SoundBlower = .false.
  461. Call SetSoundBlowerMP2(PUMP(2)%SoundBlower)
  462. MP2BLWR = 0
  463. Call Pump2_OffMode_Solver(2)
  464. exit loop2
  465. end if
  466. end do loop2
  467. else
  468. if (IsPortable) then
  469. PUMP(2)%AssignmentSwitchh = 1
  470. else
  471. PUMP(2)%AssignmentSwitchh = AssignmentSwitch
  472. end if
  473. if((any(PUMP(2)%AssignmentSwitchh==(/1,2,3,4,5,7,8,11/))) .and. (MP2Switch==1)) then
  474. PUMP(2)%SoundBlower = .true.
  475. Call SetSoundBlowerMP2(PUMP(2)%SoundBlower)
  476. MP2BLWR = 1
  477. else
  478. PUMP(2)%SoundBlower = .false.
  479. Call SetSoundBlowerMP2(PUMP(2)%SoundBlower)
  480. MP2BLWR = 0
  481. end if
  482. PUMP(2)%N_ref = MP2Throttle
  483. Call ClosePump2()
  484. Call Pump2_OffMode_Solver(2)
  485. end if
  486. if (IsStopped == .true.) then
  487. exit loop1
  488. end if
  489. end do loop1
  490. end subroutine Pump2MainBody
  491. ! ****************************************
  492. ! ***** subroutine Pump3MainBody *****
  493. ! ****************************
  494. subroutine Pump3_Setup()
  495. use CSimulationVariables
  496. implicit none
  497. call OnSimulationInitialization%Add(Pump3_Init)
  498. call OnSimulationStop%Add(Pump3_Init)
  499. call OnPump3Step%Add(Pump3_Step)
  500. call OnPump3Output%Add(Pump3_Output)
  501. call OnPump3Main%Add(Pump3MainBody)
  502. end subroutine
  503. subroutine Pump3_Init
  504. implicit none
  505. end subroutine Pump3_Init
  506. subroutine Pump3_Step
  507. implicit none
  508. end subroutine Pump3_Step
  509. subroutine Pump3_Output
  510. implicit none
  511. end subroutine Pump3_Output
  512. subroutine Pump3MainBody
  513. use ifport
  514. use ifmt
  515. implicit none
  516. integer,dimension(8) :: MP_START_TIME, MP_END_TIME
  517. INTEGER :: MP_SolDuration
  518. !Call Pump_StartUp
  519. !loop1 : do
  520. !
  521. ! Call sleepqq(10)
  522. !
  523. ! !!! Pump3 Malfunction ----> Power Failure
  524. ! !!if (PUMP(1)%PowerFailMalf==1) then
  525. ! !! !MP1BLWR=0
  526. ! !! Call Pump3_OffMode_Solver
  527. ! !! Call ClosePump1()
  528. ! !!end if
  529. !
  530. ! !if( (MP1CPSwitch==1) .and. (MP1Throttle==0.) .and. (PUMP(3)%PowerFailMalf==0) ) then
  531. !!
  532. !! loop2: do
  533. !!
  534. !! Call DATE_AND_TIME(values=MP_START_TIME)
  535. !!
  536. !!!! ! Pump3 Malfunction ----> Power Failure
  537. !!!! if (PUMP(1)%PowerFailMalf==1) then
  538. !!!! !MP1BLWR=0
  539. !!!! Pump3_OffMode_Solver
  540. !!!! Call ClosePump1()
  541. !!!! exit loop2
  542. !!!! end if
  543. !!
  544. !! PUMP(3)%N_new = MP1Throttle
  545. !! if (((PUMP(3)%N_new-PUMP(3)%N_old)/PUMP(3)%time_step)>193.) then
  546. !! PUMP(3)%N_ref =(193.*PUMP(3)%time_step)+PUMP(3)%N_old
  547. !! else if (((PUMP(3)%N_old-PUMP(3)%N_new)/PUMP(3)%time_step)>193.) then
  548. !! PUMP(3)%N_ref = (-193.*PUMP(3)%time_step)+PUMP(3)%N_old
  549. !! else
  550. !! PUMP(3)%N_ref = PUMP(3)%N_new
  551. !! end if
  552. !!
  553. !! Call Pump3_OnMode_Solver
  554. !!
  555. !! IF (PUMP(3)%Flow_Rate>0.) Then
  556. !! Call OpenCementPump()
  557. !! Else
  558. !! Call CloseCementPump()
  559. !! End if
  560. !!
  561. !! PUMP(3)%N_old = PUMP(3)%N_ref
  562. !!
  563. !! Call DATE_AND_TIME(values=MP_END_TIME)
  564. !! MP_SolDuration = 100-(MP_END_TIME(6)*60000+MP_END_TIME(7)*1000+MP_END_TIME(8)-MP_START_TIME(6)*60000-MP_START_TIME(7)*1000-MP_START_TIME(8))
  565. !! !print*, 'MPtime=', MP_SolDuration
  566. !! if(MP_SolDuration > 0.0) then
  567. !! Call sleepqq(MP_SolDuration)
  568. !! end if
  569. !!
  570. !! if ((MP1CPSwitch==0) .or. (IsStopped == .true.)) then
  571. !! Call Pump3_OffMode_Solver
  572. !! Call CloseCementPump()
  573. !! exit loop2
  574. !! end if
  575. !! end do loop2
  576. !
  577. ! else
  578. !
  579. ! !Call Pump3_OffMode_Solver
  580. ! !Call CloseCementPump()
  581. !
  582. ! end if
  583. !
  584. ! if (IsStopped == .true.) then
  585. ! exit loop1
  586. ! end if
  587. !
  588. !end do loop1
  589. end subroutine Pump3MainBody
  590. end module PumpsMain